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