Skip to content

Commit e4d40b8

Browse files
Added perspective switcher with YAML Editor
1 parent 66edc78 commit e4d40b8

2 files changed

Lines changed: 22 additions & 14 deletions

File tree

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,14 @@
8888
"webpack": "^5.68.0",
8989
"@types/react": "17.0.40",
9090
"@patternfly/react-core": "6.2.0",
91+
"@patternfly/react-component-groups": "^6.2.1",
9192
"@patternfly/react-icons": "6.2.0",
9293
"@patternfly/react-table": "6.2.0",
9394
"@patternfly/react-styles": "6.2.0",
9495
"@patternfly/react-tokens": "6.2.0"
9596
},
9697
"dependencies": {
97-
"react-tagsinput": "^3.20.0"
98+
"react-tagsinput": "^3.20.0",
99+
"@patternfly/react-component-groups": "^6.2.1"
98100
}
99101
}

src/views/CronTabForm/CronTabForm.tsx

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
ActionGroup,
77
Button,
88
PageSection,
9-
Title,
109
Alert,
1110
NumberInput,
1211
FormHelperText,
@@ -18,14 +17,18 @@ import {
1817
useK8sModel,
1918
k8sCreate,
2019
useActiveNamespace,
21-
YAMLEditor,
20+
CodeEditor,
2221
} from "@openshift-console/dynamic-plugin-sdk";
2322
import { useNavigate } from "react-router-dom-v5-compat";
2423
import { useCronTabTranslation } from "@crontab-utils/hooks/useCronTabTranslation";
2524
import { cronTabGroupVersionKind } from "src/utils/utils";
2625
import { CronTabKind } from "@crontab-model/types";
2726
import yaml from "js-yaml";
2827
import { defaultCronTabYamlTemplate } from "src/templates/crontab-yaml";
28+
import {
29+
PageHeader,
30+
PageHeaderLinkProps,
31+
} from "@patternfly/react-component-groups";
2932

3033
export const CronTabForm: React.FC = () => {
3134
const [model] = useK8sModel(cronTabGroupVersionKind);
@@ -136,22 +139,25 @@ export const CronTabForm: React.FC = () => {
136139
};
137140

138141
return (
139-
<PageSection>
140-
<Title headingLevel="h1" data-test="page-heading">
141-
{t("Create CronTab")}
142-
</Title>
143-
<Button variant="link" onClick={() => setShowYaml(!showYaml)}>
144-
{showYaml ? t("Form View") : t("YAML Editor")}
145-
</Button>
142+
<PageSection isFilled={true} height="sizeToFit">
143+
<PageHeader
144+
title={t("Create CronTab")}
145+
linkProps={
146+
{
147+
label: showYaml ? t("Form View") : t("YAML Editor"),
148+
onClick: () => setShowYaml(!showYaml),
149+
} as PageHeaderLinkProps
150+
}
151+
/>
146152

147153
{showYaml ? (
148154
<>
149-
<YAMLEditor
155+
<CodeEditor
150156
value={yamlContent}
151-
language="yaml"
152-
onChange={(_e, val) => setYamlContent(val as string)}
153-
minHeight="0"
157+
onChange={(val) => setYamlContent(val)}
158+
// @ts-expect-error TODO: fix this
154159
height="500px"
160+
language="yaml"
155161
options={{
156162
wordWrap: "on",
157163
formatOnPaste: true,

0 commit comments

Comments
 (0)