@rancher/shell 0.5.0 → 0.5.2
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/components/AsyncButton.vue +5 -17
- package/components/Certificates.vue +4 -4
- package/components/DraggableZone.vue +2 -2
- package/components/PodSecurityAdmission.vue +2 -2
- package/components/form/Error.vue +3 -3
- package/components/form/Footer.vue +2 -2
- package/components/form/GitPicker.vue +38 -83
- package/composables/useCompactInput.ts +2 -2
- package/core/types-provisioning.ts +7 -0
- package/edit/catalog.cattle.io.clusterrepo.vue +18 -0
- package/edit/management.cattle.io.podsecurityadmissionconfigurationtemplate.vue +2 -2
- package/edit/provisioning.cattle.io.cluster/index.vue +9 -3
- package/mixins/create-edit-view/index.js +2 -2
- package/models/management.cattle.io.kontainerdriver.js +2 -1
- package/package.json +1 -1
- package/rancher-components/Accordion/Accordion.vue +2 -3
- package/rancher-components/BadgeState/BadgeState.vue +3 -3
- package/rancher-components/Banner/Banner.vue +2 -2
- package/rancher-components/Card/Card.vue +3 -3
- package/rancher-components/Form/Checkbox/Checkbox.vue +3 -3
- package/rancher-components/Form/LabeledInput/LabeledInput.test.ts +1 -1
- package/rancher-components/Form/LabeledInput/LabeledInput.vue +23 -53
- package/rancher-components/Form/Radio/RadioButton.vue +7 -13
- package/rancher-components/Form/Radio/RadioGroup.vue +3 -4
- package/rancher-components/Form/TextArea/TextAreaAutoGrow.vue +4 -6
- package/rancher-components/Form/ToggleSwitch/ToggleSwitch.vue +4 -7
- package/rancher-components/LabeledTooltip/LabeledTooltip.vue +4 -9
- package/rancher-components/StringList/StringList.vue +8 -8
- package/rancher-components/components/Accordion/Accordion.vue +2 -3
- package/rancher-components/components/BadgeState/BadgeState.vue +3 -3
- package/rancher-components/components/Banner/Banner.vue +2 -2
- package/rancher-components/components/Card/Card.vue +3 -3
- package/rancher-components/components/Form/Checkbox/Checkbox.vue +3 -3
- package/rancher-components/components/Form/LabeledInput/LabeledInput.test.ts +1 -1
- package/rancher-components/components/Form/LabeledInput/LabeledInput.vue +23 -53
- package/rancher-components/components/Form/Radio/RadioButton.vue +7 -13
- package/rancher-components/components/Form/Radio/RadioGroup.vue +3 -4
- package/rancher-components/components/Form/TextArea/TextAreaAutoGrow.vue +4 -6
- package/rancher-components/components/Form/ToggleSwitch/ToggleSwitch.vue +4 -7
- package/rancher-components/components/LabeledTooltip/LabeledTooltip.vue +4 -9
- package/rancher-components/components/StringList/StringList.vue +8 -8
- package/scripts/extension/parse-tag-name +3 -3
- package/store/plugins.js +7 -6
- package/tsconfig.paths.json +1 -4
- package/types/shell/index.d.ts +20 -82
- package/utils/git.ts +1 -1
- package/composables/useCompactInput.test.ts +0 -36
- package/composables/useLabeledFormElement.test.ts +0 -135
- package/types/vue-shim.d.ts +0 -42
- /package/rancher-components/BadgeState/{BadgeState.test.ts → BadgeState.spec.ts} +0 -0
- /package/rancher-components/components/BadgeState/{BadgeState.test.ts → BadgeState.spec.ts} +0 -0
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import
|
|
2
|
+
import Vue from 'vue';
|
|
3
3
|
import { _VIEW } from '@shell/config/query-params';
|
|
4
|
-
import { randomStr } from '@shell/utils/string';
|
|
5
4
|
|
|
6
|
-
export default
|
|
5
|
+
export default Vue.extend({
|
|
7
6
|
props: {
|
|
8
7
|
/**
|
|
9
8
|
* The name of the input, for grouping.
|
|
@@ -72,10 +71,7 @@ export default defineComponent({
|
|
|
72
71
|
},
|
|
73
72
|
|
|
74
73
|
data() {
|
|
75
|
-
return {
|
|
76
|
-
isChecked: this.value === this.val,
|
|
77
|
-
randomString: `${ randomStr() }-radio`,
|
|
78
|
-
};
|
|
74
|
+
return { isChecked: this.value === this.val };
|
|
79
75
|
},
|
|
80
76
|
|
|
81
77
|
computed: {
|
|
@@ -119,15 +115,13 @@ export default defineComponent({
|
|
|
119
115
|
/**
|
|
120
116
|
* Emits the input event.
|
|
121
117
|
*/
|
|
122
|
-
clicked(
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
if (this.isDisabled || (target instanceof HTMLElement && target.tagName === 'A')) {
|
|
118
|
+
clicked({ target }: { target?: HTMLElement }) {
|
|
119
|
+
if (this.isDisabled || target?.tagName === 'A') {
|
|
126
120
|
return;
|
|
127
121
|
}
|
|
128
122
|
|
|
129
123
|
this.$emit('input', this.val);
|
|
130
|
-
}
|
|
124
|
+
}
|
|
131
125
|
}
|
|
132
126
|
});
|
|
133
127
|
</script>
|
|
@@ -140,7 +134,7 @@ export default defineComponent({
|
|
|
140
134
|
@click.stop="clicked($event)"
|
|
141
135
|
>
|
|
142
136
|
<input
|
|
143
|
-
:id="
|
|
137
|
+
:id="_uid+'-radio'"
|
|
144
138
|
:disabled="isDisabled"
|
|
145
139
|
:name="name"
|
|
146
140
|
:value="''+val"
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { PropType
|
|
2
|
+
import Vue, { PropType } from 'vue';
|
|
3
3
|
import { _VIEW } from '@shell/config/query-params';
|
|
4
4
|
import RadioButton from '@components/Form/Radio/RadioButton.vue';
|
|
5
5
|
|
|
6
6
|
interface Option {
|
|
7
7
|
value: unknown,
|
|
8
|
-
label: string
|
|
9
|
-
description?: string,
|
|
8
|
+
label: string
|
|
10
9
|
}
|
|
11
10
|
|
|
12
|
-
export default
|
|
11
|
+
export default Vue.extend({
|
|
13
12
|
components: { RadioButton },
|
|
14
13
|
props: {
|
|
15
14
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import
|
|
2
|
+
import Vue from 'vue';
|
|
3
3
|
import debounce from 'lodash/debounce';
|
|
4
4
|
import { _EDIT, _VIEW } from '@shell/config/query-params';
|
|
5
5
|
|
|
@@ -10,7 +10,7 @@ declare module 'vue/types/vue' {
|
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export default
|
|
13
|
+
export default Vue.extend({
|
|
14
14
|
inheritAttrs: false,
|
|
15
15
|
|
|
16
16
|
props: {
|
|
@@ -115,9 +115,7 @@ export default defineComponent({
|
|
|
115
115
|
/**
|
|
116
116
|
* Emits the input event and resizes the Text Area.
|
|
117
117
|
*/
|
|
118
|
-
onInput(
|
|
119
|
-
const val = (event?.target as HTMLInputElement)?.value;
|
|
120
|
-
|
|
118
|
+
onInput(val: string): void {
|
|
121
119
|
this.$emit('input', val);
|
|
122
120
|
this.queueResize();
|
|
123
121
|
},
|
|
@@ -165,7 +163,7 @@ export default defineComponent({
|
|
|
165
163
|
v-bind="$attrs"
|
|
166
164
|
:spellcheck="spellcheck"
|
|
167
165
|
@paste="$emit('paste', $event)"
|
|
168
|
-
@input="onInput($event)"
|
|
166
|
+
@input="onInput($event.target.value)"
|
|
169
167
|
@focus="$emit('focus', $event)"
|
|
170
168
|
@blur="$emit('blur', $event)"
|
|
171
169
|
/>
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
type StateType = boolean | 'true' | 'false' | undefined;
|
|
5
|
-
|
|
6
|
-
export default defineComponent({
|
|
2
|
+
import Vue from 'vue';
|
|
3
|
+
export default Vue.extend({
|
|
7
4
|
props: {
|
|
8
5
|
value: {
|
|
9
6
|
type: [Boolean, String, Number],
|
|
@@ -31,7 +28,7 @@ export default defineComponent({
|
|
|
31
28
|
},
|
|
32
29
|
},
|
|
33
30
|
data() {
|
|
34
|
-
return { state: false as
|
|
31
|
+
return { state: false as boolean | string | number };
|
|
35
32
|
},
|
|
36
33
|
|
|
37
34
|
watch: {
|
|
@@ -44,7 +41,7 @@ export default defineComponent({
|
|
|
44
41
|
},
|
|
45
42
|
|
|
46
43
|
methods: {
|
|
47
|
-
toggle(neu:
|
|
44
|
+
toggle(neu: boolean | string | number) {
|
|
48
45
|
this.state = neu === null ? !this.state : neu;
|
|
49
46
|
this.$emit('input', this.state ? this.onValue : this.offValue);
|
|
50
47
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import
|
|
2
|
+
import Vue from 'vue';
|
|
3
3
|
|
|
4
|
-
export default
|
|
4
|
+
export default Vue.extend({
|
|
5
5
|
props: {
|
|
6
6
|
/**
|
|
7
7
|
* The Labeled Tooltip value.
|
|
@@ -29,14 +29,9 @@ export default defineComponent({
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
computed: {
|
|
32
|
-
iconClass()
|
|
32
|
+
iconClass() {
|
|
33
33
|
return this.status === 'error' ? 'icon-warning' : 'icon-info';
|
|
34
34
|
}
|
|
35
|
-
},
|
|
36
|
-
methods: {
|
|
37
|
-
isObject(value: string | Record<string, unknown>): value is Record<string, unknown> {
|
|
38
|
-
return typeof value === 'object' && value !== null && !!value.content;
|
|
39
|
-
}
|
|
40
35
|
}
|
|
41
36
|
});
|
|
42
37
|
</script>
|
|
@@ -49,7 +44,7 @@ export default defineComponent({
|
|
|
49
44
|
>
|
|
50
45
|
<template v-if="hover">
|
|
51
46
|
<i
|
|
52
|
-
v-clean-tooltip="
|
|
47
|
+
v-clean-tooltip="value.content ? { ...{content: value.content, classes: [`tooltip-${status}`]}, ...value } : value"
|
|
53
48
|
:class="{'hover':!value, [iconClass]: true}"
|
|
54
49
|
class="icon status-icon"
|
|
55
50
|
/>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import Vue, { PropType
|
|
2
|
+
import Vue, { PropType } from 'vue';
|
|
3
3
|
|
|
4
4
|
import LabeledInput from '@components/Form/LabeledInput/LabeledInput.vue';
|
|
5
5
|
import { findStringIndex, hasDuplicatedStrings } from '@shell/utils/array';
|
|
@@ -29,7 +29,7 @@ const CLASS = {
|
|
|
29
29
|
/**
|
|
30
30
|
* Manage a list of strings
|
|
31
31
|
*/
|
|
32
|
-
export default
|
|
32
|
+
export default Vue.extend({
|
|
33
33
|
|
|
34
34
|
name: 'StringList',
|
|
35
35
|
components: { LabeledInput },
|
|
@@ -92,9 +92,9 @@ export default defineComponent({
|
|
|
92
92
|
},
|
|
93
93
|
data() {
|
|
94
94
|
return {
|
|
95
|
-
value:
|
|
95
|
+
value: null as string | null,
|
|
96
96
|
selected: null as string | null,
|
|
97
|
-
editedItem:
|
|
97
|
+
editedItem: null as string | null,
|
|
98
98
|
isCreateItem: false,
|
|
99
99
|
errors: { duplicate: false } as Record<Error, boolean>
|
|
100
100
|
};
|
|
@@ -281,7 +281,7 @@ export default defineComponent({
|
|
|
281
281
|
this.isCreateItem = true;
|
|
282
282
|
this.setFocus(INPUT.create);
|
|
283
283
|
} else {
|
|
284
|
-
this.value =
|
|
284
|
+
this.value = null;
|
|
285
285
|
this.toggleError('duplicate', false);
|
|
286
286
|
this.onSelectLeave();
|
|
287
287
|
|
|
@@ -303,11 +303,11 @@ export default defineComponent({
|
|
|
303
303
|
this.editedItem = item || '';
|
|
304
304
|
this.setFocus(INPUT.edit);
|
|
305
305
|
} else {
|
|
306
|
-
this.value =
|
|
306
|
+
this.value = null;
|
|
307
307
|
this.toggleError('duplicate', false);
|
|
308
308
|
this.onSelectLeave();
|
|
309
309
|
|
|
310
|
-
this.editedItem =
|
|
310
|
+
this.editedItem = null;
|
|
311
311
|
}
|
|
312
312
|
},
|
|
313
313
|
|
|
@@ -502,7 +502,7 @@ export default defineComponent({
|
|
|
502
502
|
<button
|
|
503
503
|
data-testid="button-add"
|
|
504
504
|
class="btn btn-sm role-tertiary add-button"
|
|
505
|
-
:disabled="
|
|
505
|
+
:disabled="isCreateItem || editedItem"
|
|
506
506
|
@click.prevent="onClickPlusButton"
|
|
507
507
|
>
|
|
508
508
|
<span class="icon icon-plus icon-sm" />
|
|
@@ -4,8 +4,8 @@ GITHUB_RELEASE_TAG=$1
|
|
|
4
4
|
GITHUB_RUN_ID=$2
|
|
5
5
|
GITHUB_WORKFLOW_TYPE=$3
|
|
6
6
|
|
|
7
|
-
#
|
|
8
|
-
if [[ "${GITHUB_WORKFLOW_TYPE}" == "
|
|
7
|
+
# Ensure "catalog" workflow release tag name does not match a pkg/<pkg-name>
|
|
8
|
+
if [[ "${GITHUB_WORKFLOW_TYPE}" == "catalog" ]]; then
|
|
9
9
|
for d in pkg/*/ ; do
|
|
10
10
|
pkg=$(basename $d)
|
|
11
11
|
|
|
@@ -19,7 +19,7 @@ if [[ "${GITHUB_WORKFLOW_TYPE}" == "charts" ]]; then
|
|
|
19
19
|
fi
|
|
20
20
|
done
|
|
21
21
|
else
|
|
22
|
-
#
|
|
22
|
+
# Ensure "charts" workflow release tag name does not match the root <pkg-name>
|
|
23
23
|
BASE_EXT=$(jq -r .name package.json)
|
|
24
24
|
EXT_VERSION=$(jq -r .version package.json)
|
|
25
25
|
|
package/store/plugins.js
CHANGED
|
@@ -100,12 +100,13 @@ export const suffixFields = [
|
|
|
100
100
|
|
|
101
101
|
// Machine driver to cloud provider mapping
|
|
102
102
|
const driverToCloudProviderMap = {
|
|
103
|
-
amazonec2:
|
|
104
|
-
azure:
|
|
105
|
-
digitalocean:
|
|
106
|
-
harvester:
|
|
107
|
-
linode:
|
|
108
|
-
vmwarevsphere:
|
|
103
|
+
amazonec2: 'aws',
|
|
104
|
+
azure: 'azure',
|
|
105
|
+
digitalocean: '', // Show restricted options
|
|
106
|
+
harvester: 'harvester',
|
|
107
|
+
linode: '', // Show restricted options
|
|
108
|
+
vmwarevsphere: 'rancher-vsphere',
|
|
109
|
+
ovhcloudpubliccloud: '',
|
|
109
110
|
|
|
110
111
|
custom: undefined // Show all options
|
|
111
112
|
};
|
package/tsconfig.paths.json
CHANGED
package/types/shell/index.d.ts
CHANGED
|
@@ -2134,97 +2134,35 @@ export default _default;
|
|
|
2134
2134
|
// @shell/mixins/create-edit-view
|
|
2135
2135
|
|
|
2136
2136
|
declare module '@shell/mixins/create-edit-view' {
|
|
2137
|
-
declare var _default: import("vue").
|
|
2138
|
-
mode: {
|
|
2139
|
-
type: StringConstructor;
|
|
2140
|
-
default: any;
|
|
2141
|
-
};
|
|
2142
|
-
realMode: {
|
|
2143
|
-
type: StringConstructor;
|
|
2144
|
-
default: any;
|
|
2145
|
-
};
|
|
2146
|
-
as: {
|
|
2147
|
-
type: StringConstructor;
|
|
2148
|
-
default: any;
|
|
2149
|
-
};
|
|
2150
|
-
value: {
|
|
2151
|
-
type: ObjectConstructor;
|
|
2152
|
-
required: true;
|
|
2153
|
-
};
|
|
2154
|
-
initialValue: {
|
|
2155
|
-
type: ObjectConstructor;
|
|
2156
|
-
default: any;
|
|
2157
|
-
};
|
|
2158
|
-
liveValue: {
|
|
2159
|
-
type: ObjectConstructor;
|
|
2160
|
-
default: any;
|
|
2161
|
-
};
|
|
2162
|
-
doneEvent: {
|
|
2163
|
-
type: BooleanConstructor;
|
|
2164
|
-
default: boolean;
|
|
2165
|
-
};
|
|
2166
|
-
}, {}, {
|
|
2137
|
+
declare var _default: import("vue/types/vue").ExtendedVue<Vue<Record<string, any>, Record<string, any>, never, never, (event: string, ...args: any[]) => Vue<Record<string, any>, Record<string, any>, never, never, any>>, {
|
|
2167
2138
|
errors: any[];
|
|
2168
|
-
}, {
|
|
2169
|
-
isCreate(): boolean;
|
|
2170
|
-
isEdit(): boolean;
|
|
2171
|
-
isView(): boolean;
|
|
2172
|
-
schema(): any;
|
|
2173
|
-
isNamespaced(): any;
|
|
2174
|
-
labels: {
|
|
2175
|
-
get(): any;
|
|
2176
|
-
set(neu: any): void;
|
|
2177
|
-
};
|
|
2178
|
-
annotations: {
|
|
2179
|
-
get(): any;
|
|
2180
|
-
set(neu: any): void;
|
|
2181
|
-
};
|
|
2182
|
-
doneRoute(): any;
|
|
2183
|
-
doneParams(): any;
|
|
2184
2139
|
}, {
|
|
2185
2140
|
done(): any;
|
|
2186
2141
|
conflict(): Promise<any>;
|
|
2187
2142
|
save(buttonDone: any, url: any, depth?: number): any;
|
|
2188
2143
|
actuallySave(url: any): Promise<void>;
|
|
2189
2144
|
setErrors(errors: any): void;
|
|
2190
|
-
},
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
initialValue: {
|
|
2208
|
-
type: ObjectConstructor;
|
|
2209
|
-
default: any;
|
|
2210
|
-
};
|
|
2211
|
-
liveValue: {
|
|
2212
|
-
type: ObjectConstructor;
|
|
2213
|
-
default: any;
|
|
2214
|
-
};
|
|
2215
|
-
doneEvent: {
|
|
2216
|
-
type: BooleanConstructor;
|
|
2217
|
-
default: boolean;
|
|
2218
|
-
};
|
|
2219
|
-
}>>, {
|
|
2220
|
-
as: string;
|
|
2221
|
-
mode: string;
|
|
2145
|
+
}, {
|
|
2146
|
+
isCreate: boolean;
|
|
2147
|
+
isEdit: boolean;
|
|
2148
|
+
isView: boolean;
|
|
2149
|
+
schema: any;
|
|
2150
|
+
isNamespaced: any;
|
|
2151
|
+
labels: any;
|
|
2152
|
+
annotations: any;
|
|
2153
|
+
doneRoute: any;
|
|
2154
|
+
doneParams: any;
|
|
2155
|
+
}, {
|
|
2156
|
+
mode: any;
|
|
2157
|
+
realMode: any;
|
|
2158
|
+
as: any;
|
|
2159
|
+
value: any;
|
|
2160
|
+
initialValue: any;
|
|
2161
|
+
liveValue: any;
|
|
2222
2162
|
doneEvent: boolean;
|
|
2223
|
-
|
|
2224
|
-
liveValue: Record<string, any>;
|
|
2225
|
-
realMode: string;
|
|
2226
|
-
}>;
|
|
2163
|
+
}, {}, any, import("vue/types/v3-component-options").ComponentOptionsMixin>;
|
|
2227
2164
|
export default _default;
|
|
2165
|
+
import Vue from "vue";
|
|
2228
2166
|
}
|
|
2229
2167
|
|
|
2230
2168
|
// @shell/models/namespace
|
package/utils/git.ts
CHANGED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { ref } from 'vue';
|
|
2
|
-
import { useCompactInput } from './useCompactInput';
|
|
3
|
-
|
|
4
|
-
describe('useCompactInput', () => {
|
|
5
|
-
it('should compute isCompact correctly when compact is explicitly set', () => {
|
|
6
|
-
const props = ref({
|
|
7
|
-
compact: true,
|
|
8
|
-
label: 'Test Label',
|
|
9
|
-
labelKey: 'testLabel',
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
const { isCompact } = useCompactInput(props.value);
|
|
13
|
-
|
|
14
|
-
expect(isCompact.value).toBe(true);
|
|
15
|
-
|
|
16
|
-
// When compact is explicitly set to false, isCompact should be false
|
|
17
|
-
props.value.compact = false;
|
|
18
|
-
expect(isCompact.value).toBe(false);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it('should compute isCompact correctly when compact is not explicitly set', () => {
|
|
22
|
-
const props = ref({
|
|
23
|
-
label: '',
|
|
24
|
-
labelKey: '',
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
const { isCompact } = useCompactInput(props.value);
|
|
28
|
-
|
|
29
|
-
// When there is no label and labelKey is also not present, isCompact should be true
|
|
30
|
-
expect(isCompact.value).toBe(true);
|
|
31
|
-
|
|
32
|
-
// When label is present, isCompact should be false
|
|
33
|
-
props.value.label = 'Updated Label';
|
|
34
|
-
expect(isCompact.value).toBe(false);
|
|
35
|
-
});
|
|
36
|
-
});
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { ref } from 'vue';
|
|
2
|
-
import { useLabeledFormElement } from './useLabeledFormElement';
|
|
3
|
-
|
|
4
|
-
describe('useLabeledFormElement', () => {
|
|
5
|
-
it('should set raised to true when focused', () => {
|
|
6
|
-
const props = {
|
|
7
|
-
mode: 'edit',
|
|
8
|
-
value: '',
|
|
9
|
-
required: true,
|
|
10
|
-
disabled: false,
|
|
11
|
-
rules: [],
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const emit = jest.fn();
|
|
15
|
-
const { onFocusLabeled, onBlurLabeled, raised } = useLabeledFormElement(props, emit);
|
|
16
|
-
|
|
17
|
-
onFocusLabeled();
|
|
18
|
-
expect(raised.value).toBe(true);
|
|
19
|
-
|
|
20
|
-
onBlurLabeled();
|
|
21
|
-
expect(raised.value).toBe(false);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('should set focused to true when focused', () => {
|
|
25
|
-
const props = {
|
|
26
|
-
mode: 'edit',
|
|
27
|
-
value: '',
|
|
28
|
-
required: true,
|
|
29
|
-
disabled: false,
|
|
30
|
-
rules: [],
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const emit = jest.fn();
|
|
34
|
-
const { onFocusLabeled, onBlurLabeled, focused } = useLabeledFormElement(props, emit);
|
|
35
|
-
|
|
36
|
-
onFocusLabeled();
|
|
37
|
-
expect(focused.value).toBe(true);
|
|
38
|
-
|
|
39
|
-
onBlurLabeled();
|
|
40
|
-
expect(focused.value).toBe(false);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it('should set blurred to current timestamp when blurred', () => {
|
|
44
|
-
const props = {
|
|
45
|
-
mode: 'edit',
|
|
46
|
-
value: '',
|
|
47
|
-
required: true,
|
|
48
|
-
disabled: false,
|
|
49
|
-
rules: [],
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const emit = jest.fn();
|
|
53
|
-
const { onBlurLabeled, blurred } = useLabeledFormElement(props, emit);
|
|
54
|
-
|
|
55
|
-
onBlurLabeled();
|
|
56
|
-
expect(blurred.value).toBeTruthy();
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('should compute isDisabled correctly', () => {
|
|
60
|
-
const props = ref({
|
|
61
|
-
mode: 'edit',
|
|
62
|
-
value: '',
|
|
63
|
-
required: true,
|
|
64
|
-
disabled: false,
|
|
65
|
-
rules: [],
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
const emit = jest.fn();
|
|
69
|
-
const { isDisabled } = useLabeledFormElement(props.value, emit);
|
|
70
|
-
|
|
71
|
-
expect(isDisabled.value).toBe(false);
|
|
72
|
-
|
|
73
|
-
props.value.disabled = true;
|
|
74
|
-
expect(isDisabled.value).toBe(true);
|
|
75
|
-
|
|
76
|
-
props.value.mode = 'view';
|
|
77
|
-
expect(isDisabled.value).toBe(true);
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it('should compute validationMessage correctly for required field', () => {
|
|
81
|
-
const props = ref({
|
|
82
|
-
mode: 'edit',
|
|
83
|
-
value: '',
|
|
84
|
-
required: true,
|
|
85
|
-
disabled: false,
|
|
86
|
-
rules: [
|
|
87
|
-
(value: string[]) => (value.length < 5 ? 'This field is required' : undefined),
|
|
88
|
-
],
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
const emit = jest.fn();
|
|
92
|
-
const { validationMessage, onBlurLabeled } = useLabeledFormElement(props.value, emit);
|
|
93
|
-
|
|
94
|
-
onBlurLabeled();
|
|
95
|
-
expect(validationMessage.value).toBe('This field is required');
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
it('should compute validationMessage correctly for custom rules', () => {
|
|
99
|
-
const props = ref({
|
|
100
|
-
mode: 'edit',
|
|
101
|
-
value: 'test',
|
|
102
|
-
required: false,
|
|
103
|
-
disabled: false,
|
|
104
|
-
rules: [
|
|
105
|
-
(value: string[]) => (value.length < 5 ? 'Value must be at least 5 characters long' : undefined),
|
|
106
|
-
(value: string[]) => (value.includes('test') ? 'Value cannot contain the word "test"' : undefined),
|
|
107
|
-
],
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
const emit = jest.fn();
|
|
111
|
-
const { validationMessage, onBlurLabeled } = useLabeledFormElement(props.value, emit);
|
|
112
|
-
|
|
113
|
-
onBlurLabeled();
|
|
114
|
-
expect(validationMessage.value).toBe('Value must be at least 5 characters long, Value cannot contain the word "test"');
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
it('should compute requiredField correctly', () => {
|
|
118
|
-
const props = ref({
|
|
119
|
-
mode: 'edit',
|
|
120
|
-
value: '',
|
|
121
|
-
required: true,
|
|
122
|
-
disabled: false,
|
|
123
|
-
rules: [],
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
const emit = jest.fn();
|
|
127
|
-
const { requiredField } = useLabeledFormElement(props.value, emit);
|
|
128
|
-
|
|
129
|
-
expect(requiredField.value).toBe(true);
|
|
130
|
-
|
|
131
|
-
// When the field is not required, requiredField should be false
|
|
132
|
-
props.value.required = false;
|
|
133
|
-
expect(requiredField.value).toBe(false);
|
|
134
|
-
});
|
|
135
|
-
});
|
package/types/vue-shim.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
// eslint-disable-next-line no-unused-vars
|
|
2
|
-
import Vue, { ComponentCustomProperties } from 'vue';
|
|
3
|
-
declare module '*.vue' {
|
|
4
|
-
export default Vue;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
// This is required to keep typescript from complaining. It is required for
|
|
8
|
-
// our i18n plugin. For more info see:
|
|
9
|
-
// https://v2.vuejs.org/v2/guide/typescript.html?redirect=true#Augmenting-Types-for-Use-with-Plugins
|
|
10
|
-
declare module 'vue/types/vue' {
|
|
11
|
-
// eslint-disable-next-line no-unused-vars
|
|
12
|
-
interface Vue {
|
|
13
|
-
/**
|
|
14
|
-
* Lookup a given string with the given arguments
|
|
15
|
-
* @param raw if set, do not do HTML escaping.
|
|
16
|
-
*/
|
|
17
|
-
t: {
|
|
18
|
-
(key: string, args?: Record<string, any>, raw?: boolean): string;
|
|
19
|
-
(options: { k: string; raw?: boolean; tag?: string | Record<string, any>; escapehtml?: boolean }): string;
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
declare module '@vue/runtime-core' {
|
|
25
|
-
// eslint-disable-next-line no-unused-vars
|
|
26
|
-
interface Vue {
|
|
27
|
-
t: {
|
|
28
|
-
(key: string, args?: Record<string, any>, raw?: boolean): string;
|
|
29
|
-
(options: { k: string; raw?: boolean; tag?: string | Record<string, any>; escapehtml?: boolean }): string;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// eslint-disable-next-line no-unused-vars
|
|
34
|
-
interface ComponentCustomProperties {
|
|
35
|
-
$t: {
|
|
36
|
-
(key: string, args?: Record<string, any>, raw?: boolean): string;
|
|
37
|
-
(options: { k: string; raw?: boolean; tag?: string | Record<string, any>; escapehtml?: boolean }): string;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
declare module 'js-yaml';
|
|
File without changes
|
|
File without changes
|