1. Refactor group store 2. Refactor create group: add domain prop when create 3. Refactor edit group 4. Refactor user group manage user 5. Refactor group detail 6. Suppport actions in role detail 7. Refactor group list: add project/role column && domain dolumn; remove user number column Change-Id: If8f250da3ac27e5050c9fd4d31ad9954177ed0fe
87 lines
1.8 KiB
JavaScript
87 lines
1.8 KiB
JavaScript
import React from 'react';
|
|
import { Badge } from 'antd';
|
|
import globalDomainStore from 'stores/keystone/domain';
|
|
import globalRootStore from 'src/stores/root';
|
|
|
|
export const statusTypes = [
|
|
{
|
|
label: t('Enable'),
|
|
value: true,
|
|
},
|
|
{
|
|
label: t('Forbidden'),
|
|
value: false,
|
|
},
|
|
];
|
|
|
|
export const getDomainOptions = (self) => {
|
|
const { baseDomains } = globalRootStore;
|
|
const { domains } = globalDomainStore;
|
|
const domainList = (domains || []).filter(
|
|
(it) =>
|
|
baseDomains.indexOf(it.name) === -1 ||
|
|
it.id === (self.item || {}).domain_id
|
|
);
|
|
return domainList.map((it) => ({
|
|
label: it.name,
|
|
value: it.id,
|
|
key: it.id,
|
|
}));
|
|
};
|
|
|
|
export const getCheckedOptions = () => {
|
|
const { domains } = globalDomainStore;
|
|
return (domains || []).map((it) => ({
|
|
label: it.name,
|
|
value: it.id,
|
|
key: it.id,
|
|
}));
|
|
};
|
|
|
|
export const getDomainFormItem = (self) => {
|
|
return {
|
|
name: 'domain_id',
|
|
label: t('Affiliated Domain'),
|
|
type: 'select',
|
|
checkOptions: getCheckedOptions(),
|
|
checkBoxInfo: t('Show All Domain'),
|
|
options: getDomainOptions(self),
|
|
allowClear: false,
|
|
onChange: (e) => {
|
|
self.setState({
|
|
domain: e,
|
|
});
|
|
},
|
|
required: true,
|
|
};
|
|
};
|
|
|
|
export const enabledColumn = {
|
|
title: t('Enabled'),
|
|
dataIndex: 'enabled',
|
|
isHideable: true,
|
|
render: (val) => {
|
|
if (val === true) {
|
|
return <Badge color="green" text={t('Yes')} />;
|
|
}
|
|
return <Badge color="red" text={t('No')} />;
|
|
},
|
|
stringify: (val) => (val ? t('Yes') : t('No')),
|
|
};
|
|
|
|
export const nameDomainColumns = [
|
|
{
|
|
dataIndex: 'name',
|
|
title: t('Name'),
|
|
},
|
|
{
|
|
dataIndex: 'domainName',
|
|
title: t('Domain'),
|
|
},
|
|
];
|
|
|
|
export const transferFilterOption = (inputValue, record) => {
|
|
const { domainName, name } = record;
|
|
return name.includes(inputValue) || domainName.includes(inputValue);
|
|
};
|