@rancher/shell 0.1.3 → 0.1.21
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/favicon.png +0 -0
- 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 +1 -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 +219 -47
- 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 +64 -22
- package/components/CruResource.vue +11 -3
- package/components/Dialog.vue +102 -0
- package/components/ExplorerMembers.vue +2 -4
- package/components/ExplorerProjectsNamespaces.vue +25 -9
- package/components/IconMessage.vue +9 -1
- package/components/LazyImage.vue +21 -8
- package/components/LocaleSelector.vue +62 -29
- package/components/PromptRemove.vue +2 -2
- package/components/ResourceList/Masthead.vue +21 -1
- package/components/ResourceList/ResourceLoadingIndicator.vue +0 -8
- package/components/ResourceList/index.vue +9 -23
- package/components/ResourceTable.vue +7 -2
- package/components/SimpleBox.vue +6 -4
- package/components/SortableTable/index.vue +18 -25
- package/components/Tabbed/Tab.vue +5 -0
- package/components/Tabbed/index.vue +54 -9
- package/components/TypeDescription.vue +10 -1
- package/components/auth/Principal.vue +1 -0
- package/components/fleet/FleetBundles.vue +8 -3
- package/components/fleet/FleetClusters.vue +6 -0
- package/components/fleet/FleetRepos.vue +7 -1
- package/components/fleet/FleetSummary.vue +6 -0
- package/components/form/Command.vue +5 -0
- package/components/form/EnvVars.vue +5 -0
- package/components/form/KeyValue.vue +80 -58
- package/components/form/NameNsDescription.vue +13 -5
- package/components/form/NodeScheduling.vue +6 -1
- package/components/form/PodAffinity.vue +5 -0
- package/components/form/ResourceTabs/index.vue +5 -1
- package/components/form/ServiceNameSelect.vue +5 -0
- package/components/form/ValueFromResource.vue +7 -1
- package/components/formatter/ClusterLink.vue +3 -7
- package/components/nav/NamespaceFilter.vue +3 -3
- package/components/nav/TopLevelMenu.vue +12 -29
- package/config/home-links.js +155 -0
- package/config/labels-annotations.js +2 -1
- package/config/private-label.js +1 -1
- package/config/product/explorer.js +5 -4
- package/config/product/legacy.js +0 -47
- package/config/product/manager.js +0 -2
- 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 +23 -2
- package/config/types.js +5 -1
- package/config/uiplugins.js +117 -0
- package/config/version.js +17 -0
- package/content/docs/en-us/getting-started.md +1 -26
- package/core/plugin.ts +12 -0
- package/core/plugins.js +38 -2
- package/core/types.ts +6 -0
- package/creators/app/{.eslintignore → files/.eslintignore} +0 -0
- package/creators/app/{.eslintrc.js → files/.eslintrc.js} +0 -0
- package/creators/app/{.vscode → files/.vscode}/settings.json +0 -0
- package/creators/app/{babel.config.js → files/babel.config.js} +0 -0
- package/creators/app/{nuxt.config.js → files/nuxt.config.js} +0 -0
- package/creators/app/{tsconfig.json → files/tsconfig.json} +2 -1
- package/creators/app/init +16 -17
- package/creators/app/package.json +6 -0
- package/creators/pkg/{babel.config.js → files/babel.config.js} +0 -0
- package/creators/pkg/{index.ts → files/index.ts} +0 -0
- package/creators/pkg/{tsconfig.json → files/tsconfig.json} +13 -12
- package/creators/pkg/{vue.config.js → files/vue.config.js} +0 -0
- package/creators/pkg/init +1 -1
- package/creators/update/init +54 -0
- package/creators/update/package.json +20 -0
- package/creators/update/upgrade +56 -0
- package/creators/update/yarn-error.log +54 -0
- package/detail/provisioning.cattle.io.cluster.vue +3 -3
- package/detail/workload/index.vue +3 -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 +51 -13
- package/edit/persistentvolumeclaim.vue +31 -13
- package/edit/pod.vue +27 -0
- package/edit/provisioning.cattle.io.cluster/rke2.vue +103 -24
- package/edit/service.vue +7 -5
- package/edit/workload/__tests__/Upgrading.test.ts +1 -0
- package/edit/workload/index.vue +32 -10
- package/edit/workload/mixins/workload.js +121 -126
- 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 +33 -65
- package/edit/workload/storage/persistentVolumeClaim/index.vue +5 -0
- package/edit/workload/storage/secret.vue +6 -1
- 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/catalog.cattle.io.app.vue +10 -9
- package/list/catalog.cattle.io.clusterrepo.vue +6 -61
- package/list/cis.cattle.io.clusterscan.vue +12 -12
- package/list/fleet.cattle.io.bundle.vue +33 -28
- package/list/fleet.cattle.io.cluster.vue +26 -22
- package/list/fleet.cattle.io.clustergroup.vue +6 -0
- package/list/fleet.cattle.io.clusterregistrationtoken.vue +28 -24
- package/list/fleet.cattle.io.gitrepo.vue +25 -14
- package/list/helm.cattle.io.projecthelmchart.vue +52 -33
- package/list/logging.banzaicloud.io.clusterflow.vue +7 -12
- package/list/logging.banzaicloud.io.flow.vue +7 -14
- package/list/management.cattle.io.cluster.vue +26 -15
- package/list/management.cattle.io.feature.vue +13 -8
- package/list/management.cattle.io.setting.vue +3 -3
- package/list/management.cattle.io.user.vue +38 -19
- package/list/monitoring.coreos.com.alertmanagerconfig.vue +8 -15
- package/list/namespace.vue +14 -1
- package/list/node.vue +13 -16
- package/list/persistentvolume.vue +16 -9
- package/list/persistentvolumeclaim.vue +5 -8
- package/list/provisioning.cattle.io.cluster.vue +35 -9
- package/list/service.vue +24 -12
- package/list/ui.cattle.io.navlink.vue +6 -0
- package/list/workload.vue +2 -2
- package/machine-config/harvester.vue +5 -3
- package/middleware/authenticated.js +6 -0
- package/mixins/resource-fetch.js +12 -18
- package/mixins/resource-manager.js +126 -0
- package/models/catalog.cattle.io.uiplugin.js +38 -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/pod.js +15 -5
- package/models/provisioning.cattle.io.cluster.js +16 -6
- package/models/workload.js +5 -3
- package/models/workload.service.js +10 -0
- package/nuxt.config.js +70 -25
- package/package.json +108 -109
- package/pages/auth/login.vue +11 -1
- package/pages/auth/verify.vue +9 -0
- 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/DefaultLinksEditor.vue +108 -0
- package/pages/c/_cluster/settings/brand.vue +0 -40
- package/pages/c/_cluster/settings/links.vue +152 -0
- package/pages/c/_cluster/settings/performance.vue +90 -7
- package/pages/c/_cluster/uiplugins/DeveloperInstallDialog.vue +232 -0
- package/pages/c/_cluster/uiplugins/InstallDialog.vue +293 -0
- package/pages/c/_cluster/uiplugins/PluginInfoPanel.vue +300 -0
- package/pages/c/_cluster/uiplugins/RemoveUIPlugins.vue +125 -0
- package/pages/c/_cluster/uiplugins/SetupUIPlugins.vue +261 -0
- package/pages/c/_cluster/uiplugins/UninstallDialog.vue +122 -0
- package/pages/c/_cluster/uiplugins/index.vue +808 -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 +34 -137
- package/pkg/dynamic-importer.lib.js +4 -0
- package/plugins/dashboard-store/actions.js +19 -0
- package/plugins/dashboard-store/getters.js +20 -3
- package/plugins/dashboard-store/mutations.js +13 -7
- package/plugins/dashboard-store/resource-class.js +2 -2
- package/plugins/formatters.js +15 -0
- package/plugins/plugin.js +61 -6
- package/plugins/steve/getters.js +12 -0
- 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/plugins/version.js +21 -0
- 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/rancher-components/Form/TextArea/TextAreaAutoGrow.vue +6 -7
- package/rancher-components/components/BadgeState/BadgeState.spec.ts +12 -0
- package/rancher-components/components/BadgeState/BadgeState.vue +107 -0
- package/rancher-components/components/BadgeState/index.ts +1 -0
- package/rancher-components/components/Banner/Banner.test.ts +13 -0
- package/rancher-components/components/Banner/Banner.vue +163 -0
- package/rancher-components/components/Banner/index.ts +1 -0
- package/rancher-components/components/Card/Card.vue +150 -0
- package/rancher-components/components/Card/index.ts +1 -0
- package/rancher-components/components/Form/Checkbox/Checkbox.test.ts +77 -0
- package/rancher-components/components/Form/Checkbox/Checkbox.vue +395 -0
- package/rancher-components/components/Form/Checkbox/index.ts +1 -0
- package/rancher-components/components/Form/LabeledInput/LabeledInput.test.ts +29 -0
- package/rancher-components/components/Form/LabeledInput/LabeledInput.vue +343 -0
- package/rancher-components/components/Form/LabeledInput/index.ts +1 -0
- package/rancher-components/components/Form/Radio/RadioButton.vue +270 -0
- package/rancher-components/components/Form/Radio/RadioGroup.vue +235 -0
- package/rancher-components/components/Form/Radio/index.ts +2 -0
- package/rancher-components/components/Form/TextArea/TextAreaAutoGrow.vue +168 -0
- package/rancher-components/components/Form/TextArea/index.ts +1 -0
- package/rancher-components/components/Form/ToggleSwitch/ToggleSwitch.test.ts +107 -0
- package/rancher-components/components/Form/ToggleSwitch/ToggleSwitch.vue +137 -0
- package/rancher-components/components/Form/ToggleSwitch/index.ts +1 -0
- package/rancher-components/components/Form/index.ts +5 -0
- package/rancher-components/components/LabeledTooltip/LabeledTooltip.vue +137 -0
- package/rancher-components/components/LabeledTooltip/index.ts +1 -0
- package/scripts/publish-shell.sh +40 -7
- package/scripts/record-deps.js +37 -0
- package/scripts/sync-shell-deps +37 -0
- package/scripts/test-plugins-build.sh +8 -5
- package/scripts/typegen.sh +84 -0
- package/store/auth.js +3 -0
- package/store/catalog.js +9 -8
- package/store/i18n.js +10 -1
- package/store/index.js +12 -3
- package/store/prefs.js +16 -0
- package/store/type-map.js +32 -5
- package/store/uiplugins.ts +15 -61
- package/types/shell/index.d.ts +3046 -0
- 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/favicon.js +8 -2
- package/utils/gc/gc-interval.ts +40 -0
- package/utils/gc/gc-root-store.js +76 -0
- package/utils/gc/gc-route-changed.ts +44 -0
- package/utils/gc/gc-types.ts +21 -0
- package/utils/gc/gc.ts +282 -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/config/footer.js +0 -19
- package/creators/pkg/nuxt.config.js +0 -6
- package/pages/plugins.vue +0 -387
- package/server/verdaccio-middleware.js +0 -56
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import RoleDeletionCheck from '@shell/promptRemove/mixin/roleDeletionCheck';
|
|
3
|
+
export default {
|
|
4
|
+
name: 'RoleTemplatePromptRemove',
|
|
5
|
+
mixins: [RoleDeletionCheck],
|
|
6
|
+
props: {
|
|
7
|
+
value: {
|
|
8
|
+
type: Array,
|
|
9
|
+
default: () => {
|
|
10
|
+
return [];
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
type: {
|
|
15
|
+
type: String,
|
|
16
|
+
required: true
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<template>
|
|
23
|
+
<div>
|
|
24
|
+
<template>
|
|
25
|
+
{{ t('promptRemove.attemptingToRemove', { type }) }} <span
|
|
26
|
+
v-html="resourceNames(names, plusMore, t)"
|
|
27
|
+
></span>
|
|
28
|
+
</template>
|
|
29
|
+
<div v-if="info" class="text info mb-10 mt-20">
|
|
30
|
+
<span v-html="info" />
|
|
31
|
+
</div>
|
|
32
|
+
<div v-if="warning" class="text-warning mb-10 mt-20">
|
|
33
|
+
{{ warning }}
|
|
34
|
+
</div>
|
|
35
|
+
</div>
|
|
36
|
+
</template>
|
|
37
|
+
|
|
38
|
+
<style lang="scss" scoped>
|
|
39
|
+
.text.info {
|
|
40
|
+
display: flex;
|
|
41
|
+
align-items: center;
|
|
42
|
+
|
|
43
|
+
> span {
|
|
44
|
+
margin-right: 5px;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
</style>
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { mapState, mapGetters } from 'vuex';
|
|
2
|
+
import { resourceNames } from '@shell/utils/string';
|
|
3
|
+
import { MANAGEMENT } from '@shell/config/types';
|
|
4
|
+
import { SUBTYPE_MAPPING } from '@shell/models/management.cattle.io.roletemplate';
|
|
5
|
+
const CLUSTER = SUBTYPE_MAPPING.CLUSTER.key;
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
data() {
|
|
9
|
+
return {
|
|
10
|
+
warning: '',
|
|
11
|
+
info: '',
|
|
12
|
+
};
|
|
13
|
+
},
|
|
14
|
+
|
|
15
|
+
computed: {
|
|
16
|
+
...mapState('action-menu', ['toRemove']),
|
|
17
|
+
...mapGetters({ t: 'i18n/t' }),
|
|
18
|
+
|
|
19
|
+
names() {
|
|
20
|
+
return this.toRemove.map(obj => obj.nameDisplay).slice(0, 5);
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
plusMore() {
|
|
24
|
+
const remaining = this.toRemove.length - this.names.length;
|
|
25
|
+
|
|
26
|
+
return this.t('promptRemove.andOthers', { count: remaining });
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
watch: {
|
|
30
|
+
value: {
|
|
31
|
+
handler(neu) {
|
|
32
|
+
this.handleRoleDeletionCheck(neu, neu[0].type, this.$route.hash);
|
|
33
|
+
},
|
|
34
|
+
immediate: true
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
methods: {
|
|
38
|
+
resourceNames,
|
|
39
|
+
async handleRoleDeletionCheck(rolesToRemove, resourceType, queryHash) {
|
|
40
|
+
this.warning = '';
|
|
41
|
+
let resourceToCheck;
|
|
42
|
+
let propToMatch;
|
|
43
|
+
let numberOfRolesWithBinds = 0;
|
|
44
|
+
const uniqueUsersWithBinds = new Set();
|
|
45
|
+
|
|
46
|
+
this.info = this.t('rbac.globalRoles.waiting', { count: rolesToRemove.length });
|
|
47
|
+
|
|
48
|
+
switch (resourceType) {
|
|
49
|
+
case MANAGEMENT.GLOBAL_ROLE:
|
|
50
|
+
resourceToCheck = MANAGEMENT.GLOBAL_ROLE_BINDING;
|
|
51
|
+
propToMatch = 'globalRoleName';
|
|
52
|
+
break;
|
|
53
|
+
default:
|
|
54
|
+
if (queryHash.includes(CLUSTER)) {
|
|
55
|
+
resourceToCheck = MANAGEMENT.CLUSTER_ROLE_TEMPLATE_BINDING;
|
|
56
|
+
} else {
|
|
57
|
+
resourceToCheck = MANAGEMENT.PROJECT_ROLE_TEMPLATE_BINDING;
|
|
58
|
+
}
|
|
59
|
+
propToMatch = 'roleTemplateName';
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
try {
|
|
64
|
+
const request = await this.$store.dispatch('management/request', {
|
|
65
|
+
url: `/v1/${ resourceToCheck }`,
|
|
66
|
+
method: 'get',
|
|
67
|
+
}, { root: true });
|
|
68
|
+
|
|
69
|
+
if (request.data && request.data.length) {
|
|
70
|
+
rolesToRemove.forEach((toRemove) => {
|
|
71
|
+
const usedRoles = request.data.filter(item => item[propToMatch] === toRemove.id);
|
|
72
|
+
|
|
73
|
+
if (usedRoles.length) {
|
|
74
|
+
const uniqueUsers = [...new Set(usedRoles.map(item => item.userName))];
|
|
75
|
+
|
|
76
|
+
if (uniqueUsers.length) {
|
|
77
|
+
numberOfRolesWithBinds++;
|
|
78
|
+
uniqueUsers.forEach(user => uniqueUsersWithBinds.add(user));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
if (numberOfRolesWithBinds && uniqueUsersWithBinds.size) {
|
|
84
|
+
this.info = '';
|
|
85
|
+
this.warning = this.t('rbac.globalRoles.usersBound', { count: uniqueUsersWithBinds.size });
|
|
86
|
+
} else {
|
|
87
|
+
this.info = this.t('rbac.globalRoles.notBound', null, true);
|
|
88
|
+
}
|
|
89
|
+
} else {
|
|
90
|
+
this.info = this.t('rbac.globalRoles.notBound', null, true);
|
|
91
|
+
}
|
|
92
|
+
} catch (e) {
|
|
93
|
+
this.info = this.t('rbac.globalRoles.unableToCheck');
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
};
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import Vue from 'vue';
|
|
2
|
+
import Vue, { VueConstructor } from 'vue';
|
|
3
3
|
import debounce from 'lodash/debounce';
|
|
4
4
|
import { _EDIT, _VIEW } from '@shell/config/query-params';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
interface Vue {
|
|
9
|
-
queueResize(): void;
|
|
10
|
-
}
|
|
6
|
+
interface TextAreaResize {
|
|
7
|
+
queueResize(): void;
|
|
11
8
|
}
|
|
12
9
|
|
|
13
|
-
export default
|
|
10
|
+
export default (
|
|
11
|
+
Vue as VueConstructor<Vue & TextAreaResize>
|
|
12
|
+
).extend({
|
|
14
13
|
inheritAttrs: false,
|
|
15
14
|
|
|
16
15
|
props: {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { shallowMount } from '@vue/test-utils';
|
|
2
|
+
import { BadgeState } from './index';
|
|
3
|
+
|
|
4
|
+
describe('BadgeState.vue', () => {
|
|
5
|
+
it('renders props.msg when passed', () => {
|
|
6
|
+
const label = 'Hello, World!';
|
|
7
|
+
|
|
8
|
+
const wrapper = shallowMount(BadgeState, { propsData: { label } });
|
|
9
|
+
|
|
10
|
+
expect(wrapper.find('span').text()).toMatch(label);
|
|
11
|
+
});
|
|
12
|
+
});
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Vue, { PropType } from 'vue';
|
|
3
|
+
|
|
4
|
+
interface Badge {
|
|
5
|
+
stateBackground: string;
|
|
6
|
+
stateDisplay: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Badge state component.
|
|
11
|
+
* <p>Represents a badge whose label and color is either taken from the value property or
|
|
12
|
+
* from the label and color properties. The state property takes precedence.</p>
|
|
13
|
+
*/
|
|
14
|
+
export default Vue.extend({
|
|
15
|
+
props: {
|
|
16
|
+
/**
|
|
17
|
+
* A value having the properties `stateBackground` and `stateDisplay`
|
|
18
|
+
*/
|
|
19
|
+
value: {
|
|
20
|
+
type: Object as PropType<Badge>,
|
|
21
|
+
default: null
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Badge color. `stateBackground` of the value property takes precedence if supplied
|
|
26
|
+
*/
|
|
27
|
+
color: {
|
|
28
|
+
type: String,
|
|
29
|
+
default: null
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Optional icon to be shown before the label
|
|
34
|
+
*/
|
|
35
|
+
icon: {
|
|
36
|
+
type: String,
|
|
37
|
+
default: null
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Label to display in the badge. `stateDisplay` of the value property takes precedence if supplied
|
|
42
|
+
*/
|
|
43
|
+
label: {
|
|
44
|
+
type: String,
|
|
45
|
+
default: null
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
computed: {
|
|
50
|
+
bg(): string | null {
|
|
51
|
+
return this.value?.stateBackground || this.color;
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
msg(): string | null {
|
|
55
|
+
return this.value?.stateDisplay || this.label;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
</script>
|
|
60
|
+
|
|
61
|
+
<template>
|
|
62
|
+
<span :class="{'badge-state': true, [bg]: true}">
|
|
63
|
+
<i v-if="icon" class="icon" :class="{[icon]: true, 'mr-5': !!msg}" />{{ msg }}
|
|
64
|
+
</span>
|
|
65
|
+
</template>
|
|
66
|
+
|
|
67
|
+
<style lang="scss" scoped>
|
|
68
|
+
.badge-state {
|
|
69
|
+
align-items: center;
|
|
70
|
+
display: inline-flex;
|
|
71
|
+
padding: 2px 10px;
|
|
72
|
+
border: 1px solid transparent;
|
|
73
|
+
border-radius: 20px;
|
|
74
|
+
|
|
75
|
+
&.bg-info {
|
|
76
|
+
border-color: var(--primary);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
&.bg-error {
|
|
80
|
+
border-color: var(--error);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
&.bg-warning {
|
|
84
|
+
border-color: var(--warning);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Successful states are de-emphasized by using [text-]color instead of background-color
|
|
88
|
+
&.bg-success {
|
|
89
|
+
color: var(--success);
|
|
90
|
+
background: transparent;
|
|
91
|
+
border-color: var(--success);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
</style>
|
|
95
|
+
<style lang="scss">
|
|
96
|
+
// TODO: #6005
|
|
97
|
+
// Investigate why this is here.. I don't think that styles for sortable table should belong here
|
|
98
|
+
.sortable-table TD .badge-state {
|
|
99
|
+
@include clip;
|
|
100
|
+
display: inline-block;
|
|
101
|
+
max-width: 100%;
|
|
102
|
+
position: relative;
|
|
103
|
+
max-width: 110px;
|
|
104
|
+
font-size: .85em;
|
|
105
|
+
vertical-align: middle;
|
|
106
|
+
}
|
|
107
|
+
</style>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as BadgeState } from './BadgeState.vue';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { mount } from '@vue/test-utils';
|
|
2
|
+
import { Banner } from './index';
|
|
3
|
+
|
|
4
|
+
describe('component: Banner', () => {
|
|
5
|
+
it('should display text based on label', () => {
|
|
6
|
+
const label = 'test';
|
|
7
|
+
const wrapper = mount(Banner, { propsData: { label } });
|
|
8
|
+
|
|
9
|
+
const element = wrapper.find('span').element;
|
|
10
|
+
|
|
11
|
+
expect(element.textContent).toBe(label);
|
|
12
|
+
});
|
|
13
|
+
});
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Vue from 'vue';
|
|
3
|
+
import { nlToBr } from '@shell/utils/string';
|
|
4
|
+
import { stringify } from '@shell/utils/error';
|
|
5
|
+
|
|
6
|
+
export default Vue.extend({
|
|
7
|
+
props: {
|
|
8
|
+
/**
|
|
9
|
+
* A color class that represents the color of the banner.
|
|
10
|
+
* @values primary, secondary, success, warning, error, info
|
|
11
|
+
*/
|
|
12
|
+
color: {
|
|
13
|
+
type: String,
|
|
14
|
+
default: 'secondary'
|
|
15
|
+
},
|
|
16
|
+
/**
|
|
17
|
+
* The label to display as the banner's default content.
|
|
18
|
+
*/
|
|
19
|
+
label: {
|
|
20
|
+
type: [String, Error, Object],
|
|
21
|
+
default: null
|
|
22
|
+
},
|
|
23
|
+
/**
|
|
24
|
+
* The i18n key for the label to display as the banner's default content.
|
|
25
|
+
*/
|
|
26
|
+
labelKey: {
|
|
27
|
+
type: String,
|
|
28
|
+
default: null
|
|
29
|
+
},
|
|
30
|
+
/**
|
|
31
|
+
* Toggles the banner's close button.
|
|
32
|
+
*/
|
|
33
|
+
closable: {
|
|
34
|
+
type: Boolean,
|
|
35
|
+
default: false
|
|
36
|
+
},
|
|
37
|
+
/**
|
|
38
|
+
* Toggles the stacked class for the banner.
|
|
39
|
+
*/
|
|
40
|
+
stacked: {
|
|
41
|
+
type: Boolean,
|
|
42
|
+
default: false
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
computed: {
|
|
46
|
+
/**
|
|
47
|
+
* Return message text as label.
|
|
48
|
+
*/
|
|
49
|
+
messageLabel(): string | void {
|
|
50
|
+
return !(typeof this.label === 'string') ? stringify(this.label) : undefined;
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
methods: { nlToBr }
|
|
54
|
+
});
|
|
55
|
+
</script>
|
|
56
|
+
<template>
|
|
57
|
+
<div
|
|
58
|
+
class="banner"
|
|
59
|
+
:class="{
|
|
60
|
+
[color]: true,
|
|
61
|
+
closable,
|
|
62
|
+
stacked
|
|
63
|
+
}"
|
|
64
|
+
>
|
|
65
|
+
<slot>
|
|
66
|
+
<t v-if="labelKey" :k="labelKey" :raw="true" />
|
|
67
|
+
<span v-else-if="messageLabel">{{ messageLabel }}</span>
|
|
68
|
+
<span v-else v-html="nlToBr(label)" />
|
|
69
|
+
</slot>
|
|
70
|
+
<div v-if="closable" class="closer" @click="$emit('close')">
|
|
71
|
+
<i class="icon icon-2x icon-close closer-icon" />
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
74
|
+
</template>
|
|
75
|
+
|
|
76
|
+
<style lang="scss" scoped>
|
|
77
|
+
$left-border-size: 4px;
|
|
78
|
+
|
|
79
|
+
.banner {
|
|
80
|
+
padding: 10px;
|
|
81
|
+
margin: 15px 0;
|
|
82
|
+
width: 100%;
|
|
83
|
+
transition: all 0.2s ease;
|
|
84
|
+
position: relative;
|
|
85
|
+
line-height: 20px;
|
|
86
|
+
|
|
87
|
+
&.stacked {
|
|
88
|
+
padding: 0 10px;
|
|
89
|
+
margin: 0;
|
|
90
|
+
transition: none;
|
|
91
|
+
&:first-child {
|
|
92
|
+
padding-top: 10px;
|
|
93
|
+
}
|
|
94
|
+
&:last-child {
|
|
95
|
+
padding-bottom: 10px;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
&.closable {
|
|
100
|
+
padding-right: 40px;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.closer {
|
|
104
|
+
display: flex;
|
|
105
|
+
align-items: center;
|
|
106
|
+
|
|
107
|
+
cursor: pointer;
|
|
108
|
+
position: absolute;
|
|
109
|
+
top: 0;
|
|
110
|
+
right: 0;
|
|
111
|
+
bottom: 0;
|
|
112
|
+
width: 40px;
|
|
113
|
+
line-height: 42px;
|
|
114
|
+
text-align: center;
|
|
115
|
+
|
|
116
|
+
.closer-icon {
|
|
117
|
+
font-size: 22px;
|
|
118
|
+
opacity: 0.7;
|
|
119
|
+
|
|
120
|
+
&:hover {
|
|
121
|
+
opacity: 1;
|
|
122
|
+
color: var(--link);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
&.primary {
|
|
128
|
+
background: var(--primary);
|
|
129
|
+
border-left: solid $left-border-size var(--primary);
|
|
130
|
+
color: var(--body-text);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
&.secondary {
|
|
134
|
+
background: var(--default-banner-bg);
|
|
135
|
+
border-left: solid $left-border-size var(--default);
|
|
136
|
+
color: var(--body-text);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
&.success {
|
|
140
|
+
background: var(--success-banner-bg);
|
|
141
|
+
border-left: solid $left-border-size var(--success);
|
|
142
|
+
color: var(--body-text);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
&.info {
|
|
146
|
+
background: var(--info-banner-bg);
|
|
147
|
+
border-left: solid $left-border-size var(--info);
|
|
148
|
+
color: var(--body-text);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
&.warning {
|
|
152
|
+
background: var(--warning-banner-bg);
|
|
153
|
+
border-left: solid $left-border-size var(--warning);
|
|
154
|
+
color: var(--body-text);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
&.error {
|
|
158
|
+
background: var(--error-banner-bg);
|
|
159
|
+
border-left: solid $left-border-size var(--error);
|
|
160
|
+
color: var(--error);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
</style>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Banner } from './Banner.vue';
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Vue from 'vue';
|
|
3
|
+
|
|
4
|
+
export default Vue.extend({
|
|
5
|
+
name: 'Card',
|
|
6
|
+
props: {
|
|
7
|
+
/**
|
|
8
|
+
* The card's title.
|
|
9
|
+
*/
|
|
10
|
+
title: {
|
|
11
|
+
type: String,
|
|
12
|
+
default: ''
|
|
13
|
+
},
|
|
14
|
+
/**
|
|
15
|
+
* The text content for the card's body.
|
|
16
|
+
*/
|
|
17
|
+
content: {
|
|
18
|
+
type: String,
|
|
19
|
+
default: ''
|
|
20
|
+
},
|
|
21
|
+
/**
|
|
22
|
+
* The function to invoke when the default action button is clicked.
|
|
23
|
+
*/
|
|
24
|
+
buttonAction: {
|
|
25
|
+
type: Function,
|
|
26
|
+
default: (): void => { }
|
|
27
|
+
},
|
|
28
|
+
/**
|
|
29
|
+
* The text for the default action button.
|
|
30
|
+
*/
|
|
31
|
+
buttonText: {
|
|
32
|
+
type: String,
|
|
33
|
+
default: 'go'
|
|
34
|
+
},
|
|
35
|
+
/**
|
|
36
|
+
* Toggles the card's highlight-border class.
|
|
37
|
+
*/
|
|
38
|
+
showHighlightBorder: {
|
|
39
|
+
type: Boolean,
|
|
40
|
+
default: true
|
|
41
|
+
},
|
|
42
|
+
/**
|
|
43
|
+
* Toggles the card's Actions section.
|
|
44
|
+
*/
|
|
45
|
+
showActions: {
|
|
46
|
+
type: Boolean,
|
|
47
|
+
default: true
|
|
48
|
+
},
|
|
49
|
+
sticky: {
|
|
50
|
+
type: Boolean,
|
|
51
|
+
default: false,
|
|
52
|
+
},
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
</script>
|
|
56
|
+
|
|
57
|
+
<template>
|
|
58
|
+
<div class="card-container" :class="{'highlight-border': showHighlightBorder, 'card-sticky': sticky}">
|
|
59
|
+
<div class="card-wrap">
|
|
60
|
+
<div class="card-title">
|
|
61
|
+
<slot name="title">
|
|
62
|
+
{{ title }}
|
|
63
|
+
</slot>
|
|
64
|
+
</div>
|
|
65
|
+
<hr />
|
|
66
|
+
<div class="card-body">
|
|
67
|
+
<slot name="body">
|
|
68
|
+
{{ content }}
|
|
69
|
+
</slot>
|
|
70
|
+
</div>
|
|
71
|
+
<div v-if="showActions" class="card-actions">
|
|
72
|
+
<slot name="actions">
|
|
73
|
+
<button class="btn role-primary" @click="buttonAction">
|
|
74
|
+
{{ buttonText }}
|
|
75
|
+
</button>
|
|
76
|
+
</slot>
|
|
77
|
+
</div>
|
|
78
|
+
</div>
|
|
79
|
+
</div>
|
|
80
|
+
</template>
|
|
81
|
+
|
|
82
|
+
<style lang='scss'>
|
|
83
|
+
.card-container {
|
|
84
|
+
&.highlight-border {
|
|
85
|
+
border-left: 5px solid var(--primary);
|
|
86
|
+
}
|
|
87
|
+
border-radius: var(--border-radius);
|
|
88
|
+
display: flex;
|
|
89
|
+
flex-basis: 40%;
|
|
90
|
+
margin: 10px;
|
|
91
|
+
min-height: 100px;
|
|
92
|
+
padding: 10px;
|
|
93
|
+
box-shadow: 0 0 20px var(--shadow);
|
|
94
|
+
&:not(.top) {
|
|
95
|
+
align-items: top;
|
|
96
|
+
flex-direction: row;
|
|
97
|
+
justify-content: start;
|
|
98
|
+
}
|
|
99
|
+
.card-wrap {
|
|
100
|
+
width: 100%;
|
|
101
|
+
}
|
|
102
|
+
& .card-body {
|
|
103
|
+
color: var(--input-label);
|
|
104
|
+
display: flex;
|
|
105
|
+
flex-direction: column;
|
|
106
|
+
justify-content: center;
|
|
107
|
+
}
|
|
108
|
+
& .card-actions {
|
|
109
|
+
align-self: end;
|
|
110
|
+
display: flex;
|
|
111
|
+
padding-top: 20px;
|
|
112
|
+
}
|
|
113
|
+
& .card-title {
|
|
114
|
+
align-items: center;
|
|
115
|
+
display: flex;
|
|
116
|
+
width: 100%;
|
|
117
|
+
h5 {
|
|
118
|
+
margin: 0;
|
|
119
|
+
}
|
|
120
|
+
.flex-right {
|
|
121
|
+
margin-left: auto;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Sticky mode will stick header and footer to top and bottom with content in the middle scrolling
|
|
126
|
+
&.card-sticky {
|
|
127
|
+
// display: flex;
|
|
128
|
+
// flex-direction: column;
|
|
129
|
+
overflow: hidden;
|
|
130
|
+
|
|
131
|
+
.card-wrap {
|
|
132
|
+
display: flex;
|
|
133
|
+
flex-direction: column;
|
|
134
|
+
|
|
135
|
+
.card-body {
|
|
136
|
+
justify-content: flex-start;
|
|
137
|
+
overflow: scroll;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
> * {
|
|
141
|
+
flex: 0;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.card-body {
|
|
145
|
+
flex: 1;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
</style>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Card } from './Card.vue';
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { shallowMount } from '@vue/test-utils';
|
|
2
|
+
import { Checkbox } from './index';
|
|
3
|
+
|
|
4
|
+
describe('Checkbox.vue', () => {
|
|
5
|
+
it('is unchecked by default', () => {
|
|
6
|
+
const wrapper = shallowMount(Checkbox);
|
|
7
|
+
const cbInput = wrapper.find('input[type="checkbox"]').element as HTMLInputElement;
|
|
8
|
+
|
|
9
|
+
expect(cbInput.checked).toBe(false);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('renders a true value', () => {
|
|
13
|
+
const wrapper = shallowMount(Checkbox, { propsData: { value: true } });
|
|
14
|
+
const cbInput = wrapper.find('input[type="checkbox"]').element as HTMLInputElement;
|
|
15
|
+
|
|
16
|
+
expect(cbInput.checked).toBe(true);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('updates from false to true when props change', async () => {
|
|
20
|
+
const wrapper = shallowMount(Checkbox);
|
|
21
|
+
const cbInput = wrapper.find('input[type="checkbox"]').element as HTMLInputElement;
|
|
22
|
+
|
|
23
|
+
expect(cbInput.checked).toBe(false);
|
|
24
|
+
|
|
25
|
+
await wrapper.setProps({ value: true });
|
|
26
|
+
|
|
27
|
+
expect(cbInput.checked).toBe(true);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('emits an input event with a true value', async () => {
|
|
31
|
+
const wrapper = shallowMount(Checkbox);
|
|
32
|
+
const event = {
|
|
33
|
+
target: { tagName: 'input', href: null },
|
|
34
|
+
stopPropagation: () => { },
|
|
35
|
+
preventDefault: () => { }
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
(wrapper.vm as any).clicked(event);
|
|
39
|
+
await wrapper.vm.$nextTick();
|
|
40
|
+
|
|
41
|
+
expect(wrapper.emitted().input?.length).toBe(1);
|
|
42
|
+
expect(wrapper.emitted().input?.[0][0]).toBe(true);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('emits an input event with a custom valueWhenTrue', async () => {
|
|
46
|
+
const valueWhenTrue = 'BIG IF TRUE';
|
|
47
|
+
const event = {
|
|
48
|
+
target: { tagName: 'input', href: null },
|
|
49
|
+
stopPropagation: () => { },
|
|
50
|
+
preventDefault: () => { }
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const wrapper = shallowMount(Checkbox, { propsData: { value: false, valueWhenTrue } });
|
|
54
|
+
|
|
55
|
+
(wrapper.vm as any).clicked(event);
|
|
56
|
+
await wrapper.vm.$nextTick();
|
|
57
|
+
|
|
58
|
+
expect(wrapper.emitted().input?.length).toBe(1);
|
|
59
|
+
expect(wrapper.emitted().input?.[0][0]).toBe(valueWhenTrue);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('updates from valueWhenTrue to falsy', async () => {
|
|
63
|
+
const valueWhenTrue = 'REAL HUGE IF FALSE';
|
|
64
|
+
const event = {
|
|
65
|
+
target: { tagName: 'input', href: null },
|
|
66
|
+
stopPropagation: () => { },
|
|
67
|
+
preventDefault: () => { }
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const wrapper = shallowMount(Checkbox, { propsData: { value: valueWhenTrue, valueWhenTrue } });
|
|
71
|
+
|
|
72
|
+
(wrapper.vm as any).clicked(event);
|
|
73
|
+
await wrapper.vm.$nextTick();
|
|
74
|
+
|
|
75
|
+
expect(wrapper.emitted().input?.[0][0]).toBe(null);
|
|
76
|
+
})
|
|
77
|
+
});
|