fix: Fix create share group type
1. Add share types select when create share group type 2. Add share types column in share group type list page Change-Id: I729e8120fa2017b277ce6987508c1fc1eca75dc1
This commit is contained in:
parent
9b6787121d
commit
4a4ad26a49
@ -1777,6 +1777,7 @@
|
||||
"Share Server": "Share Server",
|
||||
"Share Type": "Share Type",
|
||||
"Share Type Detail": "Share Type Detail",
|
||||
"Share Types": "Share Types",
|
||||
"Shared": "Shared",
|
||||
"Shared Image": "Shared Image",
|
||||
"Shared Network": "Shared Network",
|
||||
|
@ -1777,6 +1777,7 @@
|
||||
"Share Server": "共享服务器",
|
||||
"Share Type": "共享类型",
|
||||
"Share Type Detail": "共享类型详情",
|
||||
"Share Types": "共享类型",
|
||||
"Shared": "共享",
|
||||
"Shared Image": "共享镜像",
|
||||
"Shared Network": "共享网络",
|
||||
|
@ -15,6 +15,7 @@
|
||||
import { inject, observer } from 'mobx-react';
|
||||
import { ModalAction } from 'containers/Action';
|
||||
import globalShareGroupTypeStore from '@/stores/manila/share-group-type';
|
||||
import globalShareTypeStore from '@/stores/manila/share-type';
|
||||
import { projectTableOptions } from 'resources/project';
|
||||
import { ProjectStore } from 'stores/keystone/project';
|
||||
import { updateAddSelectValueToObj } from 'utils/index';
|
||||
@ -31,10 +32,16 @@ export class Create extends ModalAction {
|
||||
|
||||
init() {
|
||||
this.store = globalShareGroupTypeStore;
|
||||
this.typeStore = globalShareTypeStore;
|
||||
this.projectStore = new ProjectStore();
|
||||
this.getTypes();
|
||||
this.getProjects();
|
||||
}
|
||||
|
||||
getTypes() {
|
||||
this.typeStore.fetchList({ is_public: 'all' });
|
||||
}
|
||||
|
||||
getProjects() {
|
||||
this.projectStore.fetchList();
|
||||
}
|
||||
@ -56,15 +63,19 @@ export class Create extends ModalAction {
|
||||
}
|
||||
|
||||
get nameForStateUpdate() {
|
||||
return ['isPublic'];
|
||||
return ['is_public'];
|
||||
}
|
||||
|
||||
get defaultValue() {
|
||||
return { is_public: true };
|
||||
}
|
||||
|
||||
get shareTypes() {
|
||||
return globalShareTypeStore.list.data || [];
|
||||
}
|
||||
|
||||
get formItems() {
|
||||
const { isPublic } = this.state;
|
||||
const { is_public } = this.state;
|
||||
return [
|
||||
{
|
||||
name: 'name',
|
||||
@ -73,6 +84,37 @@ export class Create extends ModalAction {
|
||||
names: this.store.list.data.map((it) => it.name),
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
name: 'shareTypes',
|
||||
label: t('Share Types'),
|
||||
type: 'select-table',
|
||||
required: true,
|
||||
isMulti: true,
|
||||
data: this.shareTypes,
|
||||
isLoading: globalShareTypeStore.list.isLoading,
|
||||
filterParams: [
|
||||
{
|
||||
label: t('Name'),
|
||||
name: 'name',
|
||||
},
|
||||
],
|
||||
columns: [
|
||||
{
|
||||
title: t('Name'),
|
||||
dataIndex: 'name',
|
||||
},
|
||||
{
|
||||
title: t('Description'),
|
||||
dataIndex: 'description',
|
||||
valueRender: 'noValue',
|
||||
},
|
||||
{
|
||||
title: t('Public'),
|
||||
dataIndex: 'is_public',
|
||||
valueRender: 'yesNo',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'is_public',
|
||||
label: t('Public'),
|
||||
@ -85,7 +127,7 @@ export class Create extends ModalAction {
|
||||
label: t('Access Control'),
|
||||
type: 'select-table',
|
||||
isMulti: true,
|
||||
hidden: isPublic,
|
||||
hidden: is_public,
|
||||
data: this.projects,
|
||||
isLoading: this.projectStore.list.isLoading,
|
||||
...projectTableOptions,
|
||||
@ -95,8 +137,18 @@ export class Create extends ModalAction {
|
||||
}
|
||||
|
||||
onSubmit = (values) => {
|
||||
const { is_public, accessControl = {}, extra = [], ...rest } = values;
|
||||
const body = { is_public, ...rest };
|
||||
const {
|
||||
is_public,
|
||||
accessControl = {},
|
||||
extra = [],
|
||||
shareTypes,
|
||||
...rest
|
||||
} = values;
|
||||
const body = {
|
||||
is_public,
|
||||
share_types: shareTypes.selectedRowKeys,
|
||||
...rest,
|
||||
};
|
||||
let projectIds = [];
|
||||
const extraSpecs = updateAddSelectValueToObj(extra);
|
||||
body.group_specs = extraSpecs;
|
||||
|
@ -12,6 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import React from 'react';
|
||||
import { observer, inject } from 'mobx-react';
|
||||
import Base from 'containers/List';
|
||||
import globalShareGroupTypeStore from '@/stores/manila/share-group-type';
|
||||
@ -56,6 +57,13 @@ export class ShareGroupType extends Base {
|
||||
dataIndex: 'is_public',
|
||||
valueRender: 'yesNo',
|
||||
},
|
||||
{
|
||||
title: t('Share Types'),
|
||||
dataIndex: 'shareTypes',
|
||||
render: (value) => {
|
||||
return (value || []).map((it) => <div key={it.id}>{it.name}</div>);
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,10 @@ export class ShareGroupTypeStore extends Base {
|
||||
return client.manila.shareGroupTypes;
|
||||
}
|
||||
|
||||
get shareTypeClient() {
|
||||
return client.manila.types;
|
||||
}
|
||||
|
||||
get paramsFunc() {
|
||||
return (params) => params;
|
||||
}
|
||||
@ -41,6 +45,23 @@ export class ShareGroupTypeStore extends Base {
|
||||
return this.addProjectAccess(id, projectIds);
|
||||
}
|
||||
|
||||
async listDidFetch(items) {
|
||||
if (!items.length) {
|
||||
return items;
|
||||
}
|
||||
const result = await this.shareTypeClient.list({ is_public: 'all' });
|
||||
const { share_types: types = [] } = result;
|
||||
return items.map((it) => {
|
||||
const { share_types = [] } = it;
|
||||
return {
|
||||
...it,
|
||||
shareTypes: share_types.map((typeId) =>
|
||||
types.find((t) => t.id === typeId)
|
||||
),
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
update(id, data) {
|
||||
const body = {};
|
||||
|
Loading…
Reference in New Issue
Block a user