Skip to content

Commit ae18346

Browse files
committed
[Spaces] Manage Space: features picker is shown only when solution is set to "classic"
1 parent 3f4c279 commit ae18346

File tree

2 files changed

+51
-4
lines changed

2 files changed

+51
-4
lines changed

Diff for: x-pack/plugins/spaces/public/management/edit_space/manage_space_page.test.tsx

+45
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,51 @@ describe('ManageSpacePage', () => {
237237
expect(wrapper.find(EnabledFeatures)).toHaveLength(0);
238238
});
239239

240+
it('hides feature visibility controls when solution view is not "classic"', async () => {
241+
const spacesManager = spacesManagerMock.create();
242+
243+
const wrapper = mountWithIntl(
244+
<ManageSpacePage
245+
spacesManager={spacesManager}
246+
getFeatures={featuresStart.getFeatures}
247+
notifications={notificationServiceMock.createStartContract()}
248+
history={history}
249+
capabilities={{
250+
navLinks: {},
251+
management: {},
252+
catalogue: {},
253+
spaces: { manage: true },
254+
}}
255+
eventTracker={eventTracker}
256+
allowFeatureVisibility
257+
allowSolutionVisibility
258+
/>
259+
);
260+
261+
await waitFor(async () => {
262+
await Promise.resolve();
263+
264+
wrapper.update();
265+
266+
// default for create space: expect visible features table to exist
267+
expect(wrapper.find(EnabledFeatures)).toHaveLength(1);
268+
});
269+
270+
await waitFor(() => {
271+
// switch to observability view
272+
updateSpace(wrapper, false, 'oblt');
273+
// expect visible features table to not exist
274+
expect(wrapper.find(EnabledFeatures)).toHaveLength(0);
275+
});
276+
277+
await waitFor(() => {
278+
// switch to classic
279+
updateSpace(wrapper, false, 'classic');
280+
// expect visible features table to exist again
281+
expect(wrapper.find(EnabledFeatures)).toHaveLength(1);
282+
});
283+
});
284+
240285
it('allows a space to be updated', async () => {
241286
const spaceToUpdate = {
242287
id: 'existing-space',

Diff for: x-pack/plugins/spaces/public/management/edit_space/manage_space_page.tsx

+6-4
Original file line numberDiff line numberDiff line change
@@ -351,11 +351,13 @@ export class ManageSpacePage extends Component<Props, State> {
351351
};
352352

353353
private onSolutionViewChange = (space: Partial<Space>) => {
354-
let showVisibleFeaturesPicker = false;
355-
if (space.solution === 'classic' || space.solution == null) {
356-
showVisibleFeaturesPicker = true;
354+
if (this.props.allowFeatureVisibility) {
355+
let showVisibleFeaturesPicker = false;
356+
if (space.solution === 'classic' || space.solution == null) {
357+
showVisibleFeaturesPicker = true;
358+
}
359+
this.setState((state) => ({ ...state, showVisibleFeaturesPicker }));
357360
}
358-
this.setState((state) => ({ ...state, showVisibleFeaturesPicker }));
359361
this.onSpaceChange(space);
360362
};
361363

0 commit comments

Comments
 (0)