Skip to content

Commit 771166b

Browse files
authored
[Stateful sidenav] Enable on-prem (#203239)
1 parent c423e3e commit 771166b

File tree

20 files changed

+139
-352
lines changed

20 files changed

+139
-352
lines changed

.buildkite/ftr_platform_stateful_configs.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,6 @@ enabled:
264264
- x-pack/test/functional/apps/security/config.ts
265265
- x-pack/test/functional/apps/snapshot_restore/config.ts
266266
- x-pack/test/functional/apps/spaces/config.ts
267-
- x-pack/test/functional/apps/spaces/solution_view_flag_enabled/config.ts
268267
- x-pack/test/functional/apps/status_page/config.ts
269268
- x-pack/test/functional/apps/transform/creation/index_pattern/config.ts
270269
- x-pack/test/functional/apps/transform/creation/runtime_mappings_saved_search/config.ts

x-pack/plugins/spaces/public/config.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,4 @@ export interface ConfigType {
99
maxSpaces: number;
1010
allowFeatureVisibility: boolean;
1111
allowSolutionVisibility: boolean;
12-
experimental: {
13-
forceSolutionVisibility: boolean;
14-
};
1512
}

x-pack/plugins/spaces/public/management/management_service.test.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ describe('ManagementService', () => {
2727
maxSpaces: 1000,
2828
allowFeatureVisibility: true,
2929
allowSolutionVisibility: true,
30-
experimental: {
31-
forceSolutionVisibility: false,
32-
},
3330
};
3431

3532
describe('#setup', () => {

x-pack/plugins/spaces/public/management/spaces_management_app.test.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ const config: ConfigType = {
4545
maxSpaces: 1000,
4646
allowFeatureVisibility: true,
4747
allowSolutionVisibility: true,
48-
experimental: {
49-
forceSolutionVisibility: false,
50-
},
5148
};
5249

5350
const eventTracker = new EventTracker({ reportEvent: jest.fn() });

x-pack/plugins/spaces/public/nav_control/solution_view_tour/solution_view_tour.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ export const SolutionViewTour: FC<Props> = ({ children, solution, isTourOpen, on
7272
onFinish={onFinishTour}
7373
step={1}
7474
stepsTotal={1}
75+
repositionOnScroll
7576
title={i18n.translate('xpack.spaces.navControl.tour.title', {
7677
defaultMessage: 'You chose the {solution} solution view',
7778
values: { solution: solutionLabel },

x-pack/plugins/spaces/public/plugin.test.ts

Lines changed: 30 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
* 2.0.
66
*/
77

8-
import { cloudMock } from '@kbn/cloud-plugin/public/mocks';
98
import { coreMock } from '@kbn/core/public/mocks';
109
import { homePluginMock } from '@kbn/home-plugin/public/mocks';
1110
import {
@@ -20,7 +19,7 @@ describe('Spaces plugin', () => {
2019
it('should register the space selector app when buildFlavor is traditional', () => {
2120
const coreSetup = coreMock.createSetup();
2221
const mockInitializerContext = coreMock.createPluginInitializerContext(
23-
{},
22+
{ allowSolutionVisibility: true },
2423
{ buildFlavor: 'traditional' }
2524
);
2625

@@ -40,7 +39,7 @@ describe('Spaces plugin', () => {
4039
it('should not register the space selector app when buildFlavor is serverless and maxSpaces is 1', () => {
4140
const coreSetup = coreMock.createSetup();
4241
const mockInitializerContext = coreMock.createPluginInitializerContext(
43-
{ maxSpaces: 1 },
42+
{ maxSpaces: 1, allowSolutionVisibility: true },
4443
{ buildFlavor: 'serverless' }
4544
);
4645

@@ -60,7 +59,7 @@ describe('Spaces plugin', () => {
6059
it('should register the space selector app when buildFlavor is serverless and and maxSpaces is >1', () => {
6160
const coreSetup = coreMock.createSetup();
6261
const mockInitializerContext = coreMock.createPluginInitializerContext(
63-
{ maxSpaces: 2 },
62+
{ maxSpaces: 2, allowSolutionVisibility: true },
6463
{ buildFlavor: 'serverless' }
6564
);
6665

@@ -88,7 +87,7 @@ describe('Spaces plugin', () => {
8887
management.sections.section.kibana = mockSection;
8988

9089
const mockInitializerContext = coreMock.createPluginInitializerContext(
91-
{},
90+
{ allowSolutionVisibility: true },
9291
{ buildFlavor: 'traditional' }
9392
);
9493

@@ -122,7 +121,9 @@ describe('Spaces plugin', () => {
122121

123122
management.sections.section.kibana = mockSection;
124123

125-
const plugin = new SpacesPlugin(coreMock.createPluginInitializerContext({ maxSpaces: 1 }));
124+
const plugin = new SpacesPlugin(
125+
coreMock.createPluginInitializerContext({ maxSpaces: 1, allowSolutionVisibility: true })
126+
);
126127
plugin.setup(coreSetup, {
127128
management,
128129
home,
@@ -152,7 +153,9 @@ describe('Spaces plugin', () => {
152153

153154
management.sections.section.kibana = mockSection;
154155

155-
const plugin = new SpacesPlugin(coreMock.createPluginInitializerContext({ maxSpaces: 2 }));
156+
const plugin = new SpacesPlugin(
157+
coreMock.createPluginInitializerContext({ maxSpaces: 2, allowSolutionVisibility: true })
158+
);
156159
plugin.setup(coreSetup, {
157160
management,
158161
home,
@@ -179,7 +182,7 @@ describe('Spaces plugin', () => {
179182
const coreStart = coreMock.createStart();
180183

181184
const mockInitializerContext = coreMock.createPluginInitializerContext(
182-
{},
185+
{ allowSolutionVisibility: true },
183186
{ buildFlavor: 'traditional' }
184187
);
185188

@@ -196,7 +199,7 @@ describe('Spaces plugin', () => {
196199
const coreStart = coreMock.createStart();
197200

198201
const mockInitializerContext = coreMock.createPluginInitializerContext(
199-
{ maxSpaces: 1 },
202+
{ maxSpaces: 1, allowSolutionVisibility: true },
200203
{ buildFlavor: 'serverless' }
201204
);
202205

@@ -214,7 +217,9 @@ describe('Spaces plugin', () => {
214217
const coreSetup = coreMock.createSetup();
215218
const coreStart = coreMock.createStart();
216219

217-
const plugin = new SpacesPlugin(coreMock.createPluginInitializerContext({ maxSpaces: 1 }));
220+
const plugin = new SpacesPlugin(
221+
coreMock.createPluginInitializerContext({ maxSpaces: 1, allowSolutionVisibility: true })
222+
);
218223
const spacesSetup = plugin.setup(coreSetup, {});
219224
const spacesStart = plugin.start(coreStart);
220225

@@ -226,7 +231,9 @@ describe('Spaces plugin', () => {
226231
const coreSetup = coreMock.createSetup();
227232
const coreStart = coreMock.createStart();
228233

229-
const plugin = new SpacesPlugin(coreMock.createPluginInitializerContext({ maxSpaces: 1000 }));
234+
const plugin = new SpacesPlugin(
235+
coreMock.createPluginInitializerContext({ maxSpaces: 1000, allowSolutionVisibility: true })
236+
);
230237
const spacesSetup = plugin.setup(coreSetup, {});
231238
const spacesStart = plugin.start(coreStart);
232239

@@ -236,129 +243,45 @@ describe('Spaces plugin', () => {
236243
});
237244

238245
describe('isSolutionViewEnabled', () => {
239-
it('when onCloud, not serverless and allowSolutionVisibility is "true"', () => {
246+
it('when allowSolutionVisibility is "true"', () => {
240247
const coreSetup = coreMock.createSetup();
241248
const coreStart = coreMock.createStart();
242-
const cloud = cloudMock.createSetup();
243-
cloud.isCloudEnabled = true;
244249

245250
const plugin = new SpacesPlugin(
246-
coreMock.createPluginInitializerContext(
247-
{ allowSolutionVisibility: true },
248-
{ buildFlavor: 'traditional' }
249-
)
251+
coreMock.createPluginInitializerContext({ allowSolutionVisibility: true })
250252
);
251-
const spacesSetup = plugin.setup(coreSetup, { cloud });
253+
const spacesSetup = plugin.setup(coreSetup, {});
252254
const spacesStart = plugin.start(coreStart);
253255

254256
expect(spacesSetup.isSolutionViewEnabled).toBe(true);
255257
expect(spacesStart.isSolutionViewEnabled).toBe(true);
256258
});
257259

258-
it('when not onCloud and allowSolutionVisibility is "true"', () => {
260+
it('when allowSolutionVisibility is "false"', () => {
259261
const coreSetup = coreMock.createSetup();
260262
const coreStart = coreMock.createStart();
261263

262264
{
263265
const plugin = new SpacesPlugin(
264-
coreMock.createPluginInitializerContext(
265-
{ allowSolutionVisibility: true }, // it is true but we are not onCloud
266-
{ buildFlavor: 'traditional' }
267-
)
266+
coreMock.createPluginInitializerContext({ allowSolutionVisibility: false })
268267
);
269268
const spacesSetup = plugin.setup(coreSetup, {});
270269
const spacesStart = plugin.start(coreStart);
271270

272-
expect(spacesSetup.isSolutionViewEnabled).toBe(false); // so it should be false
273-
expect(spacesStart.isSolutionViewEnabled).toBe(false);
274-
}
275-
276-
{
277-
// unless the forceSolutionVisibility flag is set
278-
const plugin = new SpacesPlugin(
279-
coreMock.createPluginInitializerContext(
280-
{ allowSolutionVisibility: false, experimental: { forceSolutionVisibility: true } },
281-
{ buildFlavor: 'traditional' }
282-
)
283-
);
284-
const spacesSetup = plugin.setup(coreSetup, {}); // we are not onCloud but forceSolutionVisibility is true
285-
const spacesStart = plugin.start(coreStart);
286-
287-
expect(spacesSetup.isSolutionViewEnabled).toBe(true);
288-
expect(spacesStart.isSolutionViewEnabled).toBe(true);
289-
}
290-
});
291-
292-
it('when onCloud, not serverless and allowSolutionVisibility is "false"', () => {
293-
const coreSetup = coreMock.createSetup();
294-
const coreStart = coreMock.createStart();
295-
const cloud = cloudMock.createSetup();
296-
cloud.isCloudEnabled = true;
297-
298-
{
299-
const plugin = new SpacesPlugin(
300-
coreMock.createPluginInitializerContext(
301-
{ allowSolutionVisibility: false },
302-
{ buildFlavor: 'traditional' }
303-
)
304-
);
305-
const spacesSetup = plugin.setup(coreSetup, { cloud });
306-
const spacesStart = plugin.start(coreStart);
307-
308271
expect(spacesSetup.isSolutionViewEnabled).toBe(false);
309272
expect(spacesStart.isSolutionViewEnabled).toBe(false);
310273
}
311-
312-
{
313-
// unless the forceSolutionVisibility flag is set
314-
const plugin = new SpacesPlugin(
315-
coreMock.createPluginInitializerContext(
316-
{ allowSolutionVisibility: false, experimental: { forceSolutionVisibility: true } },
317-
{ buildFlavor: 'traditional' }
318-
)
319-
);
320-
const spacesSetup = plugin.setup(coreSetup, { cloud });
321-
const spacesStart = plugin.start(coreStart);
322-
323-
expect(spacesSetup.isSolutionViewEnabled).toBe(true);
324-
expect(spacesStart.isSolutionViewEnabled).toBe(true);
325-
}
326274
});
327275

328-
it('when onCloud and serverless', () => {
276+
it('when allowSolutionVisibility is "undefined"', () => {
329277
const coreSetup = coreMock.createSetup();
330-
const coreStart = coreMock.createStart();
331-
const cloud = cloudMock.createSetup();
332-
cloud.isCloudEnabled = true;
333-
334-
{
335-
const plugin = new SpacesPlugin(
336-
coreMock.createPluginInitializerContext(
337-
{ allowSolutionVisibility: true },
338-
{ buildFlavor: 'serverless' }
339-
)
340-
);
341-
const spacesSetup = plugin.setup(coreSetup, { cloud });
342-
const spacesStart = plugin.start(coreStart);
343278

344-
expect(spacesSetup.isSolutionViewEnabled).toBe(false);
345-
expect(spacesStart.isSolutionViewEnabled).toBe(false);
346-
}
347-
348-
{
349-
// unless the forceSolutionVisibility flag is set
350-
const plugin = new SpacesPlugin(
351-
coreMock.createPluginInitializerContext(
352-
{ allowSolutionVisibility: true, experimental: { forceSolutionVisibility: true } },
353-
{ buildFlavor: 'serverless' }
354-
)
355-
);
356-
const spacesSetup = plugin.setup(coreSetup, { cloud });
357-
const spacesStart = plugin.start(coreStart);
358-
359-
expect(spacesSetup.isSolutionViewEnabled).toBe(true);
360-
expect(spacesStart.isSolutionViewEnabled).toBe(true);
361-
}
279+
const plugin = new SpacesPlugin(
280+
coreMock.createPluginInitializerContext({ allowSolutionVisibility: undefined })
281+
);
282+
expect(() => plugin.setup(coreSetup, {})).toThrowErrorMatchingInlineSnapshot(
283+
`"allowSolutionVisibility has not been set in the Spaces plugin config."`
284+
);
362285
});
363286
});
364287
});

x-pack/plugins/spaces/public/plugin.tsx

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,11 @@ export class SpacesPlugin implements Plugin<SpacesPluginSetup, SpacesPluginStart
5959
}
6060

6161
public setup(core: CoreSetup<PluginsStart, SpacesPluginStart>, plugins: PluginsSetup) {
62-
const hasOnlyDefaultSpace = this.config.maxSpaces === 1;
63-
const onCloud = plugins.cloud !== undefined && plugins.cloud.isCloudEnabled;
62+
if (this.config.allowSolutionVisibility === undefined) {
63+
throw new Error('allowSolutionVisibility has not been set in the Spaces plugin config.');
64+
}
6465

65-
// We only allow "solution" to be set on cloud environments, not on prem
66-
// unless the forceSolutionVisibility flag is set
67-
const allowSolutionVisibility =
68-
(onCloud && !this.isServerless && this.config.allowSolutionVisibility) ||
69-
Boolean(this.config.experimental?.forceSolutionVisibility);
66+
const hasOnlyDefaultSpace = this.config.maxSpaces === 1;
7067

7168
this.spacesManager = new SpacesManager(core.http);
7269
this.spacesApi = {
@@ -77,12 +74,7 @@ export class SpacesPlugin implements Plugin<SpacesPluginSetup, SpacesPluginStart
7774
getActiveSpace$: () => this.spacesManager.onActiveSpaceChange$,
7875
getActiveSpace: () => this.spacesManager.getActiveSpace(),
7976
hasOnlyDefaultSpace,
80-
isSolutionViewEnabled: allowSolutionVisibility,
81-
};
82-
83-
this.config = {
84-
...this.config,
85-
allowSolutionVisibility,
77+
isSolutionViewEnabled: this.config.allowSolutionVisibility,
8678
};
8779

8880
registerSpacesEventTypes(core);
@@ -167,7 +159,7 @@ export class SpacesPlugin implements Plugin<SpacesPluginSetup, SpacesPluginStart
167159

168160
registerAnalyticsContext(core.analytics, this.spacesManager.onActiveSpaceChange$);
169161

170-
return { hasOnlyDefaultSpace, isSolutionViewEnabled: allowSolutionVisibility };
162+
return { hasOnlyDefaultSpace, isSolutionViewEnabled: this.config.allowSolutionVisibility };
171163
}
172164

173165
public start(core: CoreStart) {

x-pack/plugins/spaces/server/index.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@ export const config: PluginConfigDescriptor = {
3434
maxSpaces: true,
3535
allowFeatureVisibility: true,
3636
allowSolutionVisibility: true,
37-
experimental: {
38-
forceSolutionVisibility: true,
39-
},
4037
},
4138
};
4239

x-pack/plugins/spaces/server/plugin.test.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,7 @@ describe('Spaces plugin', () => {
3636
"hasOnlyDefaultSpace$": Observable {
3737
"operator": [Function],
3838
"source": Observable {
39-
"operator": [Function],
40-
"source": Observable {
41-
"_subscribe": [Function],
42-
},
39+
"_subscribe": [Function],
4340
},
4441
},
4542
"spacesClient": Object {
@@ -123,10 +120,7 @@ describe('Spaces plugin', () => {
123120
"hasOnlyDefaultSpace$": Observable {
124121
"operator": [Function],
125122
"source": Observable {
126-
"operator": [Function],
127-
"source": Observable {
128-
"_subscribe": [Function],
129-
},
123+
"_subscribe": [Function],
130124
},
131125
},
132126
"spacesService": Object {

0 commit comments

Comments
 (0)