Skip to content

Commit

Permalink
Merge branch 'master' into ecl
Browse files Browse the repository at this point in the history
  • Loading branch information
va6996 authored Jul 11, 2024
2 parents 630adfd + 7636e32 commit f26a134
Show file tree
Hide file tree
Showing 27 changed files with 663 additions and 84 deletions.
2 changes: 1 addition & 1 deletion packages/flyte-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"tslib": "^2.4.1"
},
"dependencies": {
"axios": "^0.27.2",
"axios": "^1.7.1",
"camelcase-keys": "^7.0.2",
"snakecase-keys": "^5.4.2"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/oss-console/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"@tanstack/react-virtual": "^3.0.0-alpha.0",
"@types/d3-shape": "^1.2.6",
"@xstate/react": "^1.0.0",
"axios": "^0.27.2",
"axios": "^1.7.1",
"copy-to-clipboard": "^3.0.8",
"cronstrue": "^1.31.0",
"d3-dag": "^0.3.4",
Expand Down
58 changes: 38 additions & 20 deletions packages/oss-console/src/App/ApplicationRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,52 @@ import { PrettyError } from '../components/Errors/PrettyError';
import { useDomainPathUpgrade } from '../routes/useDomainPathUpgrade';
import { Routes } from '../routes/routes';
import AnimateRoute from '../routes/AnimateRoute';
import { loadChunkWithAuth } from '../components/data/loadChunkWithAuth';

const SelectProject = lazy(
() => import(/* webpackChunkName: "SelectProject" */ '../components/SelectProject'),
const SelectProject = lazy(() =>
loadChunkWithAuth(
() => import(/* webpackChunkName: "SelectProject" */ '../components/SelectProject'),
),
);
const ListProjectEntities = lazy(
() => import(/* webpackChunkName: "ListProjectEntities" */ '../components/ListProjectEntities'),
const ListProjectEntities = lazy(() =>
loadChunkWithAuth(
() => import(/* webpackChunkName: "ListProjectEntities" */ '../components/ListProjectEntities'),
),
);

const ExecutionDetails = lazy(
() =>
import(/* webpackChunkName: "ExecutionDetails" */ '../components/Executions/ExecutionDetails'),
const ExecutionDetails = lazy(() =>
loadChunkWithAuth(
() =>
import(
/* webpackChunkName: "ExecutionDetails" */ '../components/Executions/ExecutionDetails'
),
),
);

const TaskDetails = lazy(() => import(/* webpackChunkName: "TaskDetails" */ '../components/Task'));
const WorkflowDetails = lazy(
() => import(/* webpackChunkName: "WorkflowDetails" */ '../components/Workflow/WorkflowDetails'),
const TaskDetails = lazy(() =>
loadChunkWithAuth(() => import(/* webpackChunkName: "TaskDetails" */ '../components/Task')),
);
const LaunchPlanDetails = lazy(
() =>
import(
/* webpackChunkName: "LaunchPlanDetails" */ '../components/LaunchPlan/LaunchPlanDetails'
),
const WorkflowDetails = lazy(() =>
loadChunkWithAuth(
() =>
import(/* webpackChunkName: "WorkflowDetails" */ '../components/Workflow/WorkflowDetails'),
),
);
const EntityVersionsDetailsContainer = lazy(
() =>
import(
/* webpackChunkName: "EntityVersionsDetailsContainer" */ '../components/Entities/VersionDetails/EntityVersionDetailsContainer'
),
const LaunchPlanDetails = lazy(() =>
loadChunkWithAuth(
() =>
import(
/* webpackChunkName: "LaunchPlanDetails" */ '../components/LaunchPlan/LaunchPlanDetails'
),
),
);
const EntityVersionsDetailsContainer = lazy(() =>
loadChunkWithAuth(
() =>
import(
/* webpackChunkName: "EntityVersionsDetailsContainer" */ '../components/Entities/VersionDetails/EntityVersionDetailsContainer'
),
),
);

export const ApplicationRouter: React.FC = () => {
Expand Down
6 changes: 2 additions & 4 deletions packages/oss-console/src/App/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { FeatureFlagsProvider } from '../basics/FeatureFlags';
import { debug, debugPrefix } from '../common/log';
import { APIContext, useAPIState } from '../components/data/apiContext';
import { QueryAuthorizationObserver } from '../components/data/QueryAuthorizationObserver';
import { createQueryClient } from '../components/data/queryCache';
import { SystemStatusBanner } from '../components/Notifications/SystemStatusBanner';
import { history } from '../routes/history';
import { LocalCacheProvider } from '../basics/LocalCache/ContextProvider';
Expand All @@ -30,12 +29,11 @@ import TopLevelLayoutProvider from '../components/common/TopLevelLayout/TopLevel
import ApplicationRouter from './ApplicationRouter';
import { ErrorBoundary } from '../components/common/ErrorBoundary';
import DownForMaintenance from '../components/Errors/DownForMaintenance';
import { globalQueryClient } from '../components/data/globalQueryClient';

const QueryClientProvider: React.FC<PropsWithChildren<QueryClientProviderProps>> =
QueryClientProviderImport;

const queryClient = createQueryClient();

export const AppComponent: React.FC<unknown> = () => {
if (env.NODE_ENV === 'development') {
debug.enable(`${debugPrefix}*:*`);
Expand All @@ -61,7 +59,7 @@ export const AppComponent: React.FC<unknown> = () => {
anchorOrigin={{ vertical: 'top', horizontal: 'right' }}
TransitionComponent={Collapse}
>
<QueryClientProvider client={queryClient}>
<QueryClientProvider client={globalQueryClient}>
<FlyteApiProvider flyteApiDomain={env.ADMIN_API} disableAutomaticLogin>
<APIContext.Provider value={apiState}>
<QueryAuthorizationObserver />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export class BreadcrumbRegistry {

static makeUrlSegments(location: Location, projectId = '', domainId = '') {
const pathName = location.pathname;
const basePath = process.env.BASE_PATH || '/console';
const basePath = process.env.BASE_URL || '/console';

// Remove first occurence of base path
const pathNameWithoutBasePath = pathName.replace(basePath, '');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { EntityExecutions } from './EntityExecutions';
import { EntityVersions } from './EntityVersions';
import { executionFilterGenerator } from './generators';
import { executionSortFields } from '../../models/Execution/constants';
import { EntitySchedules } from './EntitySchedules';

const EntityDetailsContainer = styled(Grid)(({ theme }) => ({
minHeight: '100vh',
Expand Down Expand Up @@ -123,12 +124,18 @@ export const EntityDetails: React.FC<EntityDetailsProps> = ({ id }) => {
paddingRight: (theme) => theme.spacing(2),
}}
>
{sections.description && (
{!!sections.description && (
<Grid item xs={12}>
<EntityDescription id={id} />
</Grid>
)}

{!!sections.schedules && (
<Grid item xs={12}>
<EntitySchedules id={id} />
</Grid>
)}

{!!sections.inputs && (
<Grid item xs={12}>
<EntityInputs id={id} />
Expand Down
2 changes: 1 addition & 1 deletion packages/oss-console/src/components/Entities/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const entitySections: { [k in ResourceType]: EntitySectionsFlags } = {
executions: true,
launch: false,
inputs: true,
schedules: true,
schedules: false,
versions: true,
},
[ResourceType.TASK]: {
Expand Down
142 changes: 142 additions & 0 deletions packages/oss-console/src/components/Errors/ErrorHandler.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
import NotAuthorizedError from '@clients/common/Errors/NotAuthorizedError';
import NotFoundError from '@clients/common/Errors/NotFoundError';
import { AxiosError } from 'axios';
import React from 'react';
import Box from '@mui/material/Box';
import Typography from '@mui/material/Typography';
import Link from '@mui/material/Link';
import Button from '@mui/material/Button';
import { useFlyteApi } from '@clients/flyte-api/ApiProvider';
import { GenericError } from './GenericError';

export interface ErrorHandlerProps {
error: NotFoundError | NotAuthorizedError | AxiosError | Error;
}

export const ErrorHandler: React.FC<ErrorHandlerProps> = ({ error }) => {
const { getLoginUrl } = useFlyteApi();

const contactSupport = (
<>
<Typography variant="label">
Please join the Slack community and explore its history on{' '}
<Link
color="inherit"
variant="label"
sx={{
fontSize: 'inherit',
}}
href="https://discuss.flyte.org/"
target="_blank"
>
discuss.flyte.org
</Link>
{', '}
or file a GitHub issue on{' '}
<Link
color="inherit"
variant="label"
sx={{
fontSize: 'inherit',
}}
href="https://github.com/flyteorg/flyte"
target="_blank"
>
flyteorg/flyte
</Link>{' '}
if the problem persists.
</Typography>
</>
);

if (
error instanceof NotFoundError ||
(error instanceof AxiosError && error.response?.status === 404)
) {
return (
<GenericError
title="404"
description="Not Found"
content={
<>
<Box py={1} />
<Typography variant="body2">The requested resource was not found</Typography>

<Box py={1} />

{contactSupport}
</>
}
/>
);
}

if (
error instanceof NotAuthorizedError ||
(error instanceof AxiosError && error.response?.status === 401)
) {
return (
<GenericError
title="401"
description="Unauthorized"
content={
<>
<Box py={1} />
<Typography variant="body2">
<strong>You do not have the proper authentication to access this page</strong>
</Typography>

<Box py={1} />

{contactSupport}
<Box py={1} />

<Button
variant="contained"
href={getLoginUrl()}
autoFocus
data-cy="login-button-overlay"
>
Log in
</Button>
</>
}
/>
);
}

if (error instanceof AxiosError && error.response?.status === 403) {
return (
<GenericError
title="403"
description="Forbidden"
content={
<>
<Box py={1} />
<Typography variant="body2">
<strong>You don't have permission to access this page</strong>
</Typography>

<Box py={1} />

{contactSupport}
</>
}
/>
);
}

return (
<GenericError
title={(error as AxiosError)?.response?.status || 'Oops!'}
description="Something went wrong."
content={
<>
<Box py={1} />

{contactSupport}
</>
}
/>
);
};
Loading

0 comments on commit f26a134

Please sign in to comment.