You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ro...@apache.org on 2020/02/23 09:41:07 UTC

[cloudstack-primate] branch master updated: compute: disable settings when the vm is not stopped (#172)

This is an automated email from the ASF dual-hosted git repository.

rohit pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cloudstack-primate.git


The following commit(s) were added to refs/heads/master by this push:
     new cd7f290  compute: disable settings when the vm is not stopped (#172)
cd7f290 is described below

commit cd7f290117c7c539c7b577eab60d64f7fd3041bf
Author: davidjumani <dj...@gmail.com>
AuthorDate: Sun Feb 23 15:11:01 2020 +0530

    compute: disable settings when the vm is not stopped (#172)
    
    Ensures that the vm settings are shown only when VM is stopped.
    This fixes #161
    
    Signed-off-by: Rohit Yadav <ro...@shapeblue.com>
    Co-authored-by: Rohit Yadav <ro...@apache.org>
---
 src/components/view/DetailSettings.vue | 52 ++++++++++++++++++++--------------
 1 file changed, 30 insertions(+), 22 deletions(-)

diff --git a/src/components/view/DetailSettings.vue b/src/components/view/DetailSettings.vue
index d73dd6b..72744e3 100644
--- a/src/components/view/DetailSettings.vue
+++ b/src/components/view/DetailSettings.vue
@@ -17,26 +17,32 @@
 
 <template>
   <a-spin :spinning="loading">
-    <div v-show="!showAddDetail">
-      <a-button type="dashed" style="width: 100%" icon="plus" @click="showAddDetail = true">Add Setting</a-button>
-    </div>
-    <div v-show="showAddDetail">
-      <a-auto-complete
-        style="width: 100%"
-        :filterOption="filterOption"
-        :value="newKey"
-        :dataSource="Object.keys(detailOptions)"
-        placeholder="Name"
-        @change="e => onAddInputChange(e, 'newKey')" />
-      <a-auto-complete
-        style="width: 100%"
-        :filterOption="filterOption"
-        :value="newValue"
-        :dataSource="detailOptions[newKey]"
-        placeholder="Value"
-        @change="e => onAddInputChange(e, 'newValue')" />
-      <a-button type="primary" style="width: 25%" icon="plus" @click="addDetail">Add Setting</a-button>
-      <a-button type="dashed" style="width: 25%" icon="close" @click="showAddDetail = false">Cancel</a-button>
+    <a-alert
+      v-if="disableSettings"
+      banner
+      message="Please stop the virtual machine to access settings" />
+    <div v-else>
+      <div v-show="!showAddDetail">
+        <a-button type="dashed" style="width: 100%" icon="plus" @click="showAddDetail = true">Add Setting</a-button>
+      </div>
+      <div v-show="showAddDetail">
+        <a-auto-complete
+          style="width: 100%"
+          :filterOption="filterOption"
+          :value="newKey"
+          :dataSource="Object.keys(detailOptions)"
+          placeholder="Name"
+          @change="e => onAddInputChange(e, 'newKey')" />
+        <a-auto-complete
+          style="width: 100%"
+          :filterOption="filterOption"
+          :value="newValue"
+          :dataSource="detailOptions[newKey]"
+          placeholder="Value"
+          @change="e => onAddInputChange(e, 'newValue')" />
+        <a-button type="primary" style="width: 25%" icon="plus" @click="addDetail">Add Setting</a-button>
+        <a-button type="dashed" style="width: 25%" icon="close" @click="showAddDetail = false">Cancel</a-button>
+      </div>
     </div>
     <a-list size="large">
       <a-list-item :key="index" v-for="(item, index) in details">
@@ -56,7 +62,7 @@
             <span v-else @click="showEditDetail(index)">{{ item.value }}</span>
           </span>
         </a-list-item-meta>
-        <div slot="actions">
+        <div slot="actions" v-if="!disableSettings">
           <a-button shape="circle" size="default" @click="updateDetail(index)" v-if="item.edit">
             <a-icon type="check-circle" theme="twoTone" twoToneColor="#52c41a" />
           </a-button>
@@ -67,7 +73,7 @@
             <a-icon type="edit" />
           </a-button>
         </div>
-        <div slot="actions">
+        <div slot="actions" v-if="!disableSettings">
           <a-popconfirm
             title="Delete setting?"
             @confirm="deleteDetail(index)"
@@ -101,6 +107,7 @@ export default {
       details: [],
       detailOptions: {},
       showAddDetail: false,
+      disableSettings: false,
       newKey: '',
       newValue: '',
       loading: false,
@@ -136,6 +143,7 @@ export default {
       api('listDetailOptions', { resourcetype: this.resourceType, resourceid: this.resource.id }).then(json => {
         this.detailOptions = json.listdetailoptionsresponse.detailoptions.details
       })
+      this.disableSettings = (this.$route.meta.name === 'vm' && this.resource.state !== 'Stopped')
     },
     showEditDetail (index) {
       this.details[index].edit = true