import globalRootStore from 'stores/root';
import { yesNoOptions } from 'utils/constants';
import { isBoolean } from 'lodash';
export const firewallStatus = {
ACTIVE: t('Active'),
DOWN: t('Down'),
ERROR: t('Error'),
CREATED: t('Created'),
PENDING_CREATE: t('Pending Create'),
PENDING_UPDATE: t('Pending Update'),
PENDING_DELETE: t('Pending Delete'),
INACTIVE: t('Inactive'),
};
export const adminState = {
true: t('Up'),
false: t('Down'),
};
export const transitionStatus = [
'PENDING_CREATE',
'PENDING_DELETE',
];
export const isDefault = (item) => item.name === 'default';
export const isMine = (item) => item.project_id === globalRootStore.projectId;
export const hasNoProject = (item) =>
!item.project_name || item.project_name === '-';
export const getDefaultFilter = (name) => {
const options = yesNoOptions.map((it) => {
if (it.key) {
return {
...it,
checkLabel: name,
isQuick: true,
};
}
return it;
});
return {
label: name,
name: 'notDefault',
options,
filterFunc: (record, value) => {
if (isBoolean(value)) {
return value ? record : true;
}
return value === 'true' ? record : true;
},
};
};