1. Add manila share page in console and administrator 2. Add console create share 3. Add console edit share 4. Add delete share in console and administrator 5. Add share quota info in console overview page 6. Add share quota info in administrator project detail page 7. Add share metadata tab in share detail page 8. Add create share metadata in console 9. Add edit share metadata in console 10. Add delete share metadata in console and administrator 11. Add manage share metadata action in console 12. Add access rule tab in share detail page 13. Add crate access rule in console 14. Add delete acees rule in console and administrator 15. Add manage access rule metadata in console 16. Add manage access rule action in console Change-Id: I8c80c80340e214827bcde0d62dc0521e4b2b1ea9
140 lines
3.2 KiB
JavaScript
140 lines
3.2 KiB
JavaScript
// Copyright 2021 99cloud
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
import { inject, observer } from 'mobx-react';
|
|
import { ModalAction } from 'containers/Action';
|
|
import globalShareAccessRuleStore from 'stores/manila/share-access-rule';
|
|
import { keyValueValidator } from 'pages/share/containers/ShareType/actions/Create';
|
|
import KeyValueInput from 'components/FormItem/KeyValueInput';
|
|
import { updateAddSelectValueToObj } from 'utils/index';
|
|
|
|
export const metadataFormItem = {
|
|
name: 'metadata',
|
|
label: t('Metadata'),
|
|
type: 'add-select',
|
|
itemComponent: KeyValueInput,
|
|
addText: t('Add Metadata'),
|
|
keySpan: 8,
|
|
validator: keyValueValidator,
|
|
};
|
|
|
|
export class Create extends ModalAction {
|
|
static id = 'create';
|
|
|
|
static title = t('Add Access Rule');
|
|
|
|
get name() {
|
|
return t('add access rule');
|
|
}
|
|
|
|
static get modalSize() {
|
|
return 'middle';
|
|
}
|
|
|
|
getModalSize() {
|
|
return 'middle';
|
|
}
|
|
|
|
init() {
|
|
this.store = globalShareAccessRuleStore;
|
|
}
|
|
|
|
static policy = 'manila:share:allow_access';
|
|
|
|
static allowed = () => Promise.resolve(true);
|
|
|
|
get typeOptions() {
|
|
return [
|
|
{
|
|
value: 'ip',
|
|
label: t('IP'),
|
|
},
|
|
{
|
|
value: 'cert',
|
|
label: t('Cert'),
|
|
},
|
|
{
|
|
value: 'user',
|
|
label: t('User'),
|
|
},
|
|
{
|
|
value: 'cephx',
|
|
label: t('Cephx'),
|
|
},
|
|
];
|
|
}
|
|
|
|
get levelOptions() {
|
|
return [
|
|
{
|
|
value: 'rw',
|
|
label: t('Read and write'),
|
|
},
|
|
{
|
|
value: 'ro',
|
|
label: t('Read only'),
|
|
},
|
|
];
|
|
}
|
|
|
|
get defaultValue() {
|
|
return { isPublic: true };
|
|
}
|
|
|
|
get typeTip() {
|
|
return t(
|
|
"'ip' rule represents IPv4 or IPv6 address, 'cert' rule represents TLS certificate, 'user' rule represents username or usergroup, 'cephx' rule represents ceph auth ID."
|
|
);
|
|
}
|
|
|
|
get formItems() {
|
|
return [
|
|
{
|
|
name: 'access_type',
|
|
label: t('Access Type'),
|
|
type: 'select',
|
|
options: this.typeOptions,
|
|
required: true,
|
|
tip: this.typeTip,
|
|
},
|
|
{
|
|
name: 'access_level',
|
|
label: t('Access Level'),
|
|
type: 'select',
|
|
options: this.levelOptions,
|
|
required: true,
|
|
},
|
|
{
|
|
name: 'access_to',
|
|
label: t('Access To'),
|
|
type: 'input',
|
|
required: true,
|
|
},
|
|
metadataFormItem,
|
|
];
|
|
}
|
|
|
|
onSubmit = (values, containerProps) => {
|
|
const { detail: { id } = {} } = containerProps;
|
|
const { metadata, ...rest } = values;
|
|
const body = {
|
|
...rest,
|
|
metadata: updateAddSelectValueToObj(metadata),
|
|
};
|
|
return this.store.create(id, body);
|
|
};
|
|
}
|
|
|
|
export default inject('rootStore')(observer(Create));
|