From 79d41791bd54bf12fb47c87dcbed062d87ed5538 Mon Sep 17 00:00:00 2001 From: "Jingwei.Zhang" Date: Thu, 29 Sep 2022 15:51:04 +0800 Subject: [PATCH] fix: add vm state check for modify instance tags Modify instance tags is allowed when the vm_state value is one of active, paused, suspended, stopped Closes-Bug: #1991202 Change-Id: I1275053dd0aa57d777ba23046861d4c1b551ee03 --- .../compute/containers/Instance/actions/ModifyTags.jsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pages/compute/containers/Instance/actions/ModifyTags.jsx b/src/pages/compute/containers/Instance/actions/ModifyTags.jsx index f54dc9d0..4032bf53 100644 --- a/src/pages/compute/containers/Instance/actions/ModifyTags.jsx +++ b/src/pages/compute/containers/Instance/actions/ModifyTags.jsx @@ -28,7 +28,11 @@ export class ModifyTags extends ModalAction { static policy = 'os_compute_api:os-server-tags:update_all'; - static allowed = () => Promise.resolve(true); + static allowed = (item) => { + const allowedStates = ['active', 'paused', 'suspended', 'stopped']; + const { vm_state = '' } = item || {}; + return Promise.resolve(allowedStates.includes(vm_state.toLowerCase())); + }; get name() { return t('modify instance tags');