Skip to content

Commit 3aeaa32

Browse files
committed
fix standalone
1 parent ad75014 commit 3aeaa32

File tree

6 files changed

+24
-27
lines changed

6 files changed

+24
-27
lines changed

web/moduleMapper/dummy.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import { NamespaceBarProps, ResourceIconProps, ResourceLinkProps } from '@openshift-console/dynamic-plugin-sdk';
12
import * as React from 'react';
2-
import { ResourceIconProps, ResourceLinkProps } from '@openshift-console/dynamic-plugin-sdk';
33
import { useK8sModelsWithColors } from '../src/utils/k8s-models-hook';
44
import { k8sModels } from './k8s-models';
55

@@ -80,4 +80,12 @@ export const ResourceLink: React.FC<ResourceLinkProps> = ({
8080
{children}
8181
</span>
8282
);
83-
};
83+
};
84+
85+
export const NamespaceBar: React.FC<NamespaceBarProps> = ({
86+
children
87+
}) => {
88+
return (
89+
<div>{children}</div>
90+
)
91+
};

web/src/app.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { BrowserRouter, Link } from 'react-router-dom';
2929
import NetflowTrafficDevTab from './components/netflow-traffic-dev-tab';
3030
import NetflowTrafficParent from './components/netflow-traffic-parent';
3131
import NetflowTab from './components/netflow-traffic-tab';
32+
import { ContextSingleton } from './utils/context';
3233

3334
export const pages = [
3435
{
@@ -61,6 +62,7 @@ export const App: React.FunctionComponent = () => {
6162
const [isSidebarOpen, setIsSidebarOpen] = React.useState(true);
6263
const [pageIndex, setPageIndex] = React.useState(0);
6364
const [isDark, setDark] = React.useState(false);
65+
ContextSingleton.setStandalone();
6466

6567
const onSidebarToggle = () => {
6668
setIsSidebarOpen(!isSidebarOpen);

web/src/components/netflow-traffic.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export const NetflowTraffic: React.FC<NetflowTrafficProps> = ({
7979
const { t } = useTranslation('plugin__netobserv-plugin');
8080
const isDarkTheme = useTheme();
8181
const [extensions] = useResolvedExtensions<ModelFeatureFlag>(isModelFeatureFlag);
82-
ContextSingleton.setContext(extensions, forcedNamespace);
82+
ContextSingleton.setContext(forcedNamespace);
8383

8484
const model = netflowTrafficModel();
8585

web/src/utils/context.ts

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
import {
2-
ExtensionK8sModel,
3-
K8sModel,
4-
ModelFeatureFlag,
5-
ResolvedExtension
6-
} from '@openshift-console/dynamic-plugin-sdk';
7-
import _ from 'lodash';
1+
import { K8sModel } from '@openshift-console/dynamic-plugin-sdk';
82
import { ScopeConfigDef } from '../model/scope';
93

104
export const DEFAULT_HOST = '/api/proxy/plugin/netobserv-plugin/backend';
@@ -28,22 +22,15 @@ export class ContextSingleton {
2822
return ContextSingleton.instance;
2923
}
3024

31-
public static setContext(
32-
extensions: ResolvedExtension<
33-
ModelFeatureFlag,
34-
{
35-
flag: string;
36-
model: ExtensionK8sModel;
37-
}
38-
>[],
39-
forcedNamespace?: string
40-
) {
41-
const isStandalone = (!_.isEmpty(extensions) && extensions[0]?.flags?.required?.includes('dummy')) || false;
25+
public static setStandalone() {
4226
const instance = ContextSingleton.getInstance();
43-
instance.isStandalone = isStandalone;
44-
if (isStandalone) {
45-
instance.host = '';
46-
} else {
27+
instance.isStandalone = true;
28+
instance.host = '';
29+
}
30+
31+
public static setContext(forcedNamespace?: string) {
32+
const instance = ContextSingleton.getInstance();
33+
if (!instance.isStandalone) {
4734
instance.host = DEFAULT_HOST;
4835
}
4936
instance.forcedNamespace = forcedNamespace;

web/webpack.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ module.exports = {
7878
},
7979
proxy: [
8080
{
81-
context: ['/api'],
81+
context: ['/api', '/role'],
8282
target: 'http://localhost:9000',
8383
router: () => 'http://localhost:9002',
8484
logLevel: 'debug' /*optional*/

web/webpack.standalone.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ module.exports = {
6565
},
6666
proxy: [
6767
{
68-
context: ['/api'],
68+
context: ['/api', '/role'],
6969
target: 'http://localhost:9000',
7070
router: () => 'http://localhost:9002',
7171
logLevel: 'debug' /*optional*/

0 commit comments

Comments
 (0)