Skip to content

Commit 41e01c2

Browse files
author
Georgi2704
committed
Filter create workflows and ENV loading
1 parent e95c93d commit 41e01c2

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

pages/_app.tsx

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, { useEffect, useState } from 'react';
22

3+
import _ from 'lodash';
34
import { SessionProvider } from 'next-auth/react';
45
import { NextAdapter } from 'next-query-params';
56
import App, { AppContext, AppInitialProps, AppProps } from 'next/app';
@@ -13,17 +14,21 @@ import { EuiThemeAmsterdam } from '@elastic/eui';
1314
import {
1415
ColorModes,
1516
ConfirmationDialogContextWrapper,
17+
Environment,
1618
OrchestratorConfig,
1719
OrchestratorConfigProvider,
20+
ProductLifecycleStatus,
1821
StoreProvider,
1922
WfoAuth,
2023
WfoErrorBoundary,
2124
WfoErrorMonitoring,
2225
WfoErrorMonitoringProvider,
26+
WfoLogoSpinner,
2327
WfoMenuItemLink,
2428
WfoPageTemplate,
2529
WfoToastsList,
2630
defaultOrchestratorTheme,
31+
emptyOrchestratorConfig,
2732
} from '@orchestrator-ui/orchestrator-ui-components';
2833

2934
import { getAppLogo } from '@/components/AppLogo/AppLogo';
@@ -44,6 +49,7 @@ function CustomApp({
4449
const [themeMode, setThemeMode] = useState<EuiThemeColorMode>(
4550
ColorModes.LIGHT,
4651
);
52+
const [loadedConfig, setLoadedConfig] = useState<OrchestratorConfig>();
4753

4854
const handleThemeSwitch = (newThemeMode: EuiThemeColorMode) => {
4955
setThemeMode(newThemeMode);
@@ -62,6 +68,18 @@ function CustomApp({
6268
}
6369
}, []);
6470

71+
useEffect(() => {
72+
if (!_.isEqual(orchestratorConfig, emptyOrchestratorConfig)) {
73+
setLoadedConfig(orchestratorConfig);
74+
}
75+
}, [orchestratorConfig]);
76+
77+
if (!loadedConfig) {
78+
return <WfoLogoSpinner />;
79+
}
80+
81+
const { environmentName } = loadedConfig;
82+
6583
const addMenuItems = (
6684
defaultMenuItems: EuiSideNavItemType<object>[],
6785
): EuiSideNavItemType<object>[] => [
@@ -112,12 +130,21 @@ function CustomApp({
112130
reportMessage: () => {},
113131
};
114132

133+
const startWorkflowFilters =
134+
environmentName === Environment.PRODUCTION
135+
? [ProductLifecycleStatus.ACTIVE]
136+
: [
137+
ProductLifecycleStatus.ACTIVE,
138+
ProductLifecycleStatus.PRE_PRODUCTION,
139+
ProductLifecycleStatus.PHASE_OUT,
140+
];
141+
115142
return (
116143
<WfoErrorBoundary>
117144
<OrchestratorConfigProvider
118-
initialOrchestratorConfig={orchestratorConfig}
145+
initialOrchestratorConfig={loadedConfig}
119146
>
120-
<StoreProvider initialOrchestratorConfig={orchestratorConfig}>
147+
<StoreProvider initialOrchestratorConfig={loadedConfig}>
121148
<SessionProvider session={pageProps.session}>
122149
<WfoErrorMonitoringProvider
123150
errorMonitoringHandler={errorMonitoringHandler}
@@ -149,6 +176,9 @@ function CustomApp({
149176
overrideMenuItems={
150177
addMenuItems
151178
}
179+
overrideStartWorkflowFilters={
180+
startWorkflowFilters
181+
}
152182
>
153183
<QueryParamProvider
154184
adapter={NextAdapter}

0 commit comments

Comments
 (0)