Skip to content

Commit 12e9fbd

Browse files
[7.x] Reorganizing spaces client-side plugin (#53644) (#54044)
* reorganizing spaces client-side plugin * additional testing and cleanup * address PR feedback * additional cleanup * rename scss file * one more index Co-authored-by: Elastic Machine <[email protected]>
1 parent c0cf11b commit 12e9fbd

File tree

155 files changed

+589
-298
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

155 files changed

+589
-298
lines changed

src/legacy/ui/public/new_platform/new_platform.karma_mock.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ export const npStart = {
148148
legacy: {
149149
getSection: () => ({
150150
register: sinon.fake(),
151+
deregister: sinon.fake(),
152+
hasItem: sinon.fake(),
151153
}),
152154
},
153155
},

x-pack/legacy/plugins/security/public/views/management/edit_role/components/privileges/kibana/space_aware_privilege_section/privilege_matrix.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {
2323
import { FormattedMessage, InjectedIntl } from '@kbn/i18n/react';
2424
import React, { Component, Fragment } from 'react';
2525
import { Space } from '../../../../../../../../../spaces/common/model/space';
26-
import { SpaceAvatar } from '../../../../../../../../../spaces/public/components';
26+
import { SpaceAvatar } from '../../../../../../../../../spaces/public/space_avatar';
2727
import { Feature } from '../../../../../../../../../../../plugins/features/public';
2828
import { FeaturesPrivileges, Role } from '../../../../../../../../common/model';
2929
import { CalculatedPrivilege } from '../../../../../../../lib/kibana_privilege_calculator';

x-pack/legacy/plugins/security/public/views/management/edit_role/components/privileges/kibana/space_aware_privilege_section/privilege_space_table.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
import { FormattedMessage, InjectedIntl } from '@kbn/i18n/react';
1515
import _ from 'lodash';
1616
import React, { Component } from 'react';
17-
import { getSpaceColor } from '../../../../../../../../../spaces/public/lib/space_attributes';
17+
import { getSpaceColor } from '../../../../../../../../../spaces/public/space_avatar';
1818
import { Space } from '../../../../../../../../../spaces/common/model/space';
1919
import {
2020
FeaturesPrivileges,

x-pack/legacy/plugins/security/public/views/management/edit_role/components/privileges/kibana/space_aware_privilege_section/space_selector.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { EuiComboBox, EuiComboBoxOptionProps, EuiHealth, EuiHighlight } from '@e
88
import { InjectedIntl } from '@kbn/i18n/react';
99
import React, { Component } from 'react';
1010
import { Space } from '../../../../../../../../../spaces/common/model/space';
11-
import { getSpaceColor } from '../../../../../../../../../spaces/public/lib/space_attributes';
11+
import { getSpaceColor } from '../../../../../../../../../spaces/public/space_avatar';
1212

1313
const spaceToOption = (space?: Space, currentSelection?: 'global' | 'spaces') => {
1414
if (!space) {

x-pack/legacy/plugins/security/public/views/management/edit_role/components/spaces_popover_list/spaces_popover_list.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ import {
1414
} from '@elastic/eui';
1515
import { FormattedMessage, InjectedIntl } from '@kbn/i18n/react';
1616
import React, { Component } from 'react';
17-
import { SPACE_SEARCH_COUNT_THRESHOLD } from '../../../../../../../spaces/common/constants';
18-
import { Space } from '../../../../../../../spaces/common/model/space';
19-
import { SpaceAvatar } from '../../../../../../../spaces/public/components';
17+
import { SpaceAvatar } from '../../../../../../../spaces/public/space_avatar';
18+
import { SPACE_SEARCH_COUNT_THRESHOLD } from '../../../../../../../../../plugins/spaces/common/constants';
19+
import { Space } from '../../../../../../../../../plugins/spaces/common/model/space';
2020

2121
interface Props {
2222
spaces: Space[];

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ export const spaces = (kibana: Record<string, any>) =>
4949

5050
uiExports: {
5151
styleSheetPaths: resolve(__dirname, 'public/index.scss'),
52-
managementSections: ['plugins/spaces/views/management'],
52+
managementSections: [],
5353
apps: [
5454
{
5555
id: 'space_selector',
5656
title: 'Spaces',
57-
main: 'plugins/spaces/views/space_selector',
57+
main: 'plugins/spaces/space_selector',
5858
url: 'space_selector',
5959
hidden: true,
6060
},
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
import { AdvancedSettingsService } from './advanced_settings_service';
8+
jest.mock('ui/management', () => {
9+
return {
10+
PAGE_TITLE_COMPONENT: 'page_title_component',
11+
PAGE_SUBTITLE_COMPONENT: 'page_subtitle_component',
12+
};
13+
});
14+
15+
describe('Advanced Settings Service', () => {
16+
describe('#setup', () => {
17+
it('registers space-aware components to augment the advanced settings screen', () => {
18+
const deps = {
19+
getActiveSpace: jest.fn().mockResolvedValue({ id: 'foo', name: 'foo-space' }),
20+
registerSettingsComponent: jest.fn(),
21+
};
22+
23+
const advancedSettingsService = new AdvancedSettingsService();
24+
advancedSettingsService.setup(deps);
25+
26+
expect(deps.registerSettingsComponent).toHaveBeenCalledTimes(2);
27+
expect(deps.registerSettingsComponent).toHaveBeenCalledWith(
28+
'page_title_component',
29+
expect.any(Function),
30+
true
31+
);
32+
33+
expect(deps.registerSettingsComponent).toHaveBeenCalledWith(
34+
'page_subtitle_component',
35+
expect.any(Function),
36+
true
37+
);
38+
});
39+
});
40+
});
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
import React from 'react';
7+
import { PAGE_TITLE_COMPONENT, PAGE_SUBTITLE_COMPONENT } from 'ui/management';
8+
import { Space } from '../../common/model/space';
9+
import { AdvancedSettingsTitle, AdvancedSettingsSubtitle } from './components';
10+
11+
interface SetupDeps {
12+
getActiveSpace: () => Promise<Space>;
13+
registerSettingsComponent: (
14+
id: string,
15+
component: string | React.FC<any>,
16+
allowOverride: boolean
17+
) => void;
18+
}
19+
20+
export class AdvancedSettingsService {
21+
public setup({ getActiveSpace, registerSettingsComponent }: SetupDeps) {
22+
const PageTitle = () => <AdvancedSettingsTitle getActiveSpace={getActiveSpace} />;
23+
const SubTitle = () => <AdvancedSettingsSubtitle getActiveSpace={getActiveSpace} />;
24+
25+
registerSettingsComponent(PAGE_TITLE_COMPONENT, PageTitle, true);
26+
registerSettingsComponent(PAGE_SUBTITLE_COMPONENT, SubTitle, true);
27+
}
28+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import { EuiCallOut, EuiSpacer } from '@elastic/eui';
88
import { FormattedMessage } from '@kbn/i18n/react';
99
import React, { Fragment, useState, useEffect } from 'react';
10-
import { Space } from '../../../../../common/model/space';
10+
import { Space } from '../../../../common/model/space';
1111

1212
interface Props {
1313
getActiveSpace: () => Promise<Space>;

0 commit comments

Comments
 (0)