Skip to content

Commit f5df868

Browse files
committed
Merge branch 'dev' of https://github.com/zenml-io/zenml-dashboard into feat/ahsan-new
2 parents b6691d1 + 610acc5 commit f5df868

File tree

19 files changed

+315
-258
lines changed

19 files changed

+315
-258
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
"tslint": "tsc",
7979
"all": "eslint './src/**/*.ts*' & react-scripts test --all & tsc"
8080
},
81+
"homepage": "/login",
8182
"browserslist": {
8283
"production": [
8384
">0.2%",

src/constants/routes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
import { routePaths } from '../routes/routePaths';
22
export const loggedOutRoute = routePaths.login;
3-
export const loggedInRoute = routePaths.home;
3+
export const loggedInRoute = routePaths.home(':string');

src/redux/reducers/projectsReducer.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { DEFAULT_PROJECT_NAME } from '../../constants';
12
import { camelCaseArray } from '../../utils/camelCase';
23
import { projectActionTypes } from '../actionTypes';
34
import { byKeyInsert, idsInsert } from './reducerHelpers';
@@ -7,7 +8,7 @@ export interface State {
78
byId: Record<TId, Projects>;
89
myProjectIds: TId[];
910
selectedProject: string;
10-
projectStats: any
11+
projectStats: any;
1112
}
1213

1314
type ProjectsPayload = Projects[];
@@ -25,20 +26,20 @@ export const initialState: State = {
2526
byId: {},
2627
myProjectIds: [],
2728
selectedProject: '',
28-
projectStats: {}
29+
projectStats: {},
2930
};
3031

3132
const newState = (
3233
state: State,
3334
projects: Projects[],
3435
defaultSelectedProject?: string,
35-
projectStats?: object
36+
projectStats?: object,
3637
): State => ({
3738
...state,
3839
ids: idsInsert(state.ids, projects),
3940
byId: byKeyInsert(state.byId, projects),
4041
selectedProject: defaultSelectedProject as string,
41-
projectStats: projectStats
42+
projectStats: projectStats,
4243
});
4344

4445
const projectsReducer = (
@@ -55,7 +56,7 @@ const projectsReducer = (
5556
(project: Projects) => project.id,
5657
);
5758
if (action.requestParams.selectDefault === undefined) {
58-
const defaultSelectedProject = projects[0].name;
59+
const defaultSelectedProject = DEFAULT_PROJECT_NAME;
5960
return {
6061
...newState(state, projects, defaultSelectedProject),
6162
myProjectIds,
@@ -73,22 +74,21 @@ const projectsReducer = (
7374
const myProjectIds: TId[] = allProjects.map(
7475
(project: Projects) => project.id,
7576
);
76-
77+
7778
return {
7879
...newState(state, allProjects, seletecdProject),
7980
myProjectIds,
8081
};
8182
}
8283

83-
8484
case projectActionTypes.getMyProjectStats.success: {
8585
// const { projectStats } = action.payload as any;
8686
const projectStats = action.payload;
87-
88-
return { ...newState(state, projectStats) };
87+
88+
return { ...newState(state, projectStats) };
8989
}
9090

91-
default:
91+
default:
9292
return state;
9393
}
9494
};

src/routes/appRoutesConfig.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const routes = [
5353
},
5454
},
5555
{
56-
path: routePaths.home,
56+
path: routePaths.home(':string'),
5757
Component: Home,
5858
visibility: {
5959
authentication: RouteVisibilityAuthentication.authenticatedOnly,

src/routes/routePaths.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@ export const routePaths = {
77
signup: '/signup',
88
userEmail: `/user-email`,
99
forgot: '/forgot-password',
10-
home: '/',
10+
home: (project: string): string => `/projects/${project}`,
1111
pipelines: {
1212
base: `/pipelines`,
1313
list: (project: string): string => `/projects/${project}/pipelines/list`,
14-
allRuns: (project: string): string =>
15-
`/projects/${project}/pipelines/all-runs`,
14+
allRuns: (project: string): string => `/projects/${project}/all-runs`,
1615
},
1716
pipeline: {
1817
base: (id: TId): string => `/pipelines/${id}`,
@@ -63,11 +62,11 @@ export const routePaths = {
6362
`/components/${pipelineId}/runs/${id}/tensorboard`,
6463
},
6564
run: {
66-
base: (runId: TId): string => `/runs/${runId}`,
65+
base: (runId: TId): string => `/all-runs/${runId}`,
6766
statistics: (project: string, id: TId, type?: string): string =>
68-
`/projects/${project}/runs/${id}/dag`,
67+
`/projects/${project}/all-runs/${id}/dag`,
6968
results: (project: string, runId: TId): string =>
70-
`/projects/${project}/runs/${runId}/configuration`,
69+
`/projects/${project}/all-runs/${runId}/configuration`,
7170
tensorboard: (runId: TId): string => `/runs/${runId}/tensorboard`,
7271
},
7372
},

src/routes/utils/replaceRouteIfNeeded.ts

Lines changed: 8 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,9 @@
1-
// import { RouteVisibilityAuthentication } from '../RouteVisibility';
2-
// import { loggedOutRoute, loggedInRoute } from '../../constants';
3-
4-
// const isUnauthenticatedOrMissingRoute = (
5-
// currentLocation: any | undefined,
6-
// ): boolean =>
7-
// currentLocation
8-
// ? currentLocation.visibility &&
9-
// currentLocation.visibility.authentication ===
10-
// RouteVisibilityAuthentication.unauthenticatedOnly
11-
// : false;
12-
13-
// const isAuthenticatedOrMissingRoute = (
14-
// currentLocation: any | undefined,
15-
// ): boolean =>
16-
// currentLocation
17-
// ? currentLocation.visibility &&
18-
// currentLocation.visibility.authentication ===
19-
// RouteVisibilityAuthentication.authenticatedOnly
20-
// : false;
21-
22-
// let timeout = null as any;
23-
24-
// export const replaceRouteIfNeeded = ({
25-
// user,
26-
// isAuthenticated,
27-
// currentLocation,
28-
// replaceRoute,
29-
// routeFromSearchParam,
30-
// }: {
31-
// user: any;
32-
// isAuthenticated: any;
33-
// currentLocation: any | undefined;
34-
// replaceRoute: (arg1: string) => void;
35-
// routeFromSearchParam: null | string;
36-
// }): void => {
37-
// clearTimeout(timeout);
38-
39-
// const routeToReplace = () => {
40-
// return isAuthenticated ? loggedInRoute : loggedOutRoute;
41-
// };
42-
// const replaceToLoggedInRoute =
43-
// isAuthenticated && isUnauthenticatedOrMissingRoute(currentLocation);
44-
45-
// const replaceToLoggedOutRoute =
46-
// !isAuthenticated && isAuthenticatedOrMissingRoute(currentLocation);
47-
48-
// const replaceToLoggedInRouteForEmailOptedIn =
49-
// isAuthenticated &&
50-
// user?.emailOptedIn === null &&
51-
// currentLocation?.path !== `/user-email`;
52-
// const shouldReplaceRoute =
53-
// replaceToLoggedInRoute ||
54-
// replaceToLoggedOutRoute ||
55-
// replaceToLoggedInRouteForEmailOptedIn;
56-
57-
// if (shouldReplaceRoute) {
58-
// timeout = setTimeout(() => {
59-
// let route = routeToReplace();
60-
// if (user?.emailOptedIn === null) {
61-
// route = `/user-email`;
62-
// }
63-
// console.log(currentLocation, 'currentLocation', routeFromSearchParam);
64-
65-
// if (replaceToLoggedOutRoute && currentLocation) {
66-
// route = `${route}?route=${currentLocation.path}`;
67-
// } else if (replaceToLoggedInRoute && routeFromSearchParam) {
68-
// route = routeFromSearchParam;
69-
// }
70-
71-
// replaceRoute(route);
72-
// }, 0);
73-
// }
74-
// };
75-
761
import {
772
RouteInterface,
783
RouteVisibilityAuthentication,
794
} from '../RouteVisibility';
80-
import { loggedOutRoute } from '../../constants';
5+
import { loggedOutRoute, DEFAULT_PROJECT_NAME } from '../../constants';
6+
import { routePaths } from '../routePaths';
817

828
const isUnauthenticatedOrMissingRoute = (
839
currentLocation: RouteInterface | undefined,
@@ -117,7 +43,12 @@ export const replaceRouteIfNeeded = ({
11743
clearTimeout(timeout);
11844

11945
const routeToReplace = () => {
120-
const logRoute = user?.emailOptedIn === null ? `/user-email` : '/';
46+
// const url = window.location.search;
47+
const logRoute =
48+
user?.emailOptedIn === null
49+
? `/user-email`
50+
: routePaths.home(DEFAULT_PROJECT_NAME);
51+
12152
return isAuthenticated ? logRoute : loggedOutRoute;
12253
};
12354
const replaceToLoggedInRoute =

src/ui/layouts/Home.tsx

Lines changed: 43 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import {
4040
pipelinePagesActions,
4141
runPagesActions,
4242
} from '../../redux/actions';
43+
import { NotFound } from '../../ui/layouts/NotFound';
4344

4445
import Tour from './Tour';
4546

@@ -84,6 +85,7 @@ export const Home: React.FC = () => {
8485
const stackComponentsTypes: any[] = useSelector(
8586
stackComponentSelectors.stackComponentTypes,
8687
);
88+
const [notFound, setNotFound] = useState(false);
8789

8890
const selectedProject = useSelector(projectSelectors.selectedProject);
8991
const projects = useSelector(projectSelectors.myProjects);
@@ -119,32 +121,52 @@ export const Home: React.FC = () => {
119121
{ headers: { Authorization: `bearer ${authToken}` } },
120122
);
121123

122-
await dispatch(
123-
projectsActions.getSelectedProject({
124-
allProjects: projects,
125-
seletecdProject: selectedProject
126-
? selectedProject
127-
: DEFAULT_PROJECT_NAME,
128-
}),
129-
);
130-
await dispatch(
131-
pipelinesActions.getMy({
132-
project: selectedProject ? selectedProject : DEFAULT_PROJECT_NAME,
133-
onSuccess: () => stopLoad(),
134-
onFailure: () => stopLoad(),
135-
}),
136-
);
124+
// await dispatch(
125+
// projectsActions.getMy({
126+
// selectDefault: false,
127+
// selectedProject: selectedProject,
128+
// onSuccess: () => stopLoad(),
129+
// onFailure: () => stopLoad(),
130+
// }),
131+
// );
132+
133+
// await dispatch(
134+
// projectsActions.getSelectedProject({
135+
// allProjects: projects,
136+
// seletecdProject: selectedProject
137+
// ? selectedProject
138+
// : DEFAULT_PROJECT_NAME,
139+
// }),
140+
// );
141+
142+
// await dispatch(
143+
// pipelinesActions.getMy({
144+
// project: selectedProject ? selectedProject : DEFAULT_PROJECT_NAME,
145+
// onSuccess: () => stopLoad(),
146+
// onFailure: () => stopLoad(),
147+
// }),
148+
// );
137149

138150
setDashboardData(data);
139151
setFetching(false);
140-
} catch (err) {
141-
// @ts-ignore
152+
} catch (e) {
142153
dispatch(
143154
showToasterAction({
144-
description: translate('toasts.successful.passwordText'),
145-
type: toasterTypes.success,
155+
description: 'Not found',
156+
type: toasterTypes.failure,
146157
}),
147158
);
159+
160+
await dispatch(
161+
projectsActions.getMy({
162+
selectDefault: false,
163+
selectedProject: DEFAULT_PROJECT_NAME,
164+
onSuccess: () => setNotFound(true),
165+
onFailure: () => stopLoad(),
166+
}),
167+
);
168+
169+
// push(routePaths.home(DEFAULT_PROJECT_NAME));
148170
}
149171
};
150172
getDashboardData();
@@ -166,6 +188,8 @@ export const Home: React.FC = () => {
166188
setBox('');
167189
setIsHover(false);
168190
};
191+
console.log(notFound, 'notFound');
192+
if (notFound) return <NotFound />;
169193

170194
return (
171195
<AuthenticatedLayout>

0 commit comments

Comments
 (0)