|
16 | 16 | // under the License. |
17 | 17 |
|
18 | 18 | <template> |
19 | | - <a-dropdown> |
| 19 | + <a-dropdown v-if="accessibleCreateActions && accessibleCreateActions.length > 0"> |
20 | 20 | <template #overlay> |
21 | 21 | <a-menu> |
22 | | - <a-menu-item style="width: 100%; padding: 12px" v-if="'deployVirtualMachine' in $store.getters.apis"> |
23 | | - <router-link :to="{ path: '/action/deployVirtualMachine'}"> |
| 22 | + <a-menu-item style="width: 100%; padding: 12px" v-for="menuItem in accessibleCreateActions" :key="menuItem.api"> |
| 23 | + <router-link :to="menuItem.route"> |
24 | 24 | <a-row> |
25 | 25 | <a-col style="margin-right: 12px"> |
26 | 26 | <a-avatar :style="{ backgroundColor: $config.theme['@primary-color'] }"> |
27 | 27 | <template #icon> |
28 | | - <cloud-server-outlined/> |
| 28 | + <render-icon v-if="(typeof menuItem.icon === 'string')" :icon="menuItem.icon" /> |
| 29 | + <font-awesome-icon v-else :icon="menuItem.icon" /> |
29 | 30 | </template> |
30 | 31 | </a-avatar> |
31 | 32 | </a-col> |
32 | 33 | <a-col> |
33 | 34 | <h3 style="margin-bottom: 0px;"> |
34 | | - {{ $t('label.instance') }} |
| 35 | + {{ menuItem.title }} |
35 | 36 | </h3> |
36 | | - <small>{{ $t('label.create.instance') }}</small> |
37 | | - </a-col> |
38 | | - </a-row> |
39 | | - </router-link> |
40 | | - </a-menu-item> |
41 | | - <a-menu-item style="width: 100%; padding: 12px" v-if="'createKubernetesCluster' in $store.getters.apis"> |
42 | | - <router-link :to="{ path: '/kubernetes', query: { action: 'createKubernetesCluster' } }"> |
43 | | - <a-row> |
44 | | - <a-col style="margin-right: 12px"> |
45 | | - <a-avatar :style="{ backgroundColor: $config.theme['@primary-color'] }"> |
46 | | - <template #icon> |
47 | | - <font-awesome-icon :icon="['fa-solid', 'fa-dharmachakra']" /> |
48 | | - </template> |
49 | | - </a-avatar> |
50 | | - </a-col> |
51 | | - <a-col> |
52 | | - <h3 style="margin-bottom: 0px;"> |
53 | | - {{ $t('label.kubernetes') }} |
54 | | - </h3> |
55 | | - <small>{{ $t('label.kubernetes.cluster.create') }}</small> |
56 | | - </a-col> |
57 | | - </a-row> |
58 | | - </router-link> |
59 | | - </a-menu-item> |
60 | | - <a-menu-item style="width: 100%; padding: 12px" v-if="'createVolume' in $store.getters.apis"> |
61 | | - <router-link :to="{ path: '/volume', query: { action: 'createVolume' } }"> |
62 | | - <a-row> |
63 | | - <a-col style="margin-right: 12px"> |
64 | | - <a-avatar :style="{ backgroundColor: $config.theme['@primary-color'] }"> |
65 | | - <template #icon> |
66 | | - <hdd-outlined /> |
67 | | - </template> |
68 | | - </a-avatar> |
69 | | - </a-col> |
70 | | - <a-col> |
71 | | - <h3 style="margin-bottom: 0px;"> |
72 | | - {{ $t('label.volume') }} |
73 | | - </h3> |
74 | | - <small>{{ $t('label.action.create.volume') }}</small> |
75 | | - </a-col> |
76 | | - </a-row> |
77 | | - </router-link> |
78 | | - </a-menu-item> |
79 | | - <a-menu-item style="width: 100%; padding: 12px" v-if="'createNetwork' in $store.getters.apis"> |
80 | | - <router-link :to="{ path: '/guestnetwork', query: { action: 'createNetwork' } }"> |
81 | | - <a-row> |
82 | | - <a-col style="margin-right: 12px"> |
83 | | - <a-avatar :style="{ backgroundColor: $config.theme['@primary-color'] }"> |
84 | | - <template #icon> |
85 | | - <apartment-outlined /> |
86 | | - </template> |
87 | | - </a-avatar> |
88 | | - </a-col> |
89 | | - <a-col> |
90 | | - <h3 style="margin-bottom: 0px;"> |
91 | | - {{ $t('label.network') }} |
92 | | - </h3> |
93 | | - <small>{{ $t('label.add.network') }}</small> |
94 | | - </a-col> |
95 | | - </a-row> |
96 | | - </router-link> |
97 | | - </a-menu-item> |
98 | | - <a-menu-item style="width: 100%; padding: 12px" v-if="'createVPC' in $store.getters.apis"> |
99 | | - <router-link :to="{ path: '/vpc', query: { action: 'createVPC' } }"> |
100 | | - <a-row> |
101 | | - <a-col style="margin-right: 12px"> |
102 | | - <a-avatar :style="{ backgroundColor: $config.theme['@primary-color'] }"> |
103 | | - <template #icon> |
104 | | - <deployment-unit-outlined /> |
105 | | - </template> |
106 | | - </a-avatar> |
107 | | - </a-col> |
108 | | - <a-col> |
109 | | - <h3 style="margin-bottom: 0px;"> |
110 | | - {{ $t('label.vpc') }} |
111 | | - </h3> |
112 | | - <small>{{ $t('label.add.vpc') }}</small> |
113 | | - </a-col> |
114 | | - </a-row> |
115 | | - </router-link> |
116 | | - </a-menu-item> |
117 | | - <a-menu-item style="width: 100%; padding: 12px" v-if="'registerTemplate' in $store.getters.apis"> |
118 | | - <router-link :to="{ path: '/template', query: { action: 'registerTemplate' } }"> |
119 | | - <a-row> |
120 | | - <a-col style="margin-right: 12px"> |
121 | | - <a-avatar :style="{ backgroundColor: $config.theme['@primary-color'] }"> |
122 | | - <template #icon> |
123 | | - <picture-outlined /> |
124 | | - </template> |
125 | | - </a-avatar> |
126 | | - </a-col> |
127 | | - <a-col> |
128 | | - <h3 style="margin-bottom: 0px;"> |
129 | | - {{ $t('label.templatename') }} |
130 | | - </h3> |
131 | | - <small>{{ $t('label.action.register.template') }}</small> |
132 | | - </a-col> |
133 | | - </a-row> |
134 | | - </router-link> |
135 | | - </a-menu-item> |
136 | | - <a-menu-item style="width: 100%; padding: 12px" v-if="'deployVnfAppliance' in $store.getters.apis"> |
137 | | - <router-link :to="{ path: '/action/deployVnfAppliance'}"> |
138 | | - <a-row> |
139 | | - <a-col style="margin-right: 12px"> |
140 | | - <a-avatar :style="{ backgroundColor: $config.theme['@primary-color'] }"> |
141 | | - <template #icon> |
142 | | - <font-awesome-icon :icon="['fa-solid', 'fa-dharmachakra']" /> |
143 | | - </template> |
144 | | - </a-avatar> |
145 | | - </a-col> |
146 | | - <a-col> |
147 | | - <h3 style="margin-bottom: 0px;"> |
148 | | - {{ $t('label.vnf.appliance') }} |
149 | | - </h3> |
150 | | - <small>{{ $t('label.vnf.appliance.add') }}</small> |
| 37 | + <small>{{ menuItem.subtitle }}</small> |
151 | 38 | </a-col> |
152 | 39 | </a-row> |
153 | 40 | </router-link> |
|
165 | 52 |
|
166 | 53 | export default { |
167 | 54 | name: 'CreateMenu', |
168 | | - components: { |
| 55 | + beforeCreate () { |
| 56 | + const menuItems = [ |
| 57 | + { |
| 58 | + api: 'deployVirtualMachine', |
| 59 | + title: this.$t('label.instance'), |
| 60 | + subtitle: this.$t('label.create.instance'), |
| 61 | + icon: 'cloud-server-outlined', |
| 62 | + route: { path: '/action/deployVirtualMachine' } |
| 63 | + }, |
| 64 | + { |
| 65 | + api: 'createKubernetesCluster', |
| 66 | + title: this.$t('label.kubernetes'), |
| 67 | + subtitle: this.$t('label.kubernetes.cluster.create'), |
| 68 | + icon: ['fa-solid', 'fa-dharmachakra'], |
| 69 | + route: { path: '/kubernetes', query: { action: 'createKubernetesCluster' } } |
| 70 | + }, |
| 71 | + { |
| 72 | + api: 'createVolume', |
| 73 | + title: this.$t('label.volume'), |
| 74 | + subtitle: this.$t('label.action.create.volume'), |
| 75 | + icon: 'hdd-outlined', |
| 76 | + route: { path: '/volume', query: { action: 'createVolume' } } |
| 77 | + }, |
| 78 | + { |
| 79 | + api: 'createNetwork', |
| 80 | + title: this.$t('label.network'), |
| 81 | + subtitle: this.$t('label.add.network'), |
| 82 | + icon: 'apartment-outlined', |
| 83 | + route: { path: '/guestnetwork', query: { action: 'createNetwork' } } |
| 84 | + }, |
| 85 | + { |
| 86 | + api: 'createVPC', |
| 87 | + title: this.$t('label.vpc'), |
| 88 | + subtitle: this.$t('label.add.vpc'), |
| 89 | + icon: 'deployment-unit-outlined', |
| 90 | + route: { path: '/vpc', query: { action: 'createVPC' } } |
| 91 | + }, |
| 92 | + { |
| 93 | + api: 'registerTemplate', |
| 94 | + title: this.$t('label.templatename'), |
| 95 | + subtitle: this.$t('label.action.register.template'), |
| 96 | + icon: 'picture-outlined', |
| 97 | + route: { path: '/template', query: { action: 'registerTemplate' } } |
| 98 | + }, |
| 99 | + { |
| 100 | + api: 'deployVnfAppliance', |
| 101 | + title: this.$t('label.vnf.appliance'), |
| 102 | + subtitle: this.$t('label.vnf.appliance.add'), |
| 103 | + icon: 'gateway-outlined', |
| 104 | + route: { path: '/action/deployVnfAppliance' } |
| 105 | + } |
| 106 | + ] |
| 107 | + this.accessibleCreateActions = menuItems.filter(m => m.api in this.$store.getters.apis) |
169 | 108 | } |
170 | 109 | } |
171 | 110 | </script> |
0 commit comments