Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Top level masonry refactor #771

Merged
merged 4 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"workspaces": {
"packages": [
"packages/*",
"packages/**",
"website"
]
},
Expand Down
1 change: 0 additions & 1 deletion packages/components/src/AppInfo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export const INFO_WINDOW_WIDTH = 260;
const useStyles = makeStyles((theme: Theme) => ({
infoIcon: {
cursor: 'pointer',
marginLeft: theme.spacing(1),
backgroundColor: 'initial',
},
closeButton: {
Expand Down
3 changes: 1 addition & 2 deletions packages/console/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@flyteorg/console",
"version": "0.0.44",
"version": "0.0.45",
"description": "Flyteconsole main app module",
"main": "./dist/index.js",
"module": "./lib/index.js",
Expand Down Expand Up @@ -126,7 +126,6 @@
"@types/pure-render-decorator": "^0.2.27",
"@types/react": "^16.9.34",
"@types/react-dom": "^16.9.7",
"@types/react-dropzone": "^5.1.0",
"@types/react-router-dom": "^5.3.3",
"@types/react-virtualized": "^9.21.4",
"@types/serve-static": "^1.7.31",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import React, { PropsWithChildren, useContext } from 'react';
import { AppConfig } from '@flyteorg/common';
import { Breadcrumb } from 'components';

export interface ExternalConfigurationProviderProps {
registry?: {
nav?: React.FC<any>;
topLevelLayout?: React.FC<any>;
taskExecutionAttemps?: React.FC<any>;
additionalRoutes?: any;
additionalRoutes?: any[];
breadcrumbs?: Breadcrumb[];
};
env?: any;
config?: AppConfig;
Expand Down
23 changes: 23 additions & 0 deletions packages/console/src/basics/FeatureFlags/FeatureFlags.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,31 @@ import {

export { FeatureFlag } from './defaultConfig';

/**
* Set feature flag value for current session using URLSearchParams values
* @param search
* @returns
*/
const getSearchParamFlags = (search: string): FeatureFlagConfig => {
const urlParams = new URLSearchParams(search);
const flags: FeatureFlagConfig = {};
for (const [key, value] of urlParams.entries()) {
if (value === 'true') {
flags[key] = true;
} else if (value === 'false') {
flags[key] = false;
}
}
return flags as FeatureFlagConfig;
};

const search: string = window.location.search || '';

// To turn on flag for local development only - update flag value here
// REMOVE change prior to commit
let runtimeConfig: FeatureFlagConfig = {
...defaultFlagConfig,
...getSearchParamFlags(search),
// 'test-flag-true': true, <== locally turns flag on
};

Expand All @@ -32,6 +53,7 @@ interface FeatureFlagState {
}

interface FeatureFlagProviderProps {
externalFlags?: { [k: string]: boolean };
children?: React.ReactNode;
}

Expand All @@ -55,6 +77,7 @@ export const useFeatureFlagContext = () => useContext(FeatureFlagContext);
export const FeatureFlagsProvider = (props: FeatureFlagProviderProps) => {
const [flags, setFlags] = useState<FeatureFlagConfig>({
...defaultFlagConfig,
...props.externalFlags,
...runtimeConfig,
});

Expand Down
10 changes: 10 additions & 0 deletions packages/console/src/basics/FeatureFlags/defaultConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ export enum FeatureFlag {
// Production flags
LaunchPlan = 'launch-plan',

// Makes the header inline with the content
HorizontalLayout = 'horizontal-layout',

// Replace the page header with the breadcrumb context navigation with related item quicklinks
breadcrumbs = 'breadcrumbs',

// Test Only Mine flag
OnlyMine = 'only-mine',
}
Expand All @@ -24,6 +30,10 @@ export const defaultFlagConfig: FeatureFlagConfig = {
// If you need to turn it on locally -> update runtimeConfig in ./index.tsx file
'launch-plan': false,

'horizontal-layout': false,

breadcrumbs: false,

'only-mine': false,
};

Expand Down
2 changes: 1 addition & 1 deletion packages/console/src/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Routes } from 'routes/routes';
export function isValidDate(input: string | Date): boolean {
const date = input instanceof Date ? input : new Date(input);
const time = date.getTime();
return !isNaN(time) && time > 0;
return !Number.isNaN(time) && time > 0;
}

/** Converts a Protobuf Timestamp object to a JS Date */
Expand Down
33 changes: 29 additions & 4 deletions packages/console/src/components/App/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ import {
ExternalConfigurationProvider,
ExternalConfigurationProviderProps,
} from 'basics/ExternalConfigurationProvider';
import TopLevelLayoutProvider from 'components/Navigation/TopLevelLayoutState';
import TopLevelLayout from 'components/Navigation/TopLevelLayout';
import NavBar from 'components/Navigation/NavBar';
import { SideNavigation } from 'components/Navigation/SideNavigation';
import GlobalStyles from 'components/utils/GlobalStyles';

export type AppComponentProps = ExternalConfigurationProviderProps;

Expand All @@ -55,8 +59,20 @@ export const AppComponent: React.FC<AppComponentProps> = (
}
const apiState = useAPIState();

const horizontalLayoutFlag =
`${env.HORIZONTAL_LAYOUT}`.trim().toLowerCase() === 'true';

const breadcrumbsFlag = `${env.BREADCRUMBS}`.trim().toLowerCase() === 'true';

return (
<FeatureFlagsProvider>
<FeatureFlagsProvider
externalFlags={{
...props.env,
breadcrumbs: breadcrumbsFlag,
'horizontal-layout': horizontalLayoutFlag,
}}
>
<GlobalStyles />
<LocalCacheProvider>
<StylesProvider
generateClassName={createGenerateClassName({
Expand All @@ -82,16 +98,25 @@ export const AppComponent: React.FC<AppComponentProps> = (
<ExternalConfigurationProvider {...props}>
<Router history={history}>
<ErrorBoundary fixed={true}>
<NavBar />
<ApplicationRouter />
<TopLevelLayoutProvider>
<TopLevelLayout
headerComponent={<NavBar />}
sideNavigationComponent={<SideNavigation />}
routerView={<ApplicationRouter />}
isHorizontalLayout={horizontalLayoutFlag}
/>
</TopLevelLayoutProvider>
</ErrorBoundary>
</Router>
</ExternalConfigurationProvider>
<SystemStatusBanner />
</SkeletonTheme>
</APIContext.Provider>
</FlyteApiProvider>
<ReactQueryDevtools initialIsOpen={false} />
<ReactQueryDevtools
initialIsOpen={false}
position="bottom-right"
/>
</QueryClientProvider>
</SnackbarProvider>
</ThemeProvider>
Expand Down
Loading