@rancher/shell 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/brand/suse/dark/rancher-logo.svg +1 -148
- package/assets/brand/suse/rancher-logo.svg +1 -130
- package/assets/images/featured/img1.jpg +0 -0
- package/assets/images/featured.jpg +0 -0
- package/assets/images/generic-plugin.svg +7 -0
- package/assets/styles/themes/_dark.scss +3 -0
- package/assets/styles/themes/_light.scss +3 -0
- package/assets/styles/themes/_suse.scss +1 -1
- package/assets/translations/en-us.yaml +183 -45
- package/assets/translations/zh-hans.yaml +21 -24
- package/components/AsyncButton.vue +17 -2
- package/components/ButtonDropdown.vue +4 -0
- package/components/Carousel.vue +291 -0
- package/components/CommunityLinks.vue +69 -18
- package/components/CruResource.vue +11 -3
- package/components/Dialog.vue +102 -0
- package/components/ExplorerMembers.vue +2 -4
- package/components/ExplorerProjectsNamespaces.vue +6 -7
- package/components/IconMessage.vue +9 -1
- package/components/LocaleSelector.vue +62 -29
- package/components/ResourceTable.vue +7 -2
- package/components/SimpleBox.vue +6 -4
- package/components/SortableTable/index.vue +11 -21
- package/components/Tabbed/Tab.vue +5 -0
- package/components/Tabbed/index.vue +29 -2
- package/components/auth/Principal.vue +1 -0
- package/components/fleet/FleetBundles.vue +8 -3
- package/components/fleet/FleetSummary.vue +6 -0
- package/components/form/KeyValue.vue +80 -58
- package/components/form/NameNsDescription.vue +10 -4
- package/components/form/ResourceTabs/index.vue +5 -1
- package/components/formatter/ClusterLink.vue +3 -7
- package/components/nav/NamespaceFilter.vue +3 -3
- package/components/nav/TopLevelMenu.vue +10 -28
- package/config/footer.js +13 -14
- package/config/labels-annotations.js +2 -1
- package/config/product/explorer.js +5 -4
- package/config/product/legacy.js +0 -47
- package/config/product/multi-cluster-apps.js +0 -12
- package/config/product/settings.js +12 -1
- package/config/product/uiplugins.js +17 -0
- package/config/settings.js +21 -2
- package/config/types.js +5 -1
- package/config/uiplugins.js +60 -0
- package/content/docs/en-us/getting-started.md +1 -26
- package/core/plugins.js +12 -0
- package/detail/provisioning.cattle.io.cluster.vue +3 -3
- package/detail/workload/index.vue +2 -2
- package/dialog/DiagnosticTimingsDialog.vue +116 -0
- package/dialog/RotateCertificatesDialog.vue +9 -3
- package/edit/auth/azuread.vue +28 -9
- package/edit/networking.k8s.io.ingress/index.vue +2 -2
- package/edit/persistentvolume/index.vue +3 -0
- package/edit/pod.vue +27 -0
- package/edit/provisioning.cattle.io.cluster/rke2.vue +76 -5
- package/edit/service.vue +7 -5
- package/edit/workload/__tests__/Upgrading.test.ts +1 -0
- package/edit/workload/index.vue +13 -1
- package/edit/workload/mixins/workload.js +13 -13
- package/edit/workload/storage/ContainerMountPaths.vue +240 -0
- package/edit/workload/storage/Mount.vue +1 -0
- package/edit/workload/storage/awsElasticBlockStore.vue +20 -1
- package/edit/workload/storage/azureDisk.vue +22 -2
- package/edit/workload/storage/azureFile.vue +20 -2
- package/edit/workload/storage/csi/index.vue +23 -1
- package/edit/workload/storage/gcePersistentDisk.vue +20 -2
- package/edit/workload/storage/index.vue +23 -49
- package/edit/workload/storage/vsphereVolume.vue +11 -1
- package/layouts/default.vue +14 -8
- package/layouts/home.vue +9 -4
- package/layouts/plain.vue +10 -5
- package/list/management.cattle.io.setting.vue +3 -3
- package/list/provisioning.cattle.io.cluster.vue +1 -1
- package/machine-config/harvester.vue +5 -3
- package/models/catalog.cattle.io.uiplugin.js +34 -0
- package/models/cluster/node.js +25 -2
- package/models/fleet.cattle.io.bundle.js +1 -1
- package/models/harvesterhci.io.management.cluster.js +11 -5
- package/models/provisioning.cattle.io.cluster.js +12 -6
- package/models/workload.js +5 -3
- package/nuxt.config.js +69 -25
- package/package.json +108 -109
- package/pages/auth/login.vue +1 -1
- package/pages/c/_cluster/apps/charts/index.vue +46 -1
- package/pages/c/_cluster/apps/charts/install.vue +10 -9
- package/pages/c/_cluster/explorer/index.vue +72 -9
- package/pages/c/_cluster/explorer/tools/index.vue +12 -5
- package/pages/c/_cluster/mcapps/index.vue +1 -1
- package/pages/c/_cluster/settings/brand.vue +0 -40
- package/pages/c/_cluster/settings/links.vue +200 -0
- package/pages/c/_cluster/uiplugins/DeveloperInstallDialog.vue +232 -0
- package/pages/c/_cluster/uiplugins/InstallDialog.vue +242 -0
- package/pages/c/_cluster/uiplugins/PluginInfoPanel.vue +284 -0
- package/pages/c/_cluster/uiplugins/RemoveUIPlugins.vue +130 -0
- package/pages/c/_cluster/uiplugins/SetupUIPlugins.vue +253 -0
- package/pages/c/_cluster/uiplugins/UninstallDialog.vue +115 -0
- package/pages/c/_cluster/uiplugins/index.vue +694 -0
- package/pages/diagnostic.vue +185 -101
- package/pages/docs/_doc.vue +3 -1
- package/pages/home.vue +21 -56
- package/pages/prefs.vue +108 -88
- package/pages/safeMode.vue +17 -0
- package/pages/support/index.vue +23 -15
- package/pkg/dynamic-importer.lib.js +4 -0
- package/plugins/dashboard-store/resource-class.js +2 -2
- package/plugins/formatters.js +15 -0
- package/plugins/plugin.js +56 -4
- package/plugins/steve/mutations.js +1 -1
- package/plugins/steve/subscribe.js +94 -72
- package/plugins/steve/web-worker.steve-sub-worker.js +24 -15
- package/promptRemove/management.cattle.io.globalrole.vue +47 -0
- package/promptRemove/management.cattle.io.roletemplate.vue +47 -0
- package/promptRemove/mixin/roleDeletionCheck.js +97 -0
- package/scripts/publish-shell.sh +1 -1
- package/scripts/sync-shell-deps +37 -0
- package/store/catalog.js +9 -8
- package/store/i18n.js +10 -1
- package/store/prefs.js +16 -0
- package/store/type-map.js +32 -5
- package/store/uiplugins.ts +15 -61
- package/utils/__tests__/object.test.ts +0 -24
- package/utils/__tests__/selector.test.ts +1 -1
- package/utils/dynamic-importer.js +4 -0
- package/utils/grafana.js +2 -6
- package/utils/socket.js +41 -20
- package/utils/string.js +1 -7
- package/utils/validators/formRules/__tests__/index.test.ts +108 -0
- package/utils/validators/formRules/index.ts +9 -1
- package/yarn-error.log +195 -0
- package/pages/plugins.vue +0 -387
- package/server/verdaccio-middleware.js +0 -56
|
@@ -17,7 +17,6 @@ import { _EDIT, _VIEW } from '@shell/config/query-params';
|
|
|
17
17
|
import { setFavIcon } from '@shell/utils/favicon';
|
|
18
18
|
|
|
19
19
|
const Color = require('color');
|
|
20
|
-
const parse = require('url-parse');
|
|
21
20
|
|
|
22
21
|
export default {
|
|
23
22
|
layout: 'authenticated',
|
|
@@ -29,12 +28,10 @@ export default {
|
|
|
29
28
|
async fetch() {
|
|
30
29
|
const hash = await allHash({
|
|
31
30
|
uiPLSetting: this.$store.dispatch('management/find', { type: MANAGEMENT.SETTING, id: SETTING.PL }),
|
|
32
|
-
uiIssuesSetting: this.$store.dispatch('management/find', { type: MANAGEMENT.SETTING, id: SETTING.ISSUES }),
|
|
33
31
|
uiLogoDarkSetting: fetchOrCreateSetting(this.$store, SETTING.LOGO_DARK, ''),
|
|
34
32
|
uiLogoLightSetting: fetchOrCreateSetting(this.$store, SETTING.LOGO_LIGHT, ''),
|
|
35
33
|
uiColorSetting: fetchOrCreateSetting(this.$store, SETTING.PRIMARY_COLOR, ''),
|
|
36
34
|
uiLinkColorSetting: fetchOrCreateSetting(this.$store, SETTING.LINK_COLOR, ''),
|
|
37
|
-
uiCommunitySetting: fetchOrCreateSetting(this.$store, SETTING.COMMUNITY_LINKS, 'true'),
|
|
38
35
|
uiFaviconSetting: fetchOrCreateSetting(this.$store, SETTING.FAVICON, ''),
|
|
39
36
|
});
|
|
40
37
|
|
|
@@ -75,8 +72,6 @@ export default {
|
|
|
75
72
|
vendor: getVendor(),
|
|
76
73
|
uiPLSetting: {},
|
|
77
74
|
|
|
78
|
-
uiIssuesSetting: {},
|
|
79
|
-
|
|
80
75
|
uiLogoDarkSetting: {},
|
|
81
76
|
uiLogoDark: '',
|
|
82
77
|
uiLogoLightSetting: {},
|
|
@@ -94,8 +89,6 @@ export default {
|
|
|
94
89
|
uiLinkColor: null,
|
|
95
90
|
customizeLinkColor: false,
|
|
96
91
|
|
|
97
|
-
uiCommunitySetting: {},
|
|
98
|
-
|
|
99
92
|
errors: [],
|
|
100
93
|
|
|
101
94
|
};
|
|
@@ -134,22 +127,7 @@ export default {
|
|
|
134
127
|
this.errors.push(e);
|
|
135
128
|
},
|
|
136
129
|
|
|
137
|
-
validateUrl(url) {
|
|
138
|
-
const parsed = parse(url, {});
|
|
139
|
-
|
|
140
|
-
if (!parsed.protocol) {
|
|
141
|
-
this.errors.push(this.t('branding.uiIssues.invalidUrl'));
|
|
142
|
-
|
|
143
|
-
return false;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
return true;
|
|
147
|
-
},
|
|
148
|
-
|
|
149
130
|
async save(btnCB) {
|
|
150
|
-
if (this.uiIssuesSetting.value && !this.validateUrl(this.uiIssuesSetting.value)) {
|
|
151
|
-
return btnCB(false);
|
|
152
|
-
}
|
|
153
131
|
this.uiPLSetting.value = this.uiPLSetting.value.replaceAll(/[\<>&=#()"]/gm, '');
|
|
154
132
|
|
|
155
133
|
if (this.customizeLogo) {
|
|
@@ -183,12 +161,10 @@ export default {
|
|
|
183
161
|
try {
|
|
184
162
|
await Promise.all([
|
|
185
163
|
this.uiPLSetting.save(),
|
|
186
|
-
this.uiIssuesSetting.save(),
|
|
187
164
|
this.uiLogoDarkSetting.save(),
|
|
188
165
|
this.uiLogoLightSetting.save(),
|
|
189
166
|
this.uiColorSetting.save(),
|
|
190
167
|
this.uiLinkColorSetting.save(),
|
|
191
|
-
this.uiCommunitySetting.save(),
|
|
192
168
|
this.uiFaviconSetting.save()
|
|
193
169
|
]);
|
|
194
170
|
if (this.uiPLSetting.value !== this.vendor) {
|
|
@@ -219,22 +195,6 @@ export default {
|
|
|
219
195
|
<LabeledInput v-model="uiPLSetting.value" :label="t('branding.uiPL.label')" :mode="mode" :maxlength="100" />
|
|
220
196
|
</div>
|
|
221
197
|
</div>
|
|
222
|
-
|
|
223
|
-
<h3 class="mt-20 mb-5 pb-5">
|
|
224
|
-
{{ t('branding.uiIssues.label') }}
|
|
225
|
-
</h3>
|
|
226
|
-
<label class="text-label">
|
|
227
|
-
{{ t(`advancedSettings.descriptions.${ 'ui-issues' }`, {}, true) }}
|
|
228
|
-
</label>
|
|
229
|
-
<div :style="{'align-items':'center'}" class="row mt-10">
|
|
230
|
-
<div class="col span-6 pb-5">
|
|
231
|
-
<LabeledInput v-model="uiIssuesSetting.value" :label="t('branding.uiIssues.issuesUrl')" :mode="mode" />
|
|
232
|
-
</div>
|
|
233
|
-
<div class="col span-6">
|
|
234
|
-
<Checkbox :value="uiCommunitySetting.value === 'true'" :label="t('branding.uiIssues.communityLinks')" :mode="mode" @input="e=>$set(uiCommunitySetting, 'value', e.toString())" />
|
|
235
|
-
</div>
|
|
236
|
-
</div>
|
|
237
|
-
|
|
238
198
|
<h3 class="mt-20 mb-5 pb-5">
|
|
239
199
|
{{ t('branding.logos.label') }}
|
|
240
200
|
</h3>
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import Loading from '@shell/components/Loading';
|
|
3
|
+
import AsyncButton from '@shell/components/AsyncButton';
|
|
4
|
+
import Banner from '@components/Banner/Banner.vue';
|
|
5
|
+
import { MANAGEMENT } from '@shell/config/types';
|
|
6
|
+
import { fetchOrCreateSetting, SETTING } from '@shell/config/settings';
|
|
7
|
+
import { _EDIT, _VIEW } from '@shell/config/query-params';
|
|
8
|
+
import KeyValue from '@shell/components/form/KeyValue';
|
|
9
|
+
import { allHash } from '@shell/utils/promise';
|
|
10
|
+
import { mapGetters } from 'vuex';
|
|
11
|
+
|
|
12
|
+
const DEFAULT_CUSTOM_LINKS = [
|
|
13
|
+
{
|
|
14
|
+
order: 1,
|
|
15
|
+
key: 'customLinks.defaults.docs',
|
|
16
|
+
value: 'https://rancher.com/docs/rancher/v2.6/en'
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
order: 2,
|
|
20
|
+
key: 'customLinks.defaults.forums',
|
|
21
|
+
value: 'https://forums.rancher.com/'
|
|
22
|
+
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
order: 3,
|
|
26
|
+
key: 'customLinks.defaults.slack',
|
|
27
|
+
value: 'https://slack.rancher.io/'
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
order: 5,
|
|
31
|
+
key: 'customLinks.defaults.getStarted',
|
|
32
|
+
value: '/docs/getting-started'
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
const DEFAULT_SUPPORT_LINK = {
|
|
38
|
+
order: 4,
|
|
39
|
+
key: 'customLinks.defaults.issues',
|
|
40
|
+
value: 'https://github.com/rancher/dashboard/issues/new'
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const COMMUNITY_LINKS = [
|
|
44
|
+
{
|
|
45
|
+
order: 99,
|
|
46
|
+
key: 'customLinks.defaults.commercialSupport',
|
|
47
|
+
value: '/support'
|
|
48
|
+
}
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
export default {
|
|
52
|
+
layout: 'authenticated',
|
|
53
|
+
components: {
|
|
54
|
+
KeyValue,
|
|
55
|
+
Loading,
|
|
56
|
+
AsyncButton,
|
|
57
|
+
Banner,
|
|
58
|
+
},
|
|
59
|
+
async fetch() {
|
|
60
|
+
try {
|
|
61
|
+
const { uiIssuesSetting, uiCommunitySetting } = await allHash({
|
|
62
|
+
uiIssuesSetting: this.$store.dispatch('management/find', { type: MANAGEMENT.SETTING, id: SETTING.ISSUES }),
|
|
63
|
+
uiCommunitySetting: this.$store.dispatch('management/find', { type: MANAGEMENT.SETTING, id: SETTING.COMMUNITY_LINKS })
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
this.uiIssuesSetting = uiIssuesSetting;
|
|
67
|
+
this.uiCommunitySetting = uiCommunitySetting;
|
|
68
|
+
} catch {}
|
|
69
|
+
|
|
70
|
+
try {
|
|
71
|
+
const defaultIssueLink = !!this.uiIssuesSetting.value ? { key: this.t('customLinks.defaults.issues'), value: this.uiIssuesSetting.value } : DEFAULT_SUPPORT_LINK;
|
|
72
|
+
const defaultLinks = this.multiWithFallback([...DEFAULT_CUSTOM_LINKS, defaultIssueLink, ...COMMUNITY_LINKS]);
|
|
73
|
+
|
|
74
|
+
this.uiCustomLinks = await fetchOrCreateSetting(this.$store, SETTING.UI_CUSTOM_LINKS, JSON.stringify(defaultLinks));
|
|
75
|
+
|
|
76
|
+
await this.deprecateIssueLinks();
|
|
77
|
+
} catch {}
|
|
78
|
+
|
|
79
|
+
const sValue = this.uiCustomLinks?.value || JSON.stringify(this.multiWithFallback([...DEFAULT_CUSTOM_LINKS]));
|
|
80
|
+
|
|
81
|
+
this.value = JSON.parse(sValue);
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
data() {
|
|
85
|
+
return {
|
|
86
|
+
uiCustomLinks: {},
|
|
87
|
+
defaultValues: undefined,
|
|
88
|
+
bannerVal: {},
|
|
89
|
+
value: {},
|
|
90
|
+
errors: [],
|
|
91
|
+
showRestoredBanner: false
|
|
92
|
+
};
|
|
93
|
+
},
|
|
94
|
+
computed: {
|
|
95
|
+
...mapGetters({ multiWithFallback: 'i18n/multiWithFallback' }),
|
|
96
|
+
|
|
97
|
+
mode() {
|
|
98
|
+
const schema = this.$store.getters[`management/schemaFor`](MANAGEMENT.SETTING);
|
|
99
|
+
|
|
100
|
+
return schema?.resourceMethods?.includes('PUT') ? _EDIT : _VIEW;
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
methods: {
|
|
104
|
+
useDefaults() {
|
|
105
|
+
const nonCommercialRancherLinks = this.isCommercial ? [] : COMMUNITY_LINKS;
|
|
106
|
+
|
|
107
|
+
this.defaultValues = this.multiWithFallback([...DEFAULT_CUSTOM_LINKS, DEFAULT_SUPPORT_LINK, ...nonCommercialRancherLinks]);
|
|
108
|
+
|
|
109
|
+
this.showRestoredBanner = true;
|
|
110
|
+
|
|
111
|
+
setTimeout(() => {
|
|
112
|
+
this.showRestoredBanner = false;
|
|
113
|
+
}, 10000);
|
|
114
|
+
},
|
|
115
|
+
|
|
116
|
+
deprecateIssueLinks() {
|
|
117
|
+
if (this.uiIssuesSetting.value || this.uiIssuesSetting.value) {
|
|
118
|
+
this.uiIssuesSetting.value = '';
|
|
119
|
+
this.uiCommunitySetting.value = '';
|
|
120
|
+
|
|
121
|
+
return this.uiIssuesSetting.save();
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
|
|
125
|
+
async save(btnCB) {
|
|
126
|
+
this.uiCustomLinks.value = JSON.stringify(this.value);
|
|
127
|
+
this.errors = [];
|
|
128
|
+
try {
|
|
129
|
+
await this.uiCustomLinks.save();
|
|
130
|
+
btnCB(true);
|
|
131
|
+
} catch (err) {
|
|
132
|
+
this.errors.push(err);
|
|
133
|
+
btnCB(false);
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
</script>
|
|
139
|
+
<template>
|
|
140
|
+
<Loading v-if="$fetchState.pending" />
|
|
141
|
+
<div v-else>
|
|
142
|
+
<Banner v-if="showRestoredBanner" :color="'success'" label="Default restored" :closable="true" :label-key="'customLinks.restoreSuccess'" />
|
|
143
|
+
<h1
|
|
144
|
+
class="mb-20"
|
|
145
|
+
>
|
|
146
|
+
{{ t("customLinks.label") }}
|
|
147
|
+
</h1>
|
|
148
|
+
<div>
|
|
149
|
+
<label class="text-label">
|
|
150
|
+
{{ t(`customLinks.description`, {}, true) }}
|
|
151
|
+
</label>
|
|
152
|
+
<div class="ui-links-setting mt-20">
|
|
153
|
+
<KeyValue
|
|
154
|
+
v-model="value"
|
|
155
|
+
:default-value="defaultValues"
|
|
156
|
+
:as-map="false"
|
|
157
|
+
:key-label="t('customLinks.settings.keyLabel')"
|
|
158
|
+
:value-label="t('customLinks.settings.valueLabel')"
|
|
159
|
+
:add-label="t('customLinks.addLink')"
|
|
160
|
+
:mode="mode"
|
|
161
|
+
:read-allowed="false"
|
|
162
|
+
:protip="false"
|
|
163
|
+
/>
|
|
164
|
+
</div>
|
|
165
|
+
</div>
|
|
166
|
+
<template v-for="err in errors">
|
|
167
|
+
<Banner :key="err" color="error" :label="err" />
|
|
168
|
+
</template>
|
|
169
|
+
<div v-if="mode === 'edit'" class="mt-20">
|
|
170
|
+
<AsyncButton class="pull-right" mode="apply" @click="save" />
|
|
171
|
+
<button class="pull-right btn role-secondary mr-10" @click="useDefaults">
|
|
172
|
+
{{ t('customLinks.restoreDefaults') }}
|
|
173
|
+
</button>
|
|
174
|
+
</div>
|
|
175
|
+
</div>
|
|
176
|
+
</template>
|
|
177
|
+
<style scoped lang='scss'>
|
|
178
|
+
.overlay {
|
|
179
|
+
width: 100%;
|
|
180
|
+
height: 100%;
|
|
181
|
+
position: absolute;
|
|
182
|
+
top: 0;
|
|
183
|
+
left: 0;
|
|
184
|
+
background-color: var(--overlay-bg);
|
|
185
|
+
z-index: 1;
|
|
186
|
+
}
|
|
187
|
+
.ui-links-setting {
|
|
188
|
+
P {
|
|
189
|
+
line-height: 1.25;
|
|
190
|
+
margin-bottom: 10px;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
.underline {
|
|
194
|
+
text-decoration: underline;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
.input {
|
|
198
|
+
max-width: 25%;
|
|
199
|
+
}
|
|
200
|
+
</style>
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import AsyncButton from '@shell/components/AsyncButton';
|
|
3
|
+
import { LabeledInput } from '@components/Form/LabeledInput';
|
|
4
|
+
import Checkbox from '@components/Form/Checkbox/Checkbox.vue';
|
|
5
|
+
import { UI_PLUGIN } from '@shell/config/types';
|
|
6
|
+
import { UI_PLUGIN_NAMESPACE } from '@shell/config/uiplugins';
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
components: {
|
|
10
|
+
AsyncButton,
|
|
11
|
+
Checkbox,
|
|
12
|
+
LabeledInput,
|
|
13
|
+
},
|
|
14
|
+
|
|
15
|
+
data() {
|
|
16
|
+
return {
|
|
17
|
+
name: '',
|
|
18
|
+
location: '',
|
|
19
|
+
persist: false,
|
|
20
|
+
canModifyName: true,
|
|
21
|
+
canModifyLocation: true,
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
watch: {
|
|
26
|
+
name(neu, old) {
|
|
27
|
+
if (this.canModifyLocation) {
|
|
28
|
+
this.location = `/pkg/${ neu }/${ neu }.umd.min.js`;
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
location(neu, old) {
|
|
32
|
+
if (this.canModifyName) {
|
|
33
|
+
const names = neu.split('/');
|
|
34
|
+
let last = names[names.length - 1];
|
|
35
|
+
let index = last.indexOf('.umd.min.js');
|
|
36
|
+
|
|
37
|
+
if (index !== -1) {
|
|
38
|
+
last = last.substr(0, index);
|
|
39
|
+
} else {
|
|
40
|
+
index = last.indexOf('.umd.js');
|
|
41
|
+
if (index !== -1) {
|
|
42
|
+
last = last.substr(0, index);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
this.name = last;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
methods: {
|
|
52
|
+
showDialog() {
|
|
53
|
+
this.$modal.show('developerInstallPluginDialog');
|
|
54
|
+
},
|
|
55
|
+
closeDialog(result) {
|
|
56
|
+
this.$modal.hide('developerInstallPluginDialog');
|
|
57
|
+
this.$emit('closed', result);
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
updateName(v) {
|
|
61
|
+
this.canModifyName = v.length === 0;
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
updateLocation(v) {
|
|
65
|
+
this.canModifyLocation = v.length === 0;
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
async loadPlugin(btnCb) {
|
|
69
|
+
let name = this.name;
|
|
70
|
+
const url = this.location;
|
|
71
|
+
|
|
72
|
+
if (!name) {
|
|
73
|
+
const parts = url.split('/');
|
|
74
|
+
const n = parts[parts.length - 1];
|
|
75
|
+
|
|
76
|
+
// Split on '.'
|
|
77
|
+
name = n.split('.')[0];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Try and parse version number from the name
|
|
81
|
+
let version = '0.0.1';
|
|
82
|
+
let crdName = name;
|
|
83
|
+
|
|
84
|
+
const parts = name.split('-');
|
|
85
|
+
|
|
86
|
+
if (parts.length === 2) {
|
|
87
|
+
crdName = parts[0];
|
|
88
|
+
version = parts[1];
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (this.persist) {
|
|
92
|
+
const pluginCR = await this.$store.dispatch('management/create', {
|
|
93
|
+
type: UI_PLUGIN,
|
|
94
|
+
metadata: {
|
|
95
|
+
name,
|
|
96
|
+
namespace: UI_PLUGIN_NAMESPACE
|
|
97
|
+
},
|
|
98
|
+
spec: {
|
|
99
|
+
plugin: {
|
|
100
|
+
name: crdName,
|
|
101
|
+
version,
|
|
102
|
+
endpoint: url,
|
|
103
|
+
noCache: true,
|
|
104
|
+
metadata: {
|
|
105
|
+
developer: 'true',
|
|
106
|
+
direct: 'true'
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
try {
|
|
113
|
+
await pluginCR.save({ url: `/v1/${ UI_PLUGIN }`, method: 'POST' });
|
|
114
|
+
} catch (e) {
|
|
115
|
+
console.error('Could not create CRD for plugin', e); // eslint-disable-line no-console
|
|
116
|
+
btnCb(false);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
this.$plugin.loadAsync(name, url).then(() => {
|
|
121
|
+
this.closeDialog(true);
|
|
122
|
+
this.$store.dispatch('growl/success', {
|
|
123
|
+
title: this.t('plugins.success.title', { name }),
|
|
124
|
+
message: this.t('plugins.success.message'),
|
|
125
|
+
timeout: 3000,
|
|
126
|
+
}, { root: true });
|
|
127
|
+
btnCb(true);
|
|
128
|
+
}).catch((error) => {
|
|
129
|
+
btnCb(false);
|
|
130
|
+
// this.closeDialog(false);
|
|
131
|
+
const message = typeof error === 'object' ? this.t('plugins.error.message') : error;
|
|
132
|
+
|
|
133
|
+
this.$store.dispatch('growl/error', {
|
|
134
|
+
title: this.t('plugins.error.title'),
|
|
135
|
+
message,
|
|
136
|
+
timeout: 5000
|
|
137
|
+
}, { root: true });
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
</script>
|
|
143
|
+
|
|
144
|
+
<template>
|
|
145
|
+
<modal
|
|
146
|
+
name="developerInstallPluginDialog"
|
|
147
|
+
height="auto"
|
|
148
|
+
:scrollable="true"
|
|
149
|
+
>
|
|
150
|
+
<div class="plugin-install-dialog">
|
|
151
|
+
<h4>
|
|
152
|
+
{{ t('plugins.developer.title') }}
|
|
153
|
+
</h4>
|
|
154
|
+
<p>
|
|
155
|
+
{{ t('plugins.developer.prompt') }}
|
|
156
|
+
</p>
|
|
157
|
+
<div class="custom mt-10">
|
|
158
|
+
<div class="fields">
|
|
159
|
+
<LabeledInput v-model="location" v-focus label-key="plugins.developer.fields.url" @input="updateLocation" />
|
|
160
|
+
</div>
|
|
161
|
+
</div>
|
|
162
|
+
<div class="custom mt-10">
|
|
163
|
+
<div class="fields">
|
|
164
|
+
<LabeledInput v-model="name" label-key="plugins.developer.fields.name" @input="updateName" />
|
|
165
|
+
</div>
|
|
166
|
+
<div class="fields mt-10">
|
|
167
|
+
<Checkbox v-model="persist" label-key="plugins.developer.fields.persist" />
|
|
168
|
+
</div>
|
|
169
|
+
<div class="dialog-buttons mt-20">
|
|
170
|
+
<button class="btn role-secondary" @click="closeDialog()">
|
|
171
|
+
{{ t('generic.cancel') }}
|
|
172
|
+
</button>
|
|
173
|
+
<AsyncButton
|
|
174
|
+
mode="load"
|
|
175
|
+
@click="loadPlugin"
|
|
176
|
+
/>
|
|
177
|
+
</div>
|
|
178
|
+
</div>
|
|
179
|
+
</div>
|
|
180
|
+
</modal>
|
|
181
|
+
</template>
|
|
182
|
+
|
|
183
|
+
<style lang="scss" scoped>
|
|
184
|
+
.plugin-install-dialog {
|
|
185
|
+
padding: 10px;
|
|
186
|
+
|
|
187
|
+
h4 {
|
|
188
|
+
font-weight: bold;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.dialog-panel {
|
|
192
|
+
display: flex;
|
|
193
|
+
flex-direction: column;
|
|
194
|
+
min-height: 100px;
|
|
195
|
+
|
|
196
|
+
p {
|
|
197
|
+
margin-bottom: 5px;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.dialog-info {
|
|
201
|
+
flex: 1;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.toggle-advanced {
|
|
205
|
+
display: flex;
|
|
206
|
+
align-items: center;
|
|
207
|
+
cursor: pointer;
|
|
208
|
+
margin: 10px 0;
|
|
209
|
+
|
|
210
|
+
&:hover {
|
|
211
|
+
text-decoration: none;
|
|
212
|
+
color: var(--link);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.version-selector {
|
|
217
|
+
margin: 0 10px 10px 10px;
|
|
218
|
+
width: auto;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
.dialog-buttons {
|
|
223
|
+
display: flex;
|
|
224
|
+
justify-content: flex-end;
|
|
225
|
+
margin-top: 10px;
|
|
226
|
+
|
|
227
|
+
> *:not(:last-child) {
|
|
228
|
+
margin-right: 10px;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
</style>
|