Skip to content

Commit 28d93a4

Browse files
committed
wip
1 parent 518e1fd commit 28d93a4

34 files changed

+10149
-64
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: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,40 @@
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+
"Enabled": "Enabled",
170+
"Disabled": "Disabled",
171+
"Select {{title}}": "Select {{title}}",
172+
"Configure via:": "Configure via:",
173+
"Form view": "Form view",
174+
"YAML view": "YAML view",
175+
"This object has been updated.": "This object has been updated.",
176+
"Click reload to see the new version.": "Click reload to see the new version.",
177+
"Create": "Create",
178+
"Reload": "Reload",
179+
"Cancel": "Cancel",
180+
"Update {{kind}}": "Update {{kind}}",
181+
"Create {{kind}}": "Create {{kind}}",
182+
"Update by completing the form. Current values are from the existing resource.": "Update by completing the form. Current values are from the existing resource.",
183+
"Create by completing the form. Default values are provided as example.": "Create by completing the form. Default values are provided as example.",
184+
"Unable to get {{kind}}": "Unable to get {{kind}}",
185+
"Network Observability setup": "Network Observability setup",
186+
"Overview": "Overview",
187+
"Network Observability Operator deploys a monitoring pipeline that consists in:\n - an eBPF agent, that generates network flows from captured packets\n - flowlogs-pipeline, a component that collects, enriches and exports these flows\n - a Console plugin for flows visualization with powerful filtering options, a topology representation and more\n\nFlow data is then available in multiple ways, each optional:\n - As Prometheus metrics\n - As raw flow logs stored in Grafana Loki\n - As raw flow logs exported to a collector\n\nThe FlowCollector resource is used to configure the operator and its managed components.\nThis setup will guide you on the common aspects of the FlowCollector configuration.": "Network Observability Operator deploys a monitoring pipeline that consists in:\n - an eBPF agent, that generates network flows from captured packets\n - flowlogs-pipeline, a component that collects, enriches and exports these flows\n - a Console plugin for flows visualization with powerful filtering options, a topology representation and more\n\nFlow data is then available in multiple ways, each optional:\n - As Prometheus metrics\n - As raw flow logs stored in Grafana Loki\n - As raw flow logs exported to a collector\n\nThe FlowCollector resource is used to configure the operator and its managed components.\nThis setup will guide you on the common aspects of the FlowCollector configuration.",
188+
"Operator configuration": "Operator configuration",
189+
"Capture": "Capture",
190+
"Filters": "Filters",
191+
"Options": "Options",
192+
"Pipeline": "Pipeline",
193+
"Storage": "Storage",
194+
"Integration": "Integration",
195+
"Review": "Review",
162196
"Step {{index}}/{{count}}": "Step {{index}}/{{count}}",
163197
"Step {{index}}/{{count}}_plural": "Step {{index}}/{{count}}",
164198
"Previous tip": "Previous tip",
@@ -231,7 +265,6 @@
231265
"Unselect all": "Unselect all",
232266
"Select all": "Select all",
233267
"Restore default columns": "Restore default columns",
234-
"Cancel": "Cancel",
235268
"At least one column must be selected": "At least one column must be selected",
236269
"Save": "Save",
237270
"Export": "Export",
@@ -351,7 +384,6 @@
351384
"Pin this element": "Pin this element",
352385
"Could not fetch drop information": "Could not fetch drop information",
353386
"Sorry, 3D view is not implemented anymore.": "Sorry, 3D view is not implemented anymore.",
354-
"Overview": "Overview",
355387
"Traffic flows": "Traffic flows",
356388
"Topology": "Topology",
357389
"Hide histogram": "Hide histogram",

web/moduleMapper/dummy.tsx

Lines changed: 76 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,46 @@ 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+
console.log("k8sGet", k8s);
71+
return Promise.resolve(k8s);
72+
}
73+
74+
export function k8sCreate(k8s: any): Promise<any> {
75+
console.log("k8sCreate", k8s);
76+
return Promise.resolve(k8s);
77+
}
78+
79+
export function k8sUpdate(k8s: any): Promise<any> {
80+
console.log("k8sUpdate", k8s);
81+
return Promise.resolve(k8s);
82+
}
83+
84+
export function useK8sWatchResource(req: any) {
85+
console.log("useK8sWatchResource", req);
86+
return [null, true, null];
87+
}
88+
3889
export const ResourceIcon: React.FC<ResourceIconProps> = ({
3990
className,
4091
kind,
@@ -80,4 +131,27 @@ export const ResourceLink: React.FC<ResourceLinkProps> = ({
80131
{children}
81132
</span>
82133
);
83-
};
134+
};
135+
136+
export const ResourceYAMLEditor: React.FC<ResourceYAMLEditorProps> = ({
137+
initialResource,
138+
header,
139+
onSave,
140+
}) => {
141+
const isDarkTheme = useTheme();
142+
const containerHeight = document.getElementById("editor-content-container")?.clientHeight || 800;
143+
const footerHeight = document.getElementById("editor-toggle-footer")?.clientHeight || 0;
144+
return (<>
145+
<CodeEditor
146+
isDarkTheme={isDarkTheme}
147+
isLineNumbersVisible={true}
148+
isReadOnly={false}
149+
isMinimapVisible={true}
150+
isLanguageLabelVisible
151+
code={safeJSToYAML(initialResource)}
152+
language={Language.yaml}
153+
height={`${containerHeight - footerHeight}px`}
154+
onChange={(value) => onSave && onSave(value)}
155+
/>
156+
</>);
157+
};

0 commit comments

Comments
 (0)