fix: fix create/delete encryption for volume type
Fix encryption check for volume type Change-Id: Id8d0b12e55e8b482d8667a8498f3fe1f82fd75f0
This commit is contained in:
parent
e65405bd8a
commit
8613ef39f3
@ -15,6 +15,7 @@
|
||||
import { inject, observer } from 'mobx-react';
|
||||
import { ModalAction } from 'containers/Action';
|
||||
import globalVolumeTypeStore from 'stores/cinder/volume-type';
|
||||
import { hasEncryption } from 'resources/cinder/volume-type';
|
||||
|
||||
export class CreateEncryption extends ModalAction {
|
||||
static id = 'create';
|
||||
@ -27,8 +28,7 @@ export class CreateEncryption extends ModalAction {
|
||||
|
||||
static policy = 'volume_extension:volume_type_encryption:create';
|
||||
|
||||
static allowed = (item) =>
|
||||
Promise.resolve(!(item.encryption && !item.encryption.deleted_at));
|
||||
static allowed = (item) => Promise.resolve(!hasEncryption(item));
|
||||
|
||||
get defaultValue() {
|
||||
const { name } = this.item;
|
||||
|
@ -13,6 +13,7 @@
|
||||
// limitations under the License.
|
||||
|
||||
import { ConfirmAction } from 'containers/Action';
|
||||
import { hasEncryption } from 'resources/cinder/volume-type';
|
||||
import globalVolumeTypeStore from 'stores/cinder/volume-type';
|
||||
|
||||
export default class DeleteEncryptionAction extends ConfirmAction {
|
||||
@ -38,8 +39,7 @@ export default class DeleteEncryptionAction extends ConfirmAction {
|
||||
|
||||
policy = 'volume_extension:volume_type_encryption:delete';
|
||||
|
||||
allowedCheckFunc = (data) =>
|
||||
Promise.resolve(data.encryption && !data.encryption.deleted_at);
|
||||
allowedCheckFunc = (data) => hasEncryption(data);
|
||||
|
||||
onSubmit = () => {
|
||||
const { id, encryption } = this.item;
|
||||
|
@ -12,6 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { isEmpty } from 'lodash';
|
||||
import { multiTip } from './volume';
|
||||
|
||||
export const consumerTypes = {
|
||||
@ -66,3 +67,11 @@ export const volumeTypeSelectProps = {
|
||||
columns: volumeTypeColumns,
|
||||
filterParams: volumeTypeFilters,
|
||||
};
|
||||
|
||||
export const hasEncryption = (volume) => {
|
||||
const { encryption } = volume || {};
|
||||
if (!encryption || isEmpty(encryption)) {
|
||||
return false;
|
||||
}
|
||||
return !encryption.deleted_at;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user