@rancher/shell 0.3.23 → 0.3.24
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/styles/base/_variables.scss +1 -0
- package/assets/styles/themes/_dark.scss +1 -0
- package/assets/styles/themes/_light.scss +6 -5
- package/assets/translations/en-us.yaml +15 -10
- package/assets/translations/zh-hans.yaml +1 -1
- package/components/ClusterProviderIconMenu.vue +161 -0
- package/components/Loading.vue +1 -1
- package/components/SideNav.vue +1 -1
- package/components/form/SelectOrCreateAuthSecret.vue +7 -0
- package/components/nav/Group.vue +54 -24
- package/components/nav/Header.vue +1 -1
- package/components/nav/TopLevelMenu.vue +469 -294
- package/components/nav/Type.vue +31 -5
- package/creators/pkg/init +2 -2
- package/edit/fleet.cattle.io.gitrepo.vue +43 -15
- package/edit/logging.banzaicloud.io.output/index.vue +7 -0
- package/edit/provisioning.cattle.io.cluster/CustomCommand.vue +3 -8
- package/edit/provisioning.cattle.io.cluster/rke2.vue +108 -33
- package/edit/workload/storage/ContainerMountPaths.vue +7 -5
- package/initialize/App.js +2 -0
- package/initialize/client.js +63 -51
- package/initialize/index.js +2 -0
- package/layouts/default.vue +8 -0
- package/machine-config/amazonec2.vue +1 -0
- package/mixins/fetch.client.js +3 -3
- package/package.json +1 -1
- package/pages/__tests__/prefs.test.ts +1 -1
- package/pages/c/_cluster/explorer/ConfigBadge.vue +1 -0
- package/pages/prefs.vue +3 -13
- package/plugins/dashboard-store/resource-class.js +1 -1
- package/public/index.html +4 -2
- 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 +30 -10
- package/rancher-components/Form/Radio/RadioButton.test.ts +35 -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 +92 -58
- package/scripts/extension/parse-tag-name +0 -0
- package/store/prefs.js +3 -4
- package/store/type-map.js +2 -16
- package/types/shell/index.d.ts +13 -10
- package/utils/__tests__/sort.test.ts +61 -0
- package/utils/string.js +12 -0
- package/vue.config.js +1 -4
- package/yarn-error.log +200 -0
package/layouts/default.vue
CHANGED
|
@@ -318,6 +318,14 @@ export default {
|
|
|
318
318
|
overflow-y: auto;
|
|
319
319
|
min-height: 0px;
|
|
320
320
|
|
|
321
|
+
&:has(.side-menu) {
|
|
322
|
+
padding-left: $app-bar-collapsed-width;
|
|
323
|
+
|
|
324
|
+
.overlay-content-mode {
|
|
325
|
+
left: calc(var(--nav-width) + $app-bar-collapsed-width);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
321
329
|
&.pin-right {
|
|
322
330
|
grid-template-areas:
|
|
323
331
|
"header header header"
|
package/mixins/fetch.client.js
CHANGED
|
@@ -75,9 +75,9 @@ async function $_fetch() { // eslint-disable-line camelcase
|
|
|
75
75
|
try {
|
|
76
76
|
await this.$options.fetch.call(this);
|
|
77
77
|
} catch (err) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
// In most cases we don't handle errors at all in `fetch`es. Lets always log to help in production
|
|
79
|
+
console.error('Error in fetch():', err); // eslint-disable-line no-console
|
|
80
|
+
|
|
81
81
|
error = normalizeError(err);
|
|
82
82
|
}
|
|
83
83
|
|
package/package.json
CHANGED
package/pages/prefs.vue
CHANGED
|
@@ -8,9 +8,11 @@ import ButtonGroup from '@shell/components/ButtonGroup';
|
|
|
8
8
|
import { Checkbox } from '@components/Form/Checkbox';
|
|
9
9
|
import LandingPagePreference from '@shell/components/LandingPagePreference';
|
|
10
10
|
import {
|
|
11
|
-
mapPref, THEME, KEYMAP, DATE_FORMAT, TIME_FORMAT, ROWS_PER_PAGE, HIDE_DESC, SHOW_PRE_RELEASE,
|
|
11
|
+
mapPref, THEME, KEYMAP, DATE_FORMAT, TIME_FORMAT, ROWS_PER_PAGE, HIDE_DESC, SHOW_PRE_RELEASE,
|
|
12
12
|
VIEW_IN_API, ALL_NAMESPACES, THEME_SHORTCUT, PLUGIN_DEVELOPER, SCALE_POOL_PROMPT
|
|
13
|
+
, MENU_MAX_CLUSTERS
|
|
13
14
|
} from '@shell/store/prefs';
|
|
15
|
+
|
|
14
16
|
import LabeledSelect from '@shell/components/form/LabeledSelect';
|
|
15
17
|
import { addObject } from '@shell/utils/array';
|
|
16
18
|
import LocaleSelector from '@shell/components/LocaleSelector';
|
|
@@ -34,7 +36,6 @@ export default {
|
|
|
34
36
|
perPage: mapPref(ROWS_PER_PAGE),
|
|
35
37
|
hideDesc: mapPref(HIDE_DESC),
|
|
36
38
|
showPreRelease: mapPref(SHOW_PRE_RELEASE),
|
|
37
|
-
menuMaxClusters: mapPref(MENU_MAX_CLUSTERS),
|
|
38
39
|
pluginDeveloper: mapPref(PLUGIN_DEVELOPER),
|
|
39
40
|
scalingDownPrompt: mapPref(SCALE_POOL_PROMPT),
|
|
40
41
|
|
|
@@ -254,17 +255,6 @@ export default {
|
|
|
254
255
|
placeholder="Select a row count"
|
|
255
256
|
/>
|
|
256
257
|
</div>
|
|
257
|
-
<div class="col span-4">
|
|
258
|
-
<LabeledSelect
|
|
259
|
-
v-model.number="menuMaxClusters"
|
|
260
|
-
data-testid="prefs__displaySetting__menuMaxClusters"
|
|
261
|
-
:label="t('prefs.clusterToShow.label')"
|
|
262
|
-
:options="menuClusterOptions"
|
|
263
|
-
option-key="value"
|
|
264
|
-
option-label="label"
|
|
265
|
-
placeholder="Select a row count"
|
|
266
|
-
/>
|
|
267
|
-
</div>
|
|
268
258
|
</div>
|
|
269
259
|
</div>
|
|
270
260
|
<!-- Confirmation setting -->
|
package/public/index.html
CHANGED
|
@@ -13,8 +13,10 @@
|
|
|
13
13
|
<div id="app">
|
|
14
14
|
<script>
|
|
15
15
|
(() => {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
// Has the user chosen to auto detect the theme.... or if they haven't chosen anything.. --> check the auto-detected theme via R_PCS
|
|
17
|
+
// Otherwise check if they've specifically selected a theme --> R_THEME
|
|
18
|
+
const isDark = document.cookie.includes('R_THEME=auto') || !document.cookie.includes('R_THEME') ?
|
|
19
|
+
// User selected automatic theme, so use PCS (set when ui previously loaded and is either os theme or time of day based)
|
|
18
20
|
document.cookie.includes('R_PCS=dark') :
|
|
19
21
|
// Otherwise user selected light/dark theme directly
|
|
20
22
|
document.cookie.includes('R_THEME=dark');
|
|
@@ -60,7 +60,11 @@ export default Vue.extend({
|
|
|
60
60
|
|
|
61
61
|
<template>
|
|
62
62
|
<span :class="{'badge-state': true, [bg]: true}">
|
|
63
|
-
<i
|
|
63
|
+
<i
|
|
64
|
+
v-if="icon"
|
|
65
|
+
class="icon"
|
|
66
|
+
:class="{[icon]: true, 'mr-5': !!msg}"
|
|
67
|
+
/>{{ msg }}
|
|
64
68
|
</span>
|
|
65
69
|
</template>
|
|
66
70
|
|
|
@@ -1,13 +1,63 @@
|
|
|
1
1
|
import { mount } from '@vue/test-utils';
|
|
2
2
|
import { Banner } from './index';
|
|
3
|
+
import { cleanHtmlDirective } from '@shell/plugins/clean-html-directive';
|
|
3
4
|
|
|
4
5
|
describe('component: Banner', () => {
|
|
5
6
|
it('should display text based on label', () => {
|
|
6
7
|
const label = 'test';
|
|
7
|
-
const wrapper = mount(
|
|
8
|
+
const wrapper = mount(
|
|
9
|
+
Banner,
|
|
10
|
+
{
|
|
11
|
+
directives: { cleanHtmlDirective },
|
|
12
|
+
propsData: { label }
|
|
13
|
+
});
|
|
8
14
|
|
|
9
15
|
const element = wrapper.find('span').element;
|
|
10
16
|
|
|
11
17
|
expect(element.textContent).toBe(label);
|
|
12
18
|
});
|
|
19
|
+
|
|
20
|
+
it('should display an icon', () => {
|
|
21
|
+
const icon = 'my-icon';
|
|
22
|
+
const wrapper = mount(Banner, { propsData: { icon } });
|
|
23
|
+
|
|
24
|
+
const element = wrapper.find(`.${ icon }`).element;
|
|
25
|
+
|
|
26
|
+
expect(element.classList).toContain(icon);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('should not display an icon', () => {
|
|
30
|
+
const wrapper = mount(Banner);
|
|
31
|
+
|
|
32
|
+
const element = wrapper.find(`[data-testid="banner-icon"]`).element;
|
|
33
|
+
|
|
34
|
+
expect(element).not.toBeDefined();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('should emit close event', () => {
|
|
38
|
+
const wrapper = mount(Banner, { propsData: { closable: true } });
|
|
39
|
+
const element = wrapper.find(`[data-testid="banner-close"]`).element;
|
|
40
|
+
|
|
41
|
+
element.click();
|
|
42
|
+
|
|
43
|
+
expect(wrapper.emitted('close')).toHaveLength(1);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('should add the right color', () => {
|
|
47
|
+
const color = 'red';
|
|
48
|
+
const wrapper = mount(Banner, { propsData: { color } });
|
|
49
|
+
|
|
50
|
+
const element = wrapper.element;
|
|
51
|
+
|
|
52
|
+
expect(element.classList).toContain(color);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('should stack the banner messages', () => {
|
|
56
|
+
const stacked = true;
|
|
57
|
+
const wrapper = mount(Banner, { propsData: { stacked } });
|
|
58
|
+
|
|
59
|
+
const element = wrapper.find(`[data-testid="banner-content"]`).element;
|
|
60
|
+
|
|
61
|
+
expect(element.classList).toContain('stacked');
|
|
62
|
+
});
|
|
13
63
|
});
|
|
@@ -27,6 +27,13 @@ export default Vue.extend({
|
|
|
27
27
|
type: String,
|
|
28
28
|
default: null
|
|
29
29
|
},
|
|
30
|
+
/**
|
|
31
|
+
* Add icon for the banner
|
|
32
|
+
*/
|
|
33
|
+
icon: {
|
|
34
|
+
type: String,
|
|
35
|
+
default: null
|
|
36
|
+
},
|
|
30
37
|
/**
|
|
31
38
|
* Toggles the banner's close button.
|
|
32
39
|
*/
|
|
@@ -58,31 +65,137 @@ export default Vue.extend({
|
|
|
58
65
|
class="banner"
|
|
59
66
|
:class="{
|
|
60
67
|
[color]: true,
|
|
61
|
-
closable,
|
|
62
|
-
stacked
|
|
63
68
|
}"
|
|
64
69
|
>
|
|
65
|
-
<
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
<div
|
|
71
|
+
v-if="icon"
|
|
72
|
+
class="banner__icon"
|
|
73
|
+
data-testid="banner-icon"
|
|
74
|
+
>
|
|
75
|
+
<i
|
|
76
|
+
class="icon icon-2x"
|
|
77
|
+
:class="icon"
|
|
78
|
+
/>
|
|
79
|
+
</div>
|
|
80
|
+
<div
|
|
81
|
+
class="banner__content"
|
|
82
|
+
data-testid="banner-content"
|
|
83
|
+
:class="{
|
|
84
|
+
closable,
|
|
85
|
+
stacked,
|
|
86
|
+
icon
|
|
87
|
+
}"
|
|
88
|
+
>
|
|
89
|
+
<slot>
|
|
90
|
+
<t
|
|
91
|
+
v-if="labelKey"
|
|
92
|
+
:k="labelKey"
|
|
93
|
+
:raw="true"
|
|
94
|
+
/>
|
|
95
|
+
<span v-else-if="messageLabel">{{ messageLabel }}</span>
|
|
96
|
+
<span
|
|
97
|
+
v-else
|
|
98
|
+
v-clean-html="nlToBr(label)"
|
|
99
|
+
/>
|
|
100
|
+
</slot>
|
|
101
|
+
<div
|
|
102
|
+
v-if="closable"
|
|
103
|
+
class="banner__content__closer"
|
|
104
|
+
@click="$emit('close')"
|
|
105
|
+
>
|
|
106
|
+
<i
|
|
107
|
+
data-testid="banner-close"
|
|
108
|
+
class="icon icon-close closer-icon"
|
|
109
|
+
/>
|
|
110
|
+
</div>
|
|
72
111
|
</div>
|
|
73
112
|
</div>
|
|
74
113
|
</template>
|
|
75
114
|
|
|
76
115
|
<style lang="scss" scoped>
|
|
77
|
-
|
|
116
|
+
$left-border-size: 4px;
|
|
117
|
+
$icon-size: 24px;
|
|
118
|
+
|
|
119
|
+
.banner {
|
|
120
|
+
display: flex;
|
|
121
|
+
margin: 15px 0;
|
|
122
|
+
position: relative;
|
|
123
|
+
width: 100%;
|
|
124
|
+
color: var(--body-text);
|
|
125
|
+
|
|
126
|
+
&__icon {
|
|
127
|
+
width: $icon-size * 2;
|
|
128
|
+
flex-grow: 1;
|
|
129
|
+
display: flex;
|
|
130
|
+
justify-content: center;
|
|
131
|
+
align-items: center;
|
|
132
|
+
box-sizing: content-box;
|
|
133
|
+
|
|
134
|
+
.primary & {
|
|
135
|
+
background: var(--primary);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.secondary & {
|
|
139
|
+
background: var(--default);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.success & {
|
|
143
|
+
background: var(--success);
|
|
144
|
+
}
|
|
78
145
|
|
|
79
|
-
|
|
146
|
+
.info & {
|
|
147
|
+
background: var(--info);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.warning & {
|
|
151
|
+
background: var(--warning);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.error & {
|
|
155
|
+
background: var(--error);
|
|
156
|
+
color: var(--primary-text);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
&__content {
|
|
80
161
|
padding: 10px;
|
|
81
|
-
margin: 15px 0;
|
|
82
|
-
width: 100%;
|
|
83
162
|
transition: all 0.2s ease;
|
|
84
|
-
position: relative;
|
|
85
163
|
line-height: 20px;
|
|
164
|
+
width: 100%;
|
|
165
|
+
border-left: solid $left-border-size transparent;
|
|
166
|
+
display: flex;
|
|
167
|
+
gap: 3px;
|
|
168
|
+
|
|
169
|
+
.primary & {
|
|
170
|
+
background: var(--primary);
|
|
171
|
+
border-color: var(--primary);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.secondary & {
|
|
175
|
+
background: var(--default-banner-bg);
|
|
176
|
+
border-color: var(--default);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.success & {
|
|
180
|
+
background: var(--success-banner-bg);
|
|
181
|
+
border-color: var(--success);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.info & {
|
|
185
|
+
background: var(--info-banner-bg);
|
|
186
|
+
border-color: var(--info);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.warning & {
|
|
190
|
+
background: var(--warning-banner-bg);
|
|
191
|
+
border-color: var(--warning);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.error & {
|
|
195
|
+
background: var(--error-banner-bg);
|
|
196
|
+
border-color: var(--error);
|
|
197
|
+
color: var(--error);
|
|
198
|
+
}
|
|
86
199
|
|
|
87
200
|
&.stacked {
|
|
88
201
|
padding: 0 10px;
|
|
@@ -97,10 +210,10 @@ export default Vue.extend({
|
|
|
97
210
|
}
|
|
98
211
|
|
|
99
212
|
&.closable {
|
|
100
|
-
padding-right:
|
|
213
|
+
padding-right: $icon-size * 2;
|
|
101
214
|
}
|
|
102
215
|
|
|
103
|
-
|
|
216
|
+
&__closer {
|
|
104
217
|
display: flex;
|
|
105
218
|
align-items: center;
|
|
106
219
|
|
|
@@ -109,12 +222,11 @@ export default Vue.extend({
|
|
|
109
222
|
top: 0;
|
|
110
223
|
right: 0;
|
|
111
224
|
bottom: 0;
|
|
112
|
-
width:
|
|
113
|
-
line-height:
|
|
225
|
+
width: $icon-size;
|
|
226
|
+
line-height: $icon-size;
|
|
114
227
|
text-align: center;
|
|
115
228
|
|
|
116
229
|
.closer-icon {
|
|
117
|
-
font-size: 22px;
|
|
118
230
|
opacity: 0.7;
|
|
119
231
|
|
|
120
232
|
&:hover {
|
|
@@ -124,40 +236,9 @@ export default Vue.extend({
|
|
|
124
236
|
}
|
|
125
237
|
}
|
|
126
238
|
|
|
127
|
-
&.
|
|
128
|
-
|
|
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);
|
|
239
|
+
&.icon {
|
|
240
|
+
border-left: none;
|
|
161
241
|
}
|
|
162
242
|
}
|
|
243
|
+
}
|
|
163
244
|
</style>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { mount } from '@vue/test-utils';
|
|
2
|
+
import { Card } from './index';
|
|
3
|
+
|
|
4
|
+
describe('component: Card', () => {
|
|
5
|
+
const title = 'Card title';
|
|
6
|
+
const body = 'Card body';
|
|
7
|
+
|
|
8
|
+
it('should have a card title', () => {
|
|
9
|
+
const wrapper = mount(Card, {
|
|
10
|
+
propsData: { title },
|
|
11
|
+
slots: { title: '<div>Card title</div>' }
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const element = wrapper.find('[data-testid="card-title-slot"]');
|
|
15
|
+
|
|
16
|
+
expect(element.exists()).toBe(true);
|
|
17
|
+
expect(element.text()).toBe(title);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('should have a card body', () => {
|
|
21
|
+
const wrapper = mount(Card, {
|
|
22
|
+
propsData: { body },
|
|
23
|
+
slots: { body: '<div>Card body</div>' }
|
|
24
|
+
});
|
|
25
|
+
const element = wrapper.find('[data-testid="card-body-slot"]');
|
|
26
|
+
|
|
27
|
+
expect(element.exists()).toBe(true);
|
|
28
|
+
expect(element.text()).toBe(body);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('should display the default card actions', () => {
|
|
32
|
+
const wrapper = mount(Card);
|
|
33
|
+
const element = wrapper.find('[data-testid="card-actions-slot"]');
|
|
34
|
+
|
|
35
|
+
expect(element.exists()).toBe(true);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
@@ -49,28 +49,45 @@ export default Vue.extend({
|
|
|
49
49
|
sticky: {
|
|
50
50
|
type: Boolean,
|
|
51
51
|
default: false,
|
|
52
|
-
},
|
|
52
|
+
},
|
|
53
53
|
}
|
|
54
54
|
});
|
|
55
55
|
</script>
|
|
56
56
|
|
|
57
57
|
<template>
|
|
58
|
-
<div
|
|
58
|
+
<div
|
|
59
|
+
class="card-container"
|
|
60
|
+
:class="{'highlight-border': showHighlightBorder, 'card-sticky': sticky}"
|
|
61
|
+
data-testid="card"
|
|
62
|
+
>
|
|
59
63
|
<div class="card-wrap">
|
|
60
|
-
<div
|
|
64
|
+
<div
|
|
65
|
+
class="card-title"
|
|
66
|
+
data-testid="card-title-slot"
|
|
67
|
+
>
|
|
61
68
|
<slot name="title">
|
|
62
69
|
{{ title }}
|
|
63
70
|
</slot>
|
|
64
71
|
</div>
|
|
65
|
-
<hr
|
|
66
|
-
<div
|
|
72
|
+
<hr>
|
|
73
|
+
<div
|
|
74
|
+
class="card-body"
|
|
75
|
+
data-testid="card-body-slot"
|
|
76
|
+
>
|
|
67
77
|
<slot name="body">
|
|
68
78
|
{{ content }}
|
|
69
79
|
</slot>
|
|
70
80
|
</div>
|
|
71
|
-
<div
|
|
81
|
+
<div
|
|
82
|
+
v-if="showActions"
|
|
83
|
+
class="card-actions"
|
|
84
|
+
data-testid="card-actions-slot"
|
|
85
|
+
>
|
|
72
86
|
<slot name="actions">
|
|
73
|
-
<button
|
|
87
|
+
<button
|
|
88
|
+
class="btn role-primary"
|
|
89
|
+
@click="buttonAction"
|
|
90
|
+
>
|
|
74
91
|
{{ buttonText }}
|
|
75
92
|
</button>
|
|
76
93
|
</slot>
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import { shallowMount } from '@vue/test-utils';
|
|
1
|
+
import { shallowMount, Wrapper } from '@vue/test-utils';
|
|
2
2
|
import { Checkbox } from './index';
|
|
3
3
|
|
|
4
|
-
describe('
|
|
4
|
+
describe('checkbox.vue', () => {
|
|
5
|
+
const event = {
|
|
6
|
+
target: { tagName: 'input', href: null },
|
|
7
|
+
stopPropagation: () => { },
|
|
8
|
+
preventDefault: () => { }
|
|
9
|
+
} as unknown as MouseEvent;
|
|
10
|
+
|
|
5
11
|
it('is unchecked by default', () => {
|
|
6
12
|
const wrapper = shallowMount(Checkbox);
|
|
7
13
|
const cbInput = wrapper.find('input[type="checkbox"]').element as HTMLInputElement;
|
|
@@ -16,7 +22,7 @@ describe('Checkbox.vue', () => {
|
|
|
16
22
|
expect(cbInput.checked).toBe(true);
|
|
17
23
|
});
|
|
18
24
|
|
|
19
|
-
it('updates from false to true when props change', async
|
|
25
|
+
it('updates from false to true when props change', async() => {
|
|
20
26
|
const wrapper = shallowMount(Checkbox);
|
|
21
27
|
const cbInput = wrapper.find('input[type="checkbox"]').element as HTMLInputElement;
|
|
22
28
|
|
|
@@ -27,51 +33,36 @@ describe('Checkbox.vue', () => {
|
|
|
27
33
|
expect(cbInput.checked).toBe(true);
|
|
28
34
|
});
|
|
29
35
|
|
|
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
|
-
};
|
|
36
|
+
it('emits an input event with a true value', async() => {
|
|
37
|
+
const wrapper: Wrapper<InstanceType<typeof Checkbox>> = shallowMount(Checkbox);
|
|
37
38
|
|
|
38
|
-
|
|
39
|
+
wrapper.vm.clicked(event);
|
|
39
40
|
await wrapper.vm.$nextTick();
|
|
40
41
|
|
|
41
42
|
expect(wrapper.emitted().input?.length).toBe(1);
|
|
42
43
|
expect(wrapper.emitted().input?.[0][0]).toBe(true);
|
|
43
44
|
});
|
|
44
45
|
|
|
45
|
-
it('emits an input event with a custom valueWhenTrue', async
|
|
46
|
+
it('emits an input event with a custom valueWhenTrue', async() => {
|
|
46
47
|
const valueWhenTrue = 'BIG IF TRUE';
|
|
47
|
-
const event = {
|
|
48
|
-
target: { tagName: 'input', href: null },
|
|
49
|
-
stopPropagation: () => { },
|
|
50
|
-
preventDefault: () => { }
|
|
51
|
-
};
|
|
52
48
|
|
|
53
|
-
const wrapper = shallowMount(Checkbox, { propsData: { value: false, valueWhenTrue } });
|
|
49
|
+
const wrapper: Wrapper<InstanceType<typeof Checkbox>> = shallowMount(Checkbox, { propsData: { value: false, valueWhenTrue } });
|
|
54
50
|
|
|
55
|
-
|
|
51
|
+
wrapper.vm.clicked(event);
|
|
56
52
|
await wrapper.vm.$nextTick();
|
|
57
53
|
|
|
58
54
|
expect(wrapper.emitted().input?.length).toBe(1);
|
|
59
55
|
expect(wrapper.emitted().input?.[0][0]).toBe(valueWhenTrue);
|
|
60
56
|
});
|
|
61
57
|
|
|
62
|
-
it('updates from valueWhenTrue to falsy', async
|
|
58
|
+
it('updates from valueWhenTrue to falsy', async() => {
|
|
63
59
|
const valueWhenTrue = 'REAL HUGE IF FALSE';
|
|
64
|
-
const event = {
|
|
65
|
-
target: { tagName: 'input', href: null },
|
|
66
|
-
stopPropagation: () => { },
|
|
67
|
-
preventDefault: () => { }
|
|
68
|
-
};
|
|
69
60
|
|
|
70
|
-
const wrapper = shallowMount(Checkbox, { propsData: { value: valueWhenTrue, valueWhenTrue } });
|
|
61
|
+
const wrapper: Wrapper<InstanceType<typeof Checkbox>> = shallowMount(Checkbox, { propsData: { value: valueWhenTrue, valueWhenTrue } });
|
|
71
62
|
|
|
72
|
-
|
|
63
|
+
wrapper.vm.clicked(event);
|
|
73
64
|
await wrapper.vm.$nextTick();
|
|
74
65
|
|
|
75
|
-
expect(wrapper.emitted().input?.[0][0]).
|
|
76
|
-
})
|
|
66
|
+
expect(wrapper.emitted().input?.[0][0]).toBeNull();
|
|
67
|
+
});
|
|
77
68
|
});
|