Skip to content

Commit 4af57b5

Browse files
authored
feat: Changed component to display YAML files to Monaco Editor (#308)
1 parent 33e5876 commit 4af57b5

22 files changed

+550
-461
lines changed

package-lock.json

Lines changed: 281 additions & 327 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"@fastify/static": "8.2.0",
3535
"@fastify/vite": "8.2.0",
3636
"@hookform/resolvers": "5.2.2",
37+
"@monaco-editor/react": "^4.7.0",
3738
"@sentry/node": "10.15.0",
3839
"@sentry/react": "10.15.0",
3940
"@sentry/vite-plugin": "4.3.0",
@@ -54,13 +55,14 @@
5455
"i18next": "25.5.2",
5556
"javascript-time-ago": "2.5.12",
5657
"js-yaml": "4.1.0",
58+
"monaco-editor": "^0.45.0",
59+
"monaco-yaml": "^5.4.0",
5760
"react": "19.1.1",
5861
"react-dom": "19.1.1",
5962
"react-error-boundary": "6.0.0",
6063
"react-hook-form": "7.63.0",
6164
"react-i18next": "16.0.0",
6265
"react-router-dom": "7.9.3",
63-
"react-syntax-highlighter": "15.6.6",
6466
"react-time-ago": "7.3.5",
6567
"swr": "2.3.6",
6668
"yaml": "2.8.1",
@@ -76,7 +78,6 @@
7678
"@types/node": "22.18.6",
7779
"@types/react": "19.1.15",
7880
"@types/react-dom": "19.1.9",
79-
"@types/react-syntax-highlighter": "15.5.13",
8081
"@ui5/webcomponents-cypress-commands": "2.14.1",
8182
"@vitejs/plugin-react": "5.0.4",
8283
"@vitest/eslint-plugin": "1.3.13",
@@ -97,6 +98,7 @@
9798
"typescript": "5.9.2",
9899
"typescript-eslint": "8.44.1",
99100
"vite": "7.1.7",
101+
"vite-plugin-static-copy": "^3.1.2",
100102
"vitest": "3.2.4"
101103
}
102104
}

src/components/ControlPlanes/ControlPlaneCard/ControlPlaneCard.module.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.card {
2-
margin: 0.75rem 0.75rem 0.75rem 0;
2+
margin: 0;
33
}
44

55
.container {

src/components/ControlPlanes/List/ControlPlaneListWorkspaceGridTile.tsx

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Button, FlexBox, Grid, ObjectPageSection, Panel, Title } from '@ui5/webcomponents-react';
1+
import { Button, FlexBox, ObjectPageSection, Panel, Title } from '@ui5/webcomponents-react';
22
import '@ui5/webcomponents-fiori/dist/illustrations/NoData.js';
33
import '@ui5/webcomponents-fiori/dist/illustrations/EmptyList.js';
44
import '@ui5/webcomponents-icons/dist/delete';
@@ -161,16 +161,18 @@ export function ControlPlaneListWorkspaceGridTile({ projectName, workspace }: Pr
161161
}
162162
/>
163163
) : (
164-
<Grid defaultSpan="XL4 L4 M7 S12">
165-
{controlplanes?.map((cp) => (
166-
<ControlPlaneCard
167-
key={`${cp.metadata.name}--${cp.metadata.namespace}`}
168-
controlPlane={cp}
169-
projectName={projectName}
170-
workspace={workspace}
171-
/>
172-
))}
173-
</Grid>
164+
<div className={styles.wrapper}>
165+
<div className={styles.grid}>
166+
{controlplanes?.map((cp) => (
167+
<ControlPlaneCard
168+
key={`${cp.metadata.name}--${cp.metadata.namespace}`}
169+
controlPlane={cp}
170+
projectName={projectName}
171+
workspace={workspace}
172+
/>
173+
))}
174+
</div>
175+
</div>
174176
)}
175177
</Panel>
176178
</ObjectPageSection>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
11
.createButton {
22
margin-bottom: 2rem;
33
}
4+
5+
.wrapper {
6+
margin-top: 0.375rem;
7+
margin-bottom: 0.375rem;
8+
}
9+
10+
.grid {
11+
display: grid;
12+
grid-template-columns: 1fr;
13+
gap: 1.5rem;
14+
@container (width > 768px) {
15+
grid-template-columns: 1fr 1fr;
16+
}
17+
@container (width > 1024px) {
18+
grid-template-columns: 1fr 1fr 1fr;
19+
}
20+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.wrapper {
2+
position: relative;
3+
height: 100%;
4+
}

src/components/Wizards/CreateManagedControlPlane/SummarizeStep.tsx

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ import {
66
ComponentsListItem,
77
CreateManagedControlPlane,
88
} from '../../../lib/api/types/crate/createManagedControlPlane.ts';
9+
910
import YamlPanel from '../../Yaml/YamlPanel.tsx';
1011
import { idpPrefix } from '../../../utils/idpPrefix.ts';
1112
import { UseFormWatch } from 'react-hook-form';
1213
import { CreateDialogProps } from '../../Dialogs/CreateWorkspaceDialogContainer.tsx';
13-
import { YamlDiff } from '../../Yaml/YamlDiff.tsx';
1414

15+
import styles from './SummarizeStep.module.css';
16+
import { YamlDiff } from './YamlDiff.tsx';
1517
interface SummarizeStepProps {
1618
watch: UseFormWatch<CreateDialogProps>;
1719
projectName: string;
@@ -30,9 +32,22 @@ export const SummarizeStep: React.FC<SummarizeStepProps> = ({
3032
isEditMode = false,
3133
}) => {
3234
const { t } = useTranslation();
33-
35+
const yamlString = stringify(
36+
CreateManagedControlPlane(
37+
watch('name'),
38+
`${projectName}--ws-${workspaceName}`,
39+
{
40+
displayName: watch('displayName'),
41+
chargingTarget: watch('chargingTarget'),
42+
members: watch('members'),
43+
componentsList: componentsList ?? [],
44+
chargingTargetType: watch('chargingTargetType'),
45+
},
46+
idpPrefix,
47+
),
48+
);
3449
return (
35-
<>
50+
<div className={styles.wrapper}>
3651
<Title>{t('common.summarize')}</Title>
3752
<Grid defaultSpan="XL6 L6 M6 S6">
3853
<div>
@@ -78,26 +93,10 @@ export const SummarizeStep: React.FC<SummarizeStepProps> = ({
7893
)}
7994
/>
8095
) : (
81-
<YamlPanel
82-
yamlString={stringify(
83-
CreateManagedControlPlane(
84-
watch('name'),
85-
`${projectName}--ws-${workspaceName}`,
86-
{
87-
displayName: watch('displayName'),
88-
chargingTarget: watch('chargingTarget'),
89-
members: watch('members'),
90-
componentsList: componentsList ?? [],
91-
chargingTargetType: watch('chargingTargetType'),
92-
},
93-
idpPrefix,
94-
),
95-
)}
96-
filename={`mcp_${projectName}--ws-${workspaceName}`}
97-
/>
96+
<YamlPanel yamlString={yamlString} filename={`mcp_${projectName}--ws-${workspaceName}`} />
9897
)}
9998
</div>
10099
</Grid>
101-
</>
100+
</div>
102101
);
103102
};
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.container {
2+
position: absolute;
3+
top: 0;
4+
bottom: 0;
5+
width: calc(50% - 2rem);
6+
right: 0;
7+
overflow: hidden;
8+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { FC } from 'react';
2+
3+
import styles from './YamlDiff.module.css';
4+
import { YamlDiffEditor } from '../../YamlEditor/YamlDiffEditor.tsx';
5+
type YamlDiffProps = {
6+
originalYaml: string;
7+
modifiedYaml: string;
8+
};
9+
10+
export const YamlDiff: FC<YamlDiffProps> = ({ originalYaml, modifiedYaml }) => {
11+
return (
12+
<div className={styles.container}>
13+
<YamlDiffEditor original={originalYaml} modified={modifiedYaml} />
14+
</div>
15+
);
16+
};

src/components/Yaml/YamlDiff.module.css

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

0 commit comments

Comments
 (0)