@rancher/shell 3.0.12-rc.6 → 3.0.12-rc.7
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/apis/intf/shell-api/slide-in.ts +46 -17
- package/apis/shell/__tests__/slide-in.test.ts +83 -2
- package/apis/shell/slide-in.ts +20 -0
- package/components/ExplorerProjectsNamespaces.vue +2 -2
- package/components/Resource/Detail/Metadata/IdentifyingInformation/__tests__/identifying-fields.test.ts +9 -0
- package/components/Resource/Detail/Metadata/IdentifyingInformation/identifying-fields.ts +5 -1
- package/components/SlideInPanelManager.vue +103 -25
- package/components/__tests__/SlideInPanelManager.spec.ts +153 -10
- package/components/auth/AuthBanner.vue +1 -1
- package/core/plugins-loader.js +2 -0
- package/models/__tests__/namespace.test.ts +133 -8
- package/models/__tests__/provisioning.cattle.io.cluster.test.ts +57 -1
- package/models/namespace.js +34 -2
- package/models/provisioning.cattle.io.cluster.js +20 -13
- package/package.json +1 -1
- package/pages/c/_cluster/explorer/workload-dashboard/__tests__/composable.test.ts +136 -1
- package/pages/c/_cluster/explorer/workload-dashboard/composable.ts +69 -1
- package/pages/c/_cluster/fleet/index.vue +5 -9
- package/pkg/vue.config.js +4 -3
- package/plugins/codemirror.js +2 -0
- package/plugins/dashboard-store/resource-class.js +3 -6
- package/store/__tests__/action-menu.test.ts +622 -0
- package/store/__tests__/slideInPanel.test.ts +143 -43
- package/store/__tests__/wm.test.ts +503 -0
- package/store/aws.js +19 -4
- package/store/slideInPanel.ts +15 -3
- package/types/shell/index.d.ts +26 -2
- package/utils/__tests__/fleet-appco.test.ts +23 -0
- package/utils/fleet-appco.ts +6 -1
- package/utils/sort.js +1 -1
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
import
|
|
1
|
+
import slideInPanel, { SlideInPanelState } from '@shell/store/slideInPanel';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
const MockComponentA = { template: '<div>A</div>' };
|
|
4
|
+
const MockComponentB = { template: '<div>B</div>' };
|
|
5
|
+
|
|
6
|
+
const { state: stateFactory, mutations, getters } = slideInPanel;
|
|
7
|
+
|
|
8
|
+
function createState(overrides: Partial<SlideInPanelState> = {}): SlideInPanelState {
|
|
9
|
+
return {
|
|
10
|
+
...stateFactory(),
|
|
11
|
+
...overrides
|
|
12
|
+
};
|
|
13
|
+
}
|
|
6
14
|
|
|
15
|
+
describe('slideInPanel store', () => {
|
|
7
16
|
beforeEach(() => {
|
|
8
|
-
s = slideInPanelStore.state();
|
|
9
17
|
jest.useFakeTimers();
|
|
10
18
|
});
|
|
11
19
|
|
|
@@ -14,74 +22,166 @@ describe('slideInPanel store', () => {
|
|
|
14
22
|
});
|
|
15
23
|
|
|
16
24
|
describe('state', () => {
|
|
17
|
-
it('returns initial
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
expect(
|
|
21
|
-
|
|
25
|
+
it('returns correct initial state', () => {
|
|
26
|
+
const result = stateFactory();
|
|
27
|
+
|
|
28
|
+
expect(result).toStrictEqual({
|
|
29
|
+
isOpen: false,
|
|
30
|
+
isClosing: false,
|
|
31
|
+
component: null,
|
|
32
|
+
componentProps: {}
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
describe('getters', () => {
|
|
38
|
+
it('returns isOpen from state', () => {
|
|
39
|
+
const state = createState({ isOpen: true });
|
|
40
|
+
|
|
41
|
+
expect(getters.isOpen(state, {}, {}, {})).toStrictEqual(true);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('returns isClosing from state', () => {
|
|
45
|
+
const state = createState({ isClosing: true });
|
|
46
|
+
|
|
47
|
+
expect(getters.isClosing(state, {}, {}, {})).toStrictEqual(true);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('returns component from state', () => {
|
|
51
|
+
const state = createState({ component: MockComponentA as any });
|
|
52
|
+
|
|
53
|
+
expect(getters.component(state, {}, {}, {})).toStrictEqual(MockComponentA);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('returns componentProps from state', () => {
|
|
57
|
+
const props = { title: 'Test' };
|
|
58
|
+
const state = createState({ componentProps: props });
|
|
59
|
+
|
|
60
|
+
expect(getters.componentProps(state, {}, {}, {})).toStrictEqual(props);
|
|
22
61
|
});
|
|
23
62
|
});
|
|
24
63
|
|
|
25
64
|
describe('mutations', () => {
|
|
26
65
|
describe('open', () => {
|
|
27
|
-
it('sets isOpen to true', () => {
|
|
28
|
-
|
|
66
|
+
it('sets isOpen to true and stores component and props', () => {
|
|
67
|
+
const state = createState();
|
|
68
|
+
const props = { title: 'Test Panel' };
|
|
29
69
|
|
|
30
|
-
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('stores the component reference', () => {
|
|
34
|
-
slideInPanelStore.mutations.open(s, { component: fakeComponent });
|
|
70
|
+
mutations.open(state, { component: MockComponentA, componentProps: props });
|
|
35
71
|
|
|
36
|
-
expect(
|
|
72
|
+
expect(state.isOpen).toStrictEqual(true);
|
|
73
|
+
expect(state.component).toStrictEqual(MockComponentA);
|
|
74
|
+
expect(state.componentProps).toStrictEqual(props);
|
|
37
75
|
});
|
|
38
76
|
|
|
39
|
-
it('
|
|
40
|
-
|
|
77
|
+
it('defaults componentProps to empty object when not provided', () => {
|
|
78
|
+
const state = createState();
|
|
41
79
|
|
|
42
|
-
|
|
80
|
+
mutations.open(state, { component: MockComponentA });
|
|
81
|
+
|
|
82
|
+
expect(state.componentProps).toStrictEqual({});
|
|
43
83
|
});
|
|
44
84
|
|
|
45
|
-
it('
|
|
46
|
-
|
|
85
|
+
it('resets isClosing to false', () => {
|
|
86
|
+
const state = createState({ isClosing: true });
|
|
47
87
|
|
|
48
|
-
|
|
88
|
+
mutations.open(state, { component: MockComponentA });
|
|
89
|
+
|
|
90
|
+
expect(state.isClosing).toStrictEqual(false);
|
|
49
91
|
});
|
|
50
92
|
});
|
|
51
93
|
|
|
52
94
|
describe('close', () => {
|
|
53
|
-
|
|
54
|
-
|
|
95
|
+
it('sets isClosing to true and isOpen to false immediately', () => {
|
|
96
|
+
const state = createState({ isOpen: true, component: MockComponentA as any });
|
|
97
|
+
|
|
98
|
+
mutations.close(state);
|
|
99
|
+
|
|
100
|
+
expect(state.isClosing).toStrictEqual(true);
|
|
101
|
+
expect(state.isOpen).toStrictEqual(false);
|
|
102
|
+
expect(state.component).toStrictEqual(MockComponentA);
|
|
55
103
|
});
|
|
56
104
|
|
|
57
|
-
it('
|
|
58
|
-
|
|
105
|
+
it('retains component and componentProps before the 500ms delay elapses', () => {
|
|
106
|
+
const state = createState({
|
|
107
|
+
isOpen: true,
|
|
108
|
+
component: MockComponentA as any,
|
|
109
|
+
componentProps: { title: 'Test' }
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
mutations.close(state);
|
|
113
|
+
jest.advanceTimersByTime(499);
|
|
59
114
|
|
|
60
|
-
expect(
|
|
115
|
+
expect(state.component).toStrictEqual(MockComponentA);
|
|
116
|
+
expect(state.componentProps).toStrictEqual({ title: 'Test' });
|
|
117
|
+
expect(state.isClosing).toStrictEqual(true);
|
|
61
118
|
});
|
|
62
119
|
|
|
63
|
-
it('
|
|
64
|
-
|
|
120
|
+
it('clears component and props after 500ms transition', () => {
|
|
121
|
+
const state = createState({
|
|
122
|
+
isOpen: true,
|
|
123
|
+
component: MockComponentA as any,
|
|
124
|
+
componentProps: { title: 'Test' }
|
|
125
|
+
});
|
|
65
126
|
|
|
66
|
-
|
|
127
|
+
mutations.close(state);
|
|
128
|
+
|
|
129
|
+
expect(state.component).toStrictEqual(MockComponentA);
|
|
130
|
+
expect(state.componentProps).toStrictEqual({ title: 'Test' });
|
|
131
|
+
|
|
132
|
+
jest.advanceTimersByTime(500);
|
|
133
|
+
|
|
134
|
+
expect(state.component).toStrictEqual(null);
|
|
135
|
+
expect(state.componentProps).toStrictEqual({});
|
|
136
|
+
expect(state.isClosing).toStrictEqual(false);
|
|
67
137
|
});
|
|
138
|
+
});
|
|
68
139
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
140
|
+
describe('close-then-open race condition', () => {
|
|
141
|
+
it('does not leave an untracked timer when close is called twice before open', () => {
|
|
142
|
+
const state = createState({
|
|
143
|
+
isOpen: true,
|
|
144
|
+
component: MockComponentA as any
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
mutations.close(state);
|
|
148
|
+
mutations.close(state);
|
|
149
|
+
mutations.open(state, { component: MockComponentB, componentProps: { title: 'Panel B' } });
|
|
150
|
+
|
|
151
|
+
expect(state.isOpen).toStrictEqual(true);
|
|
152
|
+
expect(state.isClosing).toStrictEqual(false);
|
|
153
|
+
expect(state.component).toStrictEqual(MockComponentB);
|
|
154
|
+
|
|
155
|
+
jest.advanceTimersByTime(500);
|
|
72
156
|
|
|
73
|
-
|
|
74
|
-
expect(
|
|
75
|
-
expect(
|
|
157
|
+
// Neither of the two stale close timers should fire and clear the newly opened panel
|
|
158
|
+
expect(state.component).toStrictEqual(MockComponentB);
|
|
159
|
+
expect(state.isClosing).toStrictEqual(false);
|
|
76
160
|
});
|
|
77
161
|
|
|
78
|
-
it('
|
|
79
|
-
|
|
162
|
+
it('cancels pending close timer when open is called', () => {
|
|
163
|
+
const state = createState({
|
|
164
|
+
isOpen: true,
|
|
165
|
+
component: MockComponentA as any
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
mutations.close(state);
|
|
169
|
+
|
|
170
|
+
expect(state.isOpen).toStrictEqual(false);
|
|
171
|
+
expect(state.isClosing).toStrictEqual(true);
|
|
172
|
+
|
|
173
|
+
mutations.open(state, { component: MockComponentB, componentProps: { title: 'Panel B' } });
|
|
174
|
+
|
|
175
|
+
expect(state.isOpen).toStrictEqual(true);
|
|
176
|
+
expect(state.isClosing).toStrictEqual(false);
|
|
177
|
+
expect(state.component).toStrictEqual(MockComponentB);
|
|
178
|
+
expect(state.componentProps).toStrictEqual({ title: 'Panel B' });
|
|
179
|
+
|
|
80
180
|
jest.advanceTimersByTime(500);
|
|
81
181
|
|
|
82
|
-
expect(
|
|
83
|
-
expect(
|
|
84
|
-
expect(
|
|
182
|
+
expect(state.component).toStrictEqual(MockComponentB);
|
|
183
|
+
expect(state.componentProps).toStrictEqual({ title: 'Panel B' });
|
|
184
|
+
expect(state.isClosing).toStrictEqual(false);
|
|
85
185
|
});
|
|
86
186
|
});
|
|
87
187
|
});
|