@rancher/shell 0.3.16 → 0.3.18
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/images/wechat-qr-code.jpg +0 -0
- package/assets/translations/en-us.yaml +75 -16
- package/assets/translations/zh-hans.yaml +151 -15
- package/chart/__tests__/S3.test.ts +50 -0
- package/chart/rancher-backup/S3.vue +21 -0
- package/chart/rancher-backup/index.vue +4 -0
- package/components/AsyncButton.vue +1 -1
- package/components/CommunityLinks.vue +1 -0
- package/components/FileDiff.vue +92 -85
- package/components/Inactivity.vue +10 -0
- package/components/LazyImage.vue +2 -2
- package/components/PromptRestore.vue +7 -5
- package/components/ResourceDetail/Masthead.vue +1 -1
- package/components/ResourceDetail/index.vue +8 -14
- package/components/ResourceList/index.vue +1 -1
- package/components/ResourceTable.vue +50 -2
- package/components/YamlEditor.vue +1 -0
- package/components/__tests__/PromptRestore.test.ts +72 -0
- package/components/auth/AzureWarning.vue +1 -1
- package/components/auth/RoleDetailEdit.vue +1 -0
- package/components/fleet/FleetResources.vue +3 -64
- package/components/form/FileImageSelector.vue +9 -0
- package/components/form/FileSelector.vue +2 -1
- package/components/form/MatchExpressions.vue +1 -3
- package/components/form/NameNsDescription.vue +28 -12
- package/components/form/NodeAffinity.vue +2 -2
- package/components/form/PodAffinity.vue +2 -2
- package/components/form/ResourceTabs/index.vue +8 -2
- package/components/form/Select.vue +16 -0
- package/components/form/__tests__/FileImageSelector.test.ts +42 -0
- package/components/form/__tests__/FileSelector.test.ts +76 -0
- package/components/form/__tests__/NodeAffinity.test.ts +38 -0
- package/components/form/__tests__/PodAffinity.test.ts +46 -0
- package/components/formatter/ClusterLink.vue +8 -4
- package/components/formatter/ClusterProvider.vue +3 -1
- package/components/formatter/ImageName.vue +23 -0
- package/components/formatter/PodImages.vue +7 -1
- package/components/formatter/__tests__/ClusterLink.test.ts +101 -0
- package/components/formatter/__tests__/ClusterProvider.test.ts +24 -0
- package/components/nav/Header.vue +2 -2
- package/components/nav/WindowManager/ContainerShell.vue +60 -36
- package/components/nav/WindowManager/__tests__/ContainerShell.test.ts +561 -0
- package/config/__test__/home-links.test.ts +62 -0
- package/config/home-links.js +15 -3
- package/config/labels-annotations.js +7 -2
- package/config/persistentVolume.ts +108 -0
- package/config/product/manager.js +5 -1
- package/config/router.js +0 -4
- package/config/settings.ts +4 -0
- package/config/table-headers.js +6 -5
- package/config/types.js +2 -0
- package/config/uiplugins.js +50 -5
- package/core/plugin-helpers.js +39 -15
- package/core/plugin.ts +9 -0
- package/core/plugins.js +1 -1
- package/core/types-provisioning.ts +253 -0
- package/core/types.ts +21 -3
- package/detail/autoscaling.horizontalpodautoscaler/index.vue +50 -1
- package/detail/fleet.cattle.io.gitrepo.vue +10 -2
- package/detail/node.vue +6 -6
- package/detail/pod.vue +38 -9
- package/detail/provisioning.cattle.io.cluster.vue +46 -7
- package/detail/workload/index.vue +49 -18
- package/edit/__tests__/fleet.cattle.io.gitrepo.test.ts +62 -0
- package/edit/__tests__/ui.cattle.io.navlink.test.ts +110 -0
- package/edit/auth/github.vue +1 -0
- package/edit/autoscaling.horizontalpodautoscaler/hpa-scaling-rule.vue +130 -0
- package/edit/autoscaling.horizontalpodautoscaler/index.vue +79 -0
- package/edit/fleet.cattle.io.clustergroup.vue +14 -3
- package/edit/fleet.cattle.io.gitrepo.vue +18 -1
- package/edit/namespace.vue +9 -1
- package/edit/networking.k8s.io.ingress/RulePath.vue +0 -2
- package/edit/persistentvolume/__tests__/persistentvolume.test.ts +82 -0
- package/edit/persistentvolume/index.vue +2 -1
- package/edit/persistentvolume/plugins/csi.vue +3 -1
- package/edit/persistentvolume/plugins/longhorn.vue +12 -12
- package/edit/provisioning.cattle.io.cluster/AgentConfiguration.vue +1 -30
- package/edit/provisioning.cattle.io.cluster/RegistryConfigs.vue +15 -11
- package/edit/provisioning.cattle.io.cluster/__tests__/rke2.test.ts +79 -1
- package/edit/provisioning.cattle.io.cluster/index.vue +53 -1
- package/edit/provisioning.cattle.io.cluster/rke2.vue +335 -151
- package/edit/storage.k8s.io.storageclass/index.vue +1 -2
- package/edit/ui.cattle.io.navlink.vue +213 -186
- package/initialize/App.js +3 -13
- package/initialize/layouts.ts +26 -0
- package/layouts/default.vue +1 -1
- package/list/group.principal.vue +1 -1
- package/list/provisioning.cattle.io.cluster.vue +8 -1
- package/middleware/authenticated.js +101 -5
- package/mixins/brand.js +39 -3
- package/mixins/child-hook.js +2 -2
- package/mixins/create-edit-view/impl.js +4 -4
- package/models/chart.js +1 -1
- package/models/fleet.cattle.io.cluster.js +33 -4
- package/models/fleet.cattle.io.gitrepo.js +113 -38
- package/models/management.cattle.io.kontainerdriver.js +14 -0
- package/models/persistentvolume.js +2 -111
- package/models/pod.js +30 -0
- package/models/provisioning.cattle.io.cluster.js +9 -1
- package/models/rke.cattle.io.etcdsnapshot.js +10 -7
- package/package.json +2 -2
- package/pages/about.vue +8 -2
- package/pages/auth/login.vue +1 -1
- package/pages/auth/logout.vue +11 -3
- package/pages/c/_cluster/apps/charts/index.vue +5 -2
- package/pages/c/_cluster/apps/charts/install.vue +5 -0
- package/pages/c/_cluster/auth/group.principal/assign-edit.vue +1 -1
- package/pages/c/_cluster/auth/roles/index.vue +1 -1
- package/pages/c/_cluster/explorer/index.vue +2 -11
- package/pages/c/_cluster/manager/cloudCredential/_id.vue +0 -1
- package/pages/c/_cluster/manager/cloudCredential/create.vue +0 -1
- package/pages/c/_cluster/settings/brand.vue +11 -8
- package/pages/c/_cluster/uiplugins/AddExtensionRepos.vue +177 -0
- package/pages/c/_cluster/uiplugins/PluginInfoPanel.vue +19 -3
- package/pages/c/_cluster/uiplugins/RemoveUIPlugins.vue +90 -21
- package/pages/c/_cluster/uiplugins/SetupUIPlugins.vue +107 -37
- package/pages/c/_cluster/uiplugins/index.vue +160 -44
- package/pages/docs/_doc.vue +9 -3
- package/pages/home.vue +6 -6
- package/pages/support/index.vue +10 -4
- package/pkg/auto-import.js +1 -1
- package/plugins/clean-tooltip-directive.js +1 -1
- package/plugins/dashboard-store/__tests__/actions.spec.ts +165 -0
- package/plugins/dashboard-store/__tests__/getters.spec.ts +100 -0
- package/plugins/dashboard-store/__tests__/{mutations.spec.js → mutations.spec.ts} +2 -2
- package/plugins/dashboard-store/actions.js +1 -1
- package/plugins/dashboard-store/resource-class.js +39 -2
- package/plugins/plugin.js +9 -1
- package/plugins/steve/__tests__/getters.spec.ts +93 -0
- package/plugins/steve/getters.js +21 -1
- package/plugins/steve/subscribe.js +1 -3
- package/rancher-components/BadgeState/BadgeState.vue +5 -1
- package/rancher-components/Banner/Banner.test.ts +51 -1
- package/rancher-components/Banner/Banner.vue +134 -53
- package/rancher-components/Card/Card.test.ts +37 -0
- package/rancher-components/Card/Card.vue +24 -7
- package/rancher-components/Form/Checkbox/Checkbox.test.ts +20 -29
- package/rancher-components/Form/Checkbox/Checkbox.vue +45 -20
- package/rancher-components/Form/LabeledInput/LabeledInput.test.ts +2 -8
- package/rancher-components/Form/LabeledInput/LabeledInput.vue +22 -10
- package/rancher-components/Form/Radio/RadioButton.test.ts +31 -0
- package/rancher-components/Form/Radio/RadioButton.vue +30 -13
- package/rancher-components/Form/Radio/RadioGroup.vue +26 -7
- package/rancher-components/Form/TextArea/TextAreaAutoGrow.vue +7 -6
- package/rancher-components/Form/ToggleSwitch/ToggleSwitch.test.ts +25 -38
- package/rancher-components/Form/ToggleSwitch/ToggleSwitch.vue +23 -11
- package/rancher-components/LabeledTooltip/LabeledTooltip.vue +19 -5
- package/rancher-components/StringList/StringList.test.ts +453 -49
- package/rancher-components/StringList/StringList.vue +44 -26
- package/scripts/extension/publish +2 -2
- package/scripts/typegen.sh +11 -2
- package/server/server-middleware.js +4 -12
- package/store/index.js +14 -3
- package/store/prefs.js +0 -3
- package/store/store-types.js +2 -0
- package/store/type-map.js +17 -29
- package/types/api.d.ts +1 -0
- package/types/fleet.d.ts +1 -0
- package/types/shell/index.d.ts +931 -85
- package/types/userPreferences.d.ts +1 -1
- package/utils/__mocks__/socket.js +21 -0
- package/utils/grafana.js +23 -11
- package/utils/kube.js +9 -0
- package/utils/object.js +27 -0
- package/utils/selector.js +2 -1
- package/utils/settings.ts +2 -2
- package/utils/validators/formRules/index.ts +3 -3
- package/vue.config.js +3 -2
- package/components/.DS_Store +0 -0
- package/components/__tests__/.DS_Store +0 -0
- package/creators/pkg/package-lock.json +0 -37
- package/pages/safeMode.vue +0 -17
- package/plugins/steve/urloptions.js +0 -47
- package/yarn-error.log +0 -196
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { shallowMount } from '@vue/test-utils';
|
|
2
|
+
import { RadioButton } from './index';
|
|
3
|
+
import { cleanHtmlDirective } from '@shell/plugins/clean-html-directive';
|
|
4
|
+
|
|
5
|
+
describe('radioButton.vue', () => {
|
|
6
|
+
it('renders label slot contents', () => {
|
|
7
|
+
const wrapper = shallowMount(RadioButton, { slots: { label: 'Test Label' } });
|
|
8
|
+
|
|
9
|
+
expect(wrapper.find('.radio-label').text()).toBe('Test Label');
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('renders label prop contents', () => {
|
|
13
|
+
const wrapper = shallowMount(
|
|
14
|
+
RadioButton,
|
|
15
|
+
{
|
|
16
|
+
directives: { cleanHtmlDirective },
|
|
17
|
+
propsData: { label: 'Test Label' }
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
expect(wrapper.find('.radio-label').text()).toBe('Test Label');
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('renders slot contents when both slot and label prop are provided', () => {
|
|
24
|
+
const wrapper = shallowMount(RadioButton, {
|
|
25
|
+
slots: { label: 'Test Label - Slot' },
|
|
26
|
+
propsData: { label: 'Test Label - Props' },
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
expect(wrapper.find('.radio-label').text()).toBe('Test Label - Slot');
|
|
30
|
+
});
|
|
31
|
+
});
|
|
@@ -12,25 +12,25 @@ export default Vue.extend({
|
|
|
12
12
|
default: ''
|
|
13
13
|
},
|
|
14
14
|
|
|
15
|
-
/**
|
|
15
|
+
/**
|
|
16
16
|
* The value for this option.
|
|
17
|
-
*/
|
|
17
|
+
*/
|
|
18
18
|
val: {
|
|
19
19
|
required: true,
|
|
20
|
-
validator:
|
|
20
|
+
validator: () => true
|
|
21
21
|
},
|
|
22
22
|
|
|
23
|
-
/**
|
|
23
|
+
/**
|
|
24
24
|
* The selected value.
|
|
25
|
-
*/
|
|
25
|
+
*/
|
|
26
26
|
value: {
|
|
27
27
|
required: true,
|
|
28
|
-
validator:
|
|
28
|
+
validator: () => true
|
|
29
29
|
},
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
* The label shown next to the radio.
|
|
33
|
-
*/
|
|
33
|
+
*/
|
|
34
34
|
label: {
|
|
35
35
|
type: String,
|
|
36
36
|
default: ''
|
|
@@ -96,6 +96,10 @@ export default Vue.extend({
|
|
|
96
96
|
hasDescriptionSlot(): boolean {
|
|
97
97
|
return !!this.$slots.description;
|
|
98
98
|
},
|
|
99
|
+
|
|
100
|
+
hasLabelSlot(): boolean {
|
|
101
|
+
return !!this.$slots.label || !!this.$scopedSlots.label;
|
|
102
|
+
}
|
|
99
103
|
},
|
|
100
104
|
|
|
101
105
|
watch: {
|
|
@@ -138,7 +142,7 @@ export default Vue.extend({
|
|
|
138
142
|
type="radio"
|
|
139
143
|
:tabindex="-1"
|
|
140
144
|
@click.stop.prevent
|
|
141
|
-
|
|
145
|
+
>
|
|
142
146
|
<span
|
|
143
147
|
ref="custom"
|
|
144
148
|
:class="[ isDisabled ? 'text-muted' : '', 'radio-custom']"
|
|
@@ -149,15 +153,28 @@ export default Vue.extend({
|
|
|
149
153
|
/>
|
|
150
154
|
<div class="labeling">
|
|
151
155
|
<label
|
|
152
|
-
v-if="label"
|
|
153
156
|
:class="[ muteLabel ? 'text-muted' : '', 'radio-label', 'm-0']"
|
|
154
157
|
:for="name"
|
|
155
|
-
v-html="label"
|
|
156
158
|
>
|
|
157
|
-
<slot
|
|
159
|
+
<slot
|
|
160
|
+
v-if="hasLabelSlot"
|
|
161
|
+
name="label"
|
|
162
|
+
>
|
|
163
|
+
<!-- slot content -->
|
|
164
|
+
</slot>
|
|
165
|
+
<span
|
|
166
|
+
v-else-if="label"
|
|
167
|
+
v-clean-html="label"
|
|
168
|
+
/>
|
|
158
169
|
</label>
|
|
159
|
-
<div
|
|
160
|
-
|
|
170
|
+
<div
|
|
171
|
+
v-if="descriptionKey || description"
|
|
172
|
+
class="radio-button-outer-container-description"
|
|
173
|
+
>
|
|
174
|
+
<t
|
|
175
|
+
v-if="descriptionKey"
|
|
176
|
+
:k="descriptionKey"
|
|
177
|
+
/>
|
|
161
178
|
<template v-else-if="description">
|
|
162
179
|
{{ description }}
|
|
163
180
|
</template>
|
|
@@ -28,7 +28,7 @@ export default Vue.extend({
|
|
|
28
28
|
},
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
|
-
* If options are just values, then labels can be a corresponding display
|
|
31
|
+
* If options are just values, then labels can be a corresponding display
|
|
32
32
|
* value.
|
|
33
33
|
*/
|
|
34
34
|
labels: {
|
|
@@ -152,7 +152,7 @@ export default Vue.extend({
|
|
|
152
152
|
*/
|
|
153
153
|
clickNext(direction: number): void {
|
|
154
154
|
const opts = this.normalizedOptions;
|
|
155
|
-
const selected = opts.find(x => x.value === this.value);
|
|
155
|
+
const selected = opts.find((x) => x.value === this.value);
|
|
156
156
|
let newIndex = (selected ? opts.indexOf(selected) : -1) + direction;
|
|
157
157
|
|
|
158
158
|
if (newIndex >= opts.length) {
|
|
@@ -169,15 +169,29 @@ export default Vue.extend({
|
|
|
169
169
|
|
|
170
170
|
<template>
|
|
171
171
|
<div>
|
|
172
|
-
<div
|
|
172
|
+
<div
|
|
173
|
+
v-if="label || labelKey || tooltip || tooltipKey || $slots.label"
|
|
174
|
+
class="radio-group label"
|
|
175
|
+
>
|
|
173
176
|
<slot name="label">
|
|
174
177
|
<h3>
|
|
175
|
-
<t
|
|
178
|
+
<t
|
|
179
|
+
v-if="labelKey"
|
|
180
|
+
:k="labelKey"
|
|
181
|
+
/>
|
|
176
182
|
<template v-else-if="label">
|
|
177
183
|
{{ label }}
|
|
178
184
|
</template>
|
|
179
|
-
<i
|
|
180
|
-
|
|
185
|
+
<i
|
|
186
|
+
v-if="tooltipKey"
|
|
187
|
+
v-clean-tooltip="t(tooltipKey)"
|
|
188
|
+
class="icon icon-info icon-lg"
|
|
189
|
+
/>
|
|
190
|
+
<i
|
|
191
|
+
v-else-if="tooltip"
|
|
192
|
+
v-clean-tooltip="tooltip"
|
|
193
|
+
class="icon icon-info icon-lg"
|
|
194
|
+
/>
|
|
181
195
|
</h3>
|
|
182
196
|
</slot>
|
|
183
197
|
</div>
|
|
@@ -192,7 +206,12 @@ export default Vue.extend({
|
|
|
192
206
|
v-for="(option, i) in normalizedOptions"
|
|
193
207
|
:key="name+'-'+i"
|
|
194
208
|
>
|
|
195
|
-
<slot
|
|
209
|
+
<slot
|
|
210
|
+
:listeners="$listeners"
|
|
211
|
+
:option="option"
|
|
212
|
+
:is-disabled="isDisabled"
|
|
213
|
+
:name="i"
|
|
214
|
+
>
|
|
196
215
|
<RadioButton
|
|
197
216
|
:key="name+'-'+i"
|
|
198
217
|
:name="name"
|
|
@@ -24,14 +24,14 @@ export default Vue.extend({
|
|
|
24
24
|
},
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
|
-
* Sets the Minimum height for Text Area. Prevents the height from becoming
|
|
27
|
+
* Sets the Minimum height for Text Area. Prevents the height from becoming
|
|
28
28
|
* smaller than the value specified in minHeight.
|
|
29
29
|
*/
|
|
30
30
|
minHeight: {
|
|
31
31
|
type: Number,
|
|
32
32
|
default: 25
|
|
33
33
|
},
|
|
34
|
-
|
|
34
|
+
|
|
35
35
|
/**
|
|
36
36
|
* Sets the maximum height for Text Area. Prevents the height from becoming
|
|
37
37
|
* larger than the value specified in maxHeight.
|
|
@@ -50,7 +50,7 @@ export default Vue.extend({
|
|
|
50
50
|
},
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
|
-
* Specifies whether Text Area is subject to spell checking by the
|
|
53
|
+
* Specifies whether Text Area is subject to spell checking by the
|
|
54
54
|
* underlying browser/OS.
|
|
55
55
|
*/
|
|
56
56
|
spellcheck: {
|
|
@@ -83,7 +83,7 @@ export default Vue.extend({
|
|
|
83
83
|
},
|
|
84
84
|
|
|
85
85
|
/**
|
|
86
|
-
* Sets the height to one-line for SSR pageload so that it's already right
|
|
86
|
+
* Sets the height to one-line for SSR pageload so that it's already right
|
|
87
87
|
* (unless the input is long)
|
|
88
88
|
*/
|
|
89
89
|
style(): string {
|
|
@@ -112,7 +112,7 @@ export default Vue.extend({
|
|
|
112
112
|
},
|
|
113
113
|
|
|
114
114
|
methods: {
|
|
115
|
-
/**
|
|
115
|
+
/**
|
|
116
116
|
* Emits the input event and resizes the Text Area.
|
|
117
117
|
*/
|
|
118
118
|
onInput(val: string): void {
|
|
@@ -128,7 +128,7 @@ export default Vue.extend({
|
|
|
128
128
|
},
|
|
129
129
|
|
|
130
130
|
/**
|
|
131
|
-
* Sets the overflowY and height of the Text Area based on the content
|
|
131
|
+
* Sets the overflowY and height of the Text Area based on the content
|
|
132
132
|
* entered (calculated via scroll height).
|
|
133
133
|
*/
|
|
134
134
|
autoSize(): void {
|
|
@@ -155,6 +155,7 @@ export default Vue.extend({
|
|
|
155
155
|
<template>
|
|
156
156
|
<textarea
|
|
157
157
|
ref="ta"
|
|
158
|
+
data-testid="text-area-auto-grow"
|
|
158
159
|
:disabled="isDisabled"
|
|
159
160
|
:style="style"
|
|
160
161
|
:placeholder="placeholder"
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { shallowMount } from '@vue/test-utils';
|
|
1
|
+
import { shallowMount, Wrapper } from '@vue/test-utils';
|
|
2
2
|
import { ToggleSwitch } from './index';
|
|
3
3
|
|
|
4
|
-
describe('
|
|
4
|
+
describe('toggleSwitch.vue', () => {
|
|
5
5
|
it('renders falsy by default', () => {
|
|
6
6
|
const wrapper = shallowMount(ToggleSwitch);
|
|
7
7
|
|
|
8
|
-
const toggleInput = wrapper.find('input[type="checkbox"]').element as HTMLInputElement
|
|
8
|
+
const toggleInput = wrapper.find('input[type="checkbox"]').element as HTMLInputElement;
|
|
9
9
|
|
|
10
10
|
expect(toggleInput.checked).toBeFalsy();
|
|
11
11
|
});
|
|
@@ -13,71 +13,58 @@ describe('ToggleSwitch.vue', () => {
|
|
|
13
13
|
it('renders a true value', () => {
|
|
14
14
|
const wrapper = shallowMount(
|
|
15
15
|
ToggleSwitch,
|
|
16
|
-
{
|
|
17
|
-
propsData: {
|
|
18
|
-
value: true
|
|
19
|
-
}
|
|
20
|
-
});
|
|
16
|
+
{ propsData: { value: true } });
|
|
21
17
|
|
|
22
|
-
const toggleInput = wrapper.find('input[type="checkbox"]').element as HTMLInputElement
|
|
18
|
+
const toggleInput = wrapper.find('input[type="checkbox"]').element as HTMLInputElement;
|
|
23
19
|
|
|
24
20
|
expect(toggleInput.checked).toBe(true);
|
|
25
21
|
});
|
|
26
22
|
|
|
27
|
-
it('updates from falsy to truthy when props change', async
|
|
23
|
+
it('updates from falsy to truthy when props change', async() => {
|
|
28
24
|
const wrapper = shallowMount(ToggleSwitch);
|
|
29
|
-
|
|
30
|
-
const toggleInput = wrapper.find('input[type="checkbox"]').element as HTMLInputElement
|
|
25
|
+
|
|
26
|
+
const toggleInput = wrapper.find('input[type="checkbox"]').element as HTMLInputElement;
|
|
31
27
|
|
|
32
28
|
expect(toggleInput.checked).toBe(false);
|
|
33
29
|
|
|
34
30
|
await wrapper.setProps({ value: true });
|
|
35
|
-
|
|
31
|
+
|
|
36
32
|
expect(toggleInput.checked).toBe(true);
|
|
37
33
|
});
|
|
38
34
|
|
|
39
|
-
it('emits an input event with a true value', async
|
|
40
|
-
const wrapper = shallowMount(ToggleSwitch);
|
|
35
|
+
it('emits an input event with a true value', async() => {
|
|
36
|
+
const wrapper: Wrapper<InstanceType<typeof ToggleSwitch>> = shallowMount(ToggleSwitch);
|
|
41
37
|
|
|
42
|
-
|
|
38
|
+
wrapper.vm.toggle(true);
|
|
43
39
|
|
|
44
40
|
await wrapper.vm.$nextTick();
|
|
45
41
|
|
|
46
42
|
expect(wrapper.emitted().input?.length).toBe(1);
|
|
47
43
|
expect(wrapper.emitted().input?.[0][0]).toBe(true);
|
|
48
|
-
|
|
49
44
|
});
|
|
50
45
|
|
|
51
|
-
it('emits an input event with a false value', async
|
|
52
|
-
const wrapper = shallowMount(
|
|
46
|
+
it('emits an input event with a false value', async() => {
|
|
47
|
+
const wrapper: Wrapper<InstanceType<typeof ToggleSwitch>> = shallowMount(
|
|
53
48
|
ToggleSwitch,
|
|
54
|
-
{
|
|
55
|
-
propsData: {
|
|
56
|
-
value: true
|
|
57
|
-
}
|
|
58
|
-
}
|
|
49
|
+
{ propsData: { value: true } }
|
|
59
50
|
);
|
|
60
51
|
|
|
61
|
-
|
|
52
|
+
wrapper.vm.toggle(false);
|
|
62
53
|
|
|
63
54
|
await wrapper.vm.$nextTick();
|
|
64
55
|
|
|
65
56
|
expect(wrapper.emitted().input?.length).toBe(1);
|
|
66
57
|
expect(wrapper.emitted().input?.[0][0]).toBe(false);
|
|
67
|
-
})
|
|
58
|
+
});
|
|
68
59
|
|
|
69
|
-
it('emits an input event with a custom onValue', async
|
|
60
|
+
it('emits an input event with a custom onValue', async() => {
|
|
70
61
|
const onValue = 'THE TRUTH';
|
|
71
62
|
|
|
72
|
-
const wrapper = shallowMount(
|
|
63
|
+
const wrapper: Wrapper<InstanceType<typeof ToggleSwitch>> = shallowMount(
|
|
73
64
|
ToggleSwitch,
|
|
74
|
-
{
|
|
75
|
-
propsData: {
|
|
76
|
-
onValue,
|
|
77
|
-
}
|
|
78
|
-
});
|
|
65
|
+
{ propsData: { onValue } });
|
|
79
66
|
|
|
80
|
-
|
|
67
|
+
wrapper.vm.toggle(true);
|
|
81
68
|
|
|
82
69
|
await wrapper.vm.$nextTick();
|
|
83
70
|
|
|
@@ -85,10 +72,10 @@ describe('ToggleSwitch.vue', () => {
|
|
|
85
72
|
expect(wrapper.emitted().input?.[0][0]).toBe(onValue);
|
|
86
73
|
});
|
|
87
74
|
|
|
88
|
-
it('emits an input event with a custom offValue', async
|
|
75
|
+
it('emits an input event with a custom offValue', async() => {
|
|
89
76
|
const offValue = 'NOT THE TRUTH';
|
|
90
77
|
|
|
91
|
-
const wrapper = shallowMount(
|
|
78
|
+
const wrapper: Wrapper<InstanceType<typeof ToggleSwitch>> = shallowMount(
|
|
92
79
|
ToggleSwitch,
|
|
93
80
|
{
|
|
94
81
|
propsData: {
|
|
@@ -97,11 +84,11 @@ describe('ToggleSwitch.vue', () => {
|
|
|
97
84
|
}
|
|
98
85
|
});
|
|
99
86
|
|
|
100
|
-
|
|
87
|
+
wrapper.vm.toggle(false);
|
|
101
88
|
|
|
102
89
|
await wrapper.vm.$nextTick();
|
|
103
90
|
|
|
104
91
|
expect(wrapper.emitted().input?.length).toBe(1);
|
|
105
92
|
expect(wrapper.emitted().input?.[0][0]).toBe(offValue);
|
|
106
|
-
})
|
|
93
|
+
});
|
|
107
94
|
});
|
|
@@ -31,13 +31,6 @@ export default Vue.extend({
|
|
|
31
31
|
return { state: false as boolean | string | number };
|
|
32
32
|
},
|
|
33
33
|
|
|
34
|
-
methods: {
|
|
35
|
-
toggle(neu: boolean | string | number) {
|
|
36
|
-
this.state = neu === null ? !this.state : neu;
|
|
37
|
-
this.$emit('input', this.state ? this.onValue : this.offValue);
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
|
|
41
34
|
watch: {
|
|
42
35
|
value: {
|
|
43
36
|
handler() {
|
|
@@ -45,18 +38,37 @@ export default Vue.extend({
|
|
|
45
38
|
},
|
|
46
39
|
immediate: true
|
|
47
40
|
}
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
methods: {
|
|
44
|
+
toggle(neu: boolean | string | number) {
|
|
45
|
+
this.state = neu === null ? !this.state : neu;
|
|
46
|
+
this.$emit('input', this.state ? this.onValue : this.offValue);
|
|
47
|
+
}
|
|
48
48
|
}
|
|
49
49
|
});
|
|
50
50
|
</script>
|
|
51
51
|
|
|
52
52
|
<template>
|
|
53
53
|
<span class="toggle-container">
|
|
54
|
-
<span
|
|
54
|
+
<span
|
|
55
|
+
class="label no-select hand"
|
|
56
|
+
:class="{ active: !state}"
|
|
57
|
+
@click="toggle(false)"
|
|
58
|
+
>{{ offLabel }}</span>
|
|
55
59
|
<label class="switch hand">
|
|
56
|
-
<input
|
|
57
|
-
|
|
60
|
+
<input
|
|
61
|
+
type="checkbox"
|
|
62
|
+
:checked="state"
|
|
63
|
+
@input="toggle(null)"
|
|
64
|
+
>
|
|
65
|
+
<span class="slider round" />
|
|
58
66
|
</label>
|
|
59
|
-
<span
|
|
67
|
+
<span
|
|
68
|
+
class="label no-select hand"
|
|
69
|
+
:class="{ active: state}"
|
|
70
|
+
@click="toggle(true)"
|
|
71
|
+
>{{ onLabel }}</span>
|
|
60
72
|
</span>
|
|
61
73
|
</template>
|
|
62
74
|
|
|
@@ -37,13 +37,28 @@ export default Vue.extend({
|
|
|
37
37
|
</script>
|
|
38
38
|
|
|
39
39
|
<template>
|
|
40
|
-
<div
|
|
40
|
+
<div
|
|
41
|
+
ref="container"
|
|
42
|
+
class="labeled-tooltip"
|
|
43
|
+
:class="{[status]: true, hoverable: hover}"
|
|
44
|
+
>
|
|
41
45
|
<template v-if="hover">
|
|
42
|
-
<i
|
|
46
|
+
<i
|
|
47
|
+
v-clean-tooltip="value.content ? { ...{content: value.content, classes: [`tooltip-${status}`]}, ...value } : value"
|
|
48
|
+
:class="{'hover':!value, [iconClass]: true}"
|
|
49
|
+
class="icon status-icon"
|
|
50
|
+
/>
|
|
43
51
|
</template>
|
|
44
52
|
<template v-else>
|
|
45
|
-
<i
|
|
46
|
-
|
|
53
|
+
<i
|
|
54
|
+
:class="{'hover':!value}"
|
|
55
|
+
class="icon status-icon"
|
|
56
|
+
/>
|
|
57
|
+
<div
|
|
58
|
+
v-if="value"
|
|
59
|
+
class="tooltip"
|
|
60
|
+
x-placement="bottom"
|
|
61
|
+
>
|
|
47
62
|
<div class="tooltip-arrow" />
|
|
48
63
|
<div class="tooltip-inner">
|
|
49
64
|
{{ value }}
|
|
@@ -69,7 +84,6 @@ export default Vue.extend({
|
|
|
69
84
|
position: absolute;
|
|
70
85
|
right: 30px;
|
|
71
86
|
top: $input-padding-lg;
|
|
72
|
-
font-size: 20px;
|
|
73
87
|
z-index: z-index(hoverOverContent);
|
|
74
88
|
}
|
|
75
89
|
|