feat: Support force-delete && reset-status share istance

1. Support force delete share instance
2. Support reset share instance status

Change-Id: I4ddc2c8b023c92e02b3f40406c4342cbd7e4f2c5
This commit is contained in:
Jingwei.Zhang 2022-05-16 10:36:49 +08:00
parent 0b7555328b
commit bc39f976a3
8 changed files with 193 additions and 0 deletions

View File

@ -836,6 +836,8 @@
"Forbidden Project": "Forbidden Project",
"Forbidden User": "Forbidden User",
"Forbidden the domain will have a negative impact, all project and user in domain will be forbidden": "Forbidden the domain will have a negative impact, all project and user in domain will be forbidden",
"Force Delete": "Force Delete",
"Force Delete Share Instance": "Force Delete Share Instance",
"Force release": "Force release",
"Forced Shutdown": "Forced Shutdown",
"Forced shutdown may result in data loss or file system damage. You can also take the initiative to shut down and perform operations.": "Forced shutdown may result in data loss or file system damage. You can also take the initiative to shut down and perform operations.",

View File

@ -836,6 +836,8 @@
"Forbidden Project": "禁用项目",
"Forbidden User": "禁用用户",
"Forbidden the domain will have a negative impact, all project and user in domain will be forbidden": "禁用域后,该域下面的项目和用户都会被禁止,用户将无法登陆",
"Force Delete": "强制删除",
"Force Delete Share Instance": "强制删除共享实例",
"Force release": "强制释放",
"Forced Shutdown": "强制关机",
"Forced shutdown may result in data loss or file system damage. You can also take the initiative to shut down and perform operations.": "强制关机可能会导致数据丢失或文件系统损坏,您也可以主动关机后再进行操作。",

View File

@ -17,6 +17,7 @@ import { ShareInstanceStore } from 'stores/manila/share-instance';
import Base from 'containers/TabDetail';
import { shareStatus } from 'resources/manila/share';
import BaseDetail from './BaseDetail';
import actionConfigs from '../actions';
export class Detail extends Base {
get name() {
@ -31,6 +32,10 @@ export class Detail extends Base {
return this.getRoutePath('shareInstance');
}
get actionConfigs() {
return actionConfigs;
}
get detailInfos() {
return [
{

View File

@ -0,0 +1,42 @@
// 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 { ConfirmAction } from 'containers/Action';
import globalShareInstanceStore from 'stores/manila/share-instance';
export default class Delete extends ConfirmAction {
get id() {
return 'delete';
}
get title() {
return t('Force Delete Share Instance');
}
get buttonType() {
return 'danger';
}
get buttonText() {
return t('Force Delete');
}
get actionName() {
return t('Force Delete Share Instance');
}
policy = 'manila:share_instance:force_delete';
onSubmit = (data) => globalShareInstanceStore.forceDelete(data);
}

View File

@ -0,0 +1,89 @@
// 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 globalShareInstanceStore from 'stores/manila/share-instance';
import { shareStatus } from 'resources/manila/share';
import { getOptions } from 'utils/index';
export class ResetStatus extends ModalAction {
static id = 'reset';
static title = t('Reset Status');
get name() {
return t('Reset Status');
}
get defaultValue() {
const { id, status } = this.item;
const value = {
id,
oldStatus: shareStatus[status] || status,
};
return value;
}
get instanceName() {
return (this.item || {}).id;
}
static policy = 'manila:share_instance:reset_status';
static allowed = () => Promise.resolve(true);
get statusOptions() {
const statusList = ['available', 'error'];
const { status } = this.item;
const leftStatusList = statusList.filter((it) => it !== status);
const options = getOptions(shareStatus).filter((it) =>
leftStatusList.includes(it.value)
);
return options;
}
get formItems() {
return [
{
name: 'id',
label: t('Share Instance'),
type: 'label',
iconType: 'instance',
},
{
name: 'oldStatus',
label: t('Current Status'),
type: 'label',
},
{
name: 'status',
label: t('New Status'),
type: 'select',
options: this.statusOptions,
},
];
}
init() {
this.store = globalShareInstanceStore;
}
onSubmit = (values) => {
const { id } = this.item;
return this.store.resetStatus(id, values);
};
}
export default inject('rootStore')(observer(ResetStatus));

View File

@ -0,0 +1,31 @@
// 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 Delete from './Delete';
import ResetStatus from './ResetStatus';
const actionConfigs = {
rowActions: {
firstAction: Delete,
moreActions: [
{
action: ResetStatus,
},
],
},
primaryActions: [],
batchActions: [Delete],
};
export default actionConfigs;

View File

@ -16,6 +16,7 @@ import { observer, inject } from 'mobx-react';
import Base from 'containers/List';
import globalShareInstanceStore from 'stores/manila/share-instance';
import { shareStatus } from 'resources/manila/share';
import actionConfigs from './actions';
export class ShareInstance extends Base {
init() {
@ -34,6 +35,10 @@ export class ShareInstance extends Base {
return false;
}
get actionConfigs() {
return actionConfigs;
}
getColumns = () => [
{
title: t('ID'),

View File

@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import { action } from 'mobx';
import client from 'client';
import Base from 'stores/base';
@ -32,6 +33,22 @@ export class ShareInstanceStore extends Base {
item.exportLocations = export_locations;
return item;
}
@action
forceDelete = ({ id }) => {
const body = {
force_delete: null,
};
return this.submitting(this.client.action(id, body));
};
@action
resetStatus(id, data) {
const body = {
reset_status: data,
};
return this.submitting(this.client.action(id, body));
}
}
const globalShareInstanceStore = new ShareInstanceStore();