Skip to content

Commit 960caf9

Browse files
SiddharthMantrikibanamachineelasticmachine
authored
[Platform security] Replace SCSS with CSS in JS (Part 1 - Spaces plugin) (#214798)
## Summary Part of #211652 Removed most SASS files from the Spaces plugin. (Full checklist on parent issue) Remaining file: `x-pack/platform/plugins/shared/spaces/public/space_selector/space_selector.scss` This file requires a custom mixin that we'll need to migrate once this PR: https://github.com/elastic/kibana/pull/214729/files lands. It introduces a `cssUtils` file to ensure consistency in Kibana specific mixins. ### How to test Testing visual regression isn't super straightforward here. For my local testing, i started two instances of Kibana (main and this branch) On main: - Start es: ``` yarn es snapshot --license=trial -E http.port=9400 ``` - Start kibana with the following config (CLI or kibana.dev.yml) ``` server.port: 5602 elasticsearch.hosts: ["http://localhost:9400"] ``` Once started, in a private browsing window, you should have access to Kibana on main on `localhost:5602` On this PR: Start ES and Kibana normally (Kibana should be available on localhost:5601) This PR contains changes to the following parts of the Spaces plugin: - Copy Saved Objects to Space flyout - Share Saved Objects to Space flyout - Space selector screen - Space editing screen - Space selector drop down menu in Nav Bar Ideally, you should see no visual regression between the two versions. ## Screenshots | Component | Main | PR | |--------|--------|--------| | Space Edit | <img width="300" alt="space_edit_main" src="https://github.com/user-attachments/assets/786feeb7-5047-443c-bb63-41e90e31a82b" /> | <img width="300" alt="space_edit_pr" src="https://github.com/user-attachments/assets/975cc096-25d7-4bd5-804d-f82f65a908bf" /> | | Space selector nav bar | <img width="300" alt="space_selector_nav_bar_main" src="https://github.com/user-attachments/assets/c6c05d28-3dfa-43c2-9586-b66a24f990d6" /> | <img width="317" alt="Screenshot 2025-03-20 at 09 11 50" src="https://github.com/user-attachments/assets/277d3094-640b-4604-adc7-5c8465aeb21c" /> | | Share to space | <img width="300" alt="share_to_space_main" src="https://github.com/user-attachments/assets/5782a314-66f7-4780-bcfb-b0a85cece035" /> | <img width="300" alt="share_to_space_pr" src="https://github.com/user-attachments/assets/73a48305-7fa7-4637-9856-60461cbad770" /> | | Copy to Space flyout | <img width="300" alt="copy_to_space_pr" src="https://github.com/user-attachments/assets/54342ca2-b2e1-4844-a66f-fae512ff8910" /> | <img width="300" alt="copy_to_space_main" src="https://github.com/user-attachments/assets/a629f12a-75c4-4ba6-a7cf-cdeca1310ef3" /> | | Copy to Space confirmation | <img width="300" alt="copy_to_space_confirmed_main" src="https://github.com/user-attachments/assets/78f93d73-e789-487f-94c1-eebcef7ce183" /> | <img width="300" alt="copy_to_space_confirmed_pr" src="https://github.com/user-attachments/assets/2020e71a-88b4-4107-9b05-ae90bf7d39f1" /> | | Space selector | <img width="300" alt="Space_selector_before" src="https://github.com/user-attachments/assets/b8ed7269-e6f6-4bc0-bb24-1c53ac451083" /> | <img width="300" alt="Space_selector_after" src="https://github.com/user-attachments/assets/770d2141-8642-483f-b72c-bce6d5ebd282" /> | ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) ### Identify risks Does this PR introduce any risks? For example, consider risks like hard to test bugs, performance regression, potential of data loss. Describe the risk, its severity, and mitigation for each identified risk. Invite stakeholders and evaluate how to proceed before merging. - [x] The risk of inexact conversion: verifying this PR requires manual checks to ensure that the conversion has not created any regressions in the style. --------- Co-authored-by: kibanamachine <[email protected]> Co-authored-by: Elastic Machine <[email protected]>
1 parent bce77d7 commit 960caf9

34 files changed

+357
-316
lines changed

x-pack/platform/plugins/shared/spaces/public/copy_saved_objects_to_space/components/copy_status_summary_indicator.scss

Lines changed: 0 additions & 7 deletions
This file was deleted.

x-pack/platform/plugins/shared/spaces/public/copy_saved_objects_to_space/components/copy_status_summary_indicator.tsx

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
* 2.0.
66
*/
77

8-
import './copy_status_summary_indicator.scss';
9-
10-
import { EuiBadge, EuiIconTip, EuiLoadingSpinner } from '@elastic/eui';
8+
import { EuiBadge, EuiIconTip, EuiLoadingSpinner, useEuiTheme } from '@elastic/eui';
9+
import { css } from '@emotion/react';
1110
import React, { Fragment } from 'react';
1211

1312
import { FormattedMessage } from '@kbn/i18n-react';
@@ -26,7 +25,8 @@ interface Props {
2625
onDestinationMapChange: (value?: Map<string, string>) => void;
2726
}
2827

29-
const renderIcon = (props: Props) => {
28+
const CopyStatusIcon = (props: Props) => {
29+
const { euiTheme } = useEuiTheme();
3030
const {
3131
space,
3232
summarizedCopyResult,
@@ -83,7 +83,11 @@ const renderIcon = (props: Props) => {
8383
}
8484

8585
const missingReferences = hasMissingReferences ? (
86-
<span className="spcCopyToSpace__missingReferencesIcon">
86+
<span
87+
css={css`
88+
margin-left: ${euiTheme.size.xs};
89+
`}
90+
>
8791
<EuiIconTip
8892
type={'link'}
8993
color={'warning'}
@@ -134,11 +138,15 @@ const renderIcon = (props: Props) => {
134138

135139
export const CopyStatusSummaryIndicator = (props: Props) => {
136140
const { summarizedCopyResult } = props;
137-
141+
const { euiTheme } = useEuiTheme();
138142
return (
139143
<Fragment>
140-
{renderIcon(props)}
141-
<EuiBadge className="spcCopyToSpace__summaryCountBadge">
144+
<CopyStatusIcon {...props} />
145+
<EuiBadge
146+
css={css`
147+
margin-left: ${euiTheme.size.xs};
148+
`}
149+
>
142150
{summarizedCopyResult.objects.length}
143151
</EuiBadge>
144152
</Fragment>

x-pack/platform/plugins/shared/spaces/public/copy_saved_objects_to_space/components/resolve_all_conflicts.scss

Lines changed: 0 additions & 4 deletions
This file was deleted.

x-pack/platform/plugins/shared/spaces/public/copy_saved_objects_to_space/components/resolve_all_conflicts.test.tsx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,9 @@ describe('ResolveAllConflicts', () => {
8989
<EuiPopover
9090
anchorPosition="downLeft"
9191
button={
92-
<EuiLink
93-
className="spcCopyToSpace__resolveAllConflictsLink"
94-
onClick={[Function]}
95-
>
96-
<Memo(MemoizedFormattedMessage)
97-
defaultMessage="(resolve all)"
98-
id="xpack.spaces.management.copyToSpace.resolveAllConflictsLink"
99-
/>
100-
</EuiLink>
92+
<ResolveAllButton
93+
onButtonClick={[Function]}
94+
/>
10195
}
10296
closePopover={[Function]}
10397
display="inline-block"

x-pack/platform/plugins/shared/spaces/public/copy_saved_objects_to_space/components/resolve_all_conflicts.tsx

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

8-
import './resolve_all_conflicts.scss';
9-
10-
import { EuiContextMenuItem, EuiContextMenuPanel, EuiLink, EuiPopover } from '@elastic/eui';
8+
import {
9+
EuiContextMenuItem,
10+
EuiContextMenuPanel,
11+
EuiLink,
12+
EuiPopover,
13+
useEuiFontSize,
14+
} from '@elastic/eui';
15+
import { css } from '@emotion/react';
1116
import React, { Component } from 'react';
1217

1318
import { i18n } from '@kbn/i18n';
@@ -47,20 +52,34 @@ const options: ResolveOption[] = [
4752
},
4853
];
4954

55+
interface ResolveAllButtonProps {
56+
onButtonClick: () => void;
57+
}
58+
59+
const ResolveAllButton = ({ onButtonClick }: ResolveAllButtonProps) => {
60+
const { fontSize } = useEuiFontSize('s');
61+
return (
62+
<EuiLink
63+
onClick={onButtonClick}
64+
css={css`
65+
font-size: ${fontSize};
66+
`}
67+
>
68+
<FormattedMessage
69+
id="xpack.spaces.management.copyToSpace.resolveAllConflictsLink"
70+
defaultMessage="(resolve all)"
71+
/>
72+
</EuiLink>
73+
);
74+
};
75+
5076
export class ResolveAllConflicts extends Component<ResolveAllConflictsProps, State> {
5177
public state = {
5278
isPopoverOpen: false,
5379
};
5480

5581
public render() {
56-
const button = (
57-
<EuiLink onClick={this.onButtonClick} className={'spcCopyToSpace__resolveAllConflictsLink'}>
58-
<FormattedMessage
59-
id="xpack.spaces.management.copyToSpace.resolveAllConflictsLink"
60-
defaultMessage="(resolve all)"
61-
/>
62-
</EuiLink>
63-
);
82+
const button = <ResolveAllButton onButtonClick={this.onButtonClick} />;
6483

6584
const items = options.map((item) => {
6685
return (

x-pack/platform/plugins/shared/spaces/public/copy_saved_objects_to_space/components/selectable_spaces_control.scss

Lines changed: 0 additions & 3 deletions
This file was deleted.

x-pack/platform/plugins/shared/spaces/public/copy_saved_objects_to_space/components/selectable_spaces_control.tsx

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

8-
import './selectable_spaces_control.scss';
9-
108
import type { EuiSelectableOption } from '@elastic/eui';
11-
import { EuiIconTip, EuiLoadingSpinner, EuiSelectable } from '@elastic/eui';
9+
import { EuiIconTip, EuiLoadingSpinner, EuiSelectable, useEuiTheme } from '@elastic/eui';
10+
import { css } from '@emotion/react';
1211
import React, { lazy, Suspense } from 'react';
1312

1413
import { FormattedMessage } from '@kbn/i18n-react';
@@ -33,6 +32,7 @@ interface Props {
3332
type SpaceOption = EuiSelectableOption & { ['data-space-id']: string };
3433

3534
export const SelectableSpacesControl = (props: Props) => {
35+
const { euiTheme } = useEuiTheme();
3636
if (props.spaces.length === 0) {
3737
return <EuiLoadingSpinner />;
3838
}
@@ -81,7 +81,9 @@ export const SelectableSpacesControl = (props: Props) => {
8181
listProps={{
8282
bordered: true,
8383
rowHeight: 40,
84-
className: 'spcCopyToSpace__spacesList',
84+
css: css`
85+
margin-top: ${euiTheme.size.xs};
86+
`,
8587
'data-test-subj': 'cts-form-space-selector',
8688
}}
8789
searchable={options.length > SPACE_SEARCH_COUNT_THRESHOLD}

x-pack/platform/plugins/shared/spaces/public/copy_saved_objects_to_space/components/space_result.scss

Lines changed: 0 additions & 4 deletions
This file was deleted.

x-pack/platform/plugins/shared/spaces/public/copy_saved_objects_to_space/components/space_result.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
* 2.0.
66
*/
77

8-
import './space_result.scss';
9-
108
import {
119
EuiAccordion,
1210
EuiFlexGroup,
1311
EuiFlexItem,
1412
EuiLoadingSpinner,
1513
EuiSpacer,
1614
EuiText,
15+
useEuiTheme,
1716
} from '@elastic/eui';
17+
import { css } from '@emotion/react';
1818
import React, { lazy, Suspense, useState } from 'react';
1919

2020
import { CopyStatusSummaryIndicator } from './copy_status_summary_indicator';
@@ -47,12 +47,15 @@ const getInitialDestinationMap = (objects: SummarizedCopyToSpaceResult['objects'
4747

4848
export const SpaceResultProcessing = (props: Pick<Props, 'space'>) => {
4949
const { space } = props;
50-
50+
const { euiTheme } = useEuiTheme();
5151
return (
5252
<EuiAccordion
5353
id={`copyToSpace-${space.id}`}
5454
data-test-subj={`cts-space-result-${space.id}`}
55-
className="spcCopyToSpaceResult"
55+
css={css`
56+
padding-bottom: ${euiTheme.size.s};
57+
border-bottom: ${euiTheme.border.thin};
58+
`}
5659
buttonContent={
5760
<EuiFlexGroup responsive={false}>
5861
<EuiFlexItem grow={false}>
@@ -82,12 +85,16 @@ export const SpaceResult = (props: Props) => {
8285
const onDestinationMapChange = (value?: Map<string, string>) => {
8386
setDestinationMap(value || getInitialDestinationMap(objects));
8487
};
88+
const { euiTheme } = useEuiTheme();
8589

8690
return (
8791
<EuiAccordion
8892
id={`copyToSpace-${space.id}`}
8993
data-test-subj={`cts-space-result-${space.id}`}
90-
className="spcCopyToSpaceResult"
94+
css={css`
95+
padding-bottom: ${euiTheme.size.s};
96+
border-bottom: ${euiTheme.border.thin};
97+
`}
9198
buttonContent={
9299
<EuiFlexGroup responsive={false}>
93100
<EuiFlexItem grow={false}>

x-pack/platform/plugins/shared/spaces/public/copy_saved_objects_to_space/components/space_result_details.scss

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)