Skip to content

Commit 12ec282

Browse files
committed
wip
1 parent 518e1fd commit 12ec282

31 files changed

+9873
-58
lines changed

web/console-extensions.json

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,5 +287,60 @@
287287
"$codeRef": "netflowDevTab.default"
288288
}
289289
}
290+
},
291+
{
292+
"type": "console.yaml-template",
293+
"properties": {
294+
"model": {
295+
"version": "v1beta2",
296+
"group": "flows.netobserv.io",
297+
"kind": "FlowCollector"
298+
},
299+
"name": "default",
300+
"template": {
301+
"$codeRef": "yamlTemplates.FlowCollector"
302+
}
303+
}
304+
},
305+
{
306+
"type": "console.page/route",
307+
"properties": {
308+
"path": "/k8s/cluster/flows.netobserv.io~v1beta2~FlowCollector/~new/form",
309+
"component": {
310+
"$codeRef": "flowCollectorForm.default"
311+
}
312+
}
313+
},
314+
{
315+
"type": "console.yaml-template",
316+
"properties": {
317+
"model": {
318+
"version": "v1alpha1",
319+
"group": "flows.netobserv.io",
320+
"kind": "FlowMetric"
321+
},
322+
"name": "default",
323+
"template": {
324+
"$codeRef": "yamlTemplates.FlowMetric"
325+
}
326+
}
327+
},
328+
{
329+
"type": "console.page/route",
330+
"properties": {
331+
"path": "/k8s/cluster/flows.netobserv.io~v1alpha1~FlowMetric/~new/form",
332+
"component": {
333+
"$codeRef": "flowMetricForm.default"
334+
}
335+
}
336+
},
337+
{
338+
"type": "console.page/route",
339+
"properties": {
340+
"path": "/k8s/cluster/flows.netobserv.io~v1beta2~FlowCollector/~new/wizard",
341+
"component": {
342+
"$codeRef": "wizard.default"
343+
}
344+
}
290345
}
291346
]

web/locales/en/plugin__netobserv-plugin.json

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,41 @@
159159
"M": "M",
160160
"S": "S",
161161
"XS": "XS",
162+
"There is some issue in this form view. Please select \"YAML view\" for full control.": "There is some issue in this form view. Please select \"YAML view\" for full control.",
163+
"Note: Some fields may not be represented in this form view. Please select \"YAML view\" for full control.": "Note: Some fields may not be represented in this form view. Please select \"YAML view\" for full control.",
164+
"Advanced configuration": "Advanced configuration",
165+
"Remove {{singularLabel}}": "Remove {{singularLabel}}",
166+
"Add {{singularLabel}}": "Add {{singularLabel}}",
167+
"Error": "Error",
168+
"Fix the following errors:": "Fix the following errors:",
169+
"true": "true",
170+
"Decrement": "Decrement",
171+
"Increment": "Increment",
172+
"Select {{title}}": "Select {{title}}",
173+
"Configure via:": "Configure via:",
174+
"Form view": "Form view",
175+
"YAML view": "YAML view",
176+
"This object has been updated.": "This object has been updated.",
177+
"Click reload to see the new version.": "Click reload to see the new version.",
178+
"Create": "Create",
179+
"Reload": "Reload",
180+
"Cancel": "Cancel",
181+
"Unable to get {{kind}}": "Unable to get {{kind}}",
182+
"Update {{kind}}": "Update {{kind}}",
183+
"Create {{kind}}": "Create {{kind}}",
184+
"Update by completing the form. Current values are from the existing resource.": "Update by completing the form. Current values are from the existing resource.",
185+
"Create by completing the form. Default values are provided as example.": "Create by completing the form. Default values are provided as example.",
186+
"FlowCollector step by step configuration": "FlowCollector step by step configuration",
187+
"Capture": "Capture",
188+
"Filters": "Filters",
189+
"Options": "Options",
190+
"Pipeline": "Pipeline",
191+
"Storage": "Storage",
192+
"Exporters": "Exporters",
193+
"IPFIX": "IPFIX",
194+
"Kafka": "Kafka",
195+
"Open Telemetry": "Open Telemetry",
196+
"Review": "Review",
162197
"Step {{index}}/{{count}}": "Step {{index}}/{{count}}",
163198
"Step {{index}}/{{count}}_plural": "Step {{index}}/{{count}}",
164199
"Previous tip": "Previous tip",
@@ -231,7 +266,6 @@
231266
"Unselect all": "Unselect all",
232267
"Select all": "Select all",
233268
"Restore default columns": "Restore default columns",
234-
"Cancel": "Cancel",
235269
"At least one column must be selected": "At least one column must be selected",
236270
"Save": "Save",
237271
"Export": "Export",

web/moduleMapper/dummy.tsx

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
1+
/* eslint-disable @typescript-eslint/no-explicit-any */
2+
import {
3+
K8sGroupVersionKind,
4+
K8sModel,
5+
K8sResourceKindReference,
6+
ResourceIconProps,
7+
ResourceLinkProps,
8+
ResourceYAMLEditorProps
9+
} from '@openshift-console/dynamic-plugin-sdk';
10+
import { CodeEditor, Language } from '@patternfly/react-code-editor';
111
import * as React from 'react';
2-
import { ResourceIconProps, ResourceLinkProps } from '@openshift-console/dynamic-plugin-sdk';
312
import { useK8sModelsWithColors } from '../src/utils/k8s-models-hook';
13+
import { useTheme } from '../src/utils/theme-hook';
14+
import { safeJSToYAML } from '../src/utils/yaml';
415
import { k8sModels } from './k8s-models';
516

617
// This dummy file is used to resolve @Console imports from @openshift-console for JEST / Standalone
@@ -35,6 +46,42 @@ export function useK8sModels() {
3546
]
3647
}
3748

49+
export function getK8sModel(k8s: any, k8sGroupVersionKind?: K8sResourceKindReference | K8sGroupVersionKind): K8sModel {
50+
const models = Object.keys(k8sModels);
51+
52+
for (let i = 0; i < models.length; i++) {
53+
const model = (k8sModels as any)[models[i]];
54+
if (model.kind === k8s.kind) {
55+
return model;
56+
}
57+
}
58+
59+
return {
60+
abbr: '',
61+
kind: '',
62+
label: '',
63+
labelPlural: '',
64+
plural: '',
65+
apiVersion: ''
66+
};
67+
}
68+
69+
export function k8sGet(k8s: any): Promise<any> {
70+
return Promise.resolve(k8s);
71+
}
72+
73+
export function k8sCreate(k8s: any): Promise<any> {
74+
return Promise.resolve(k8s);
75+
}
76+
77+
export function k8sUpdate(k8s: any): Promise<any> {
78+
return Promise.resolve(k8s);
79+
}
80+
81+
export function useK8sWatchResource(req: any) {
82+
return [null, true, null];
83+
}
84+
3885
export const ResourceIcon: React.FC<ResourceIconProps> = ({
3986
className,
4087
kind,
@@ -80,4 +127,27 @@ export const ResourceLink: React.FC<ResourceLinkProps> = ({
80127
{children}
81128
</span>
82129
);
83-
};
130+
};
131+
132+
export const ResourceYAMLEditor: React.FC<ResourceYAMLEditorProps> = ({
133+
initialResource,
134+
header,
135+
onSave,
136+
}) => {
137+
const isDarkTheme = useTheme();
138+
const containerHeight = document.getElementById("editor-content-container")?.clientHeight || 400;
139+
const footerHeight = document.getElementById("editor-toggle-footer")?.clientHeight || 0;
140+
return (<>
141+
<CodeEditor
142+
isDarkTheme={isDarkTheme}
143+
isLineNumbersVisible={true}
144+
isReadOnly={false}
145+
isMinimapVisible={true}
146+
isLanguageLabelVisible
147+
code={safeJSToYAML(initialResource)}
148+
language={Language.yaml}
149+
height={`${containerHeight - footerHeight}px`}
150+
onChange={(value) => onSave && onSave(value)}
151+
/>
152+
</>);
153+
};

0 commit comments

Comments
 (0)