Skip to content

Commit d3597e3

Browse files
added project in api for pipeline,stacks and stack components
1 parent 66d8ef6 commit d3597e3

File tree

21 files changed

+153
-73
lines changed

21 files changed

+153
-73
lines changed

src/api/endpoints.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,15 @@ export const endpoints = {
3030
`/pipelines/${pipelineId}?unlisted=false&hydrated=true`,
3131
},
3232
Stacks: {
33-
my: '/stacks?hydrated=true',
33+
my: (project: string): string =>
34+
`/projects/${project}/stacks?hydrated=true`,
3435
get: (stackId: TId): string =>
3536
`/stacks/${stackId}?unlisted=false&hydrated=true`,
3637
},
3738
StackComponents: {
3839
types: '/component-types',
39-
my: (type: string): string => `/components?type=${type}&hydrated=true`,
40+
my: (type: string, project: string): string =>
41+
`/projects/${project}/components?type=${type}&hydrated=true`,
4042
get: (stackComponentId: TId): string =>
4143
`/components/${stackComponentId}?hydrated=true`,
4244
},

src/api/stackComponents/getStackComponentListApi.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ import { apiUrl } from '../apiUrl';
66
const getMyStackComponentsApi = ({
77
authenticationToken,
88
type,
9+
project,
910
}: {
11+
project: string;
1012
authenticationToken: string;
1113
type: string;
1214
}): Promise<TStack> =>
1315
fetchApiWithAuthRequest({
14-
url: apiUrl(endpoints.StackComponents.my(type)),
16+
url: apiUrl(endpoints.StackComponents.my(type, project)),
1517
method: httpMethods.get,
1618
authenticationToken,
1719
});

src/api/stacks/getMyStacksApi.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ import { httpMethods } from '../constants';
44
import { apiUrl } from '../apiUrl';
55

66
const getMyStacksApi = ({
7+
project,
78
authenticationToken,
89
}: {
10+
project: string;
911
authenticationToken: string;
1012
}): Promise<TStack> =>
1113
fetchApiWithAuthRequest({
12-
url: apiUrl(endpoints.Stacks.my),
14+
url: apiUrl(endpoints.Stacks.my(project)),
1315
method: httpMethods.get,
1416
authenticationToken,
1517
});

src/redux/actions/stackComponents/getStackComponentListAction.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ import { stackComponentActionTypes } from '../../actionTypes';
22
import getStackComponentListApi from '../../../api/stackComponents/getStackComponentListApi';
33

44
export const getStackComponentListAction = ({
5+
project,
56
type,
67
onSuccess,
78
onFailure,
89
}: {
10+
project: string;
911
type: TId;
1012
onSuccess?: () => void;
1113
onFailure?: () => void;
@@ -16,7 +18,7 @@ export const getStackComponentListAction = ({
1618
isAuthenticated: true,
1719
failureActionType: stackComponentActionTypes.getStackComponentList.failure,
1820
successActionType: stackComponentActionTypes.getStackComponentList.success,
19-
params: { type },
21+
params: { type, project },
2022
onSuccess,
2123
onFailure,
2224
},

src/redux/actions/stacks/getMyStacksAction.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ import { stackActionTypes } from '../../actionTypes';
22
import getMyStacksApi from '../../../api/stacks/getMyStacksApi';
33

44
export const getMyStacksAction = ({
5+
project,
56
onSuccess,
67
onFailure,
78
}: {
9+
project: string;
810
onSuccess?: () => void;
911
onFailure?: () => void;
1012
}): TRequestAction => ({
@@ -14,6 +16,7 @@ export const getMyStacksAction = ({
1416
isAuthenticated: true,
1517
failureActionType: stackActionTypes.getMyStacks.failure,
1618
successActionType: stackActionTypes.getMyStacks.success,
19+
params: { project },
1720
onSuccess,
1821
onFailure,
1922
},

src/routes/appRoutesConfig.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,15 @@ const routes = [
6969
exact: true,
7070
},
7171
{
72-
path: routePaths.pipelines.list,
72+
path: routePaths.pipelines.list(':string'),
7373
Component: Pipelines,
7474
visibility: {
7575
authentication: RouteVisibilityAuthentication.authenticatedOnly,
7676
},
7777
exact: true,
7878
},
7979
{
80-
path: routePaths.pipelines.allRuns,
80+
path: routePaths.pipelines.allRuns(':string'),
8181
Component: Pipelines,
8282
visibility: {
8383
authentication: RouteVisibilityAuthentication.authenticatedOnly,
@@ -283,7 +283,7 @@ const routes = [
283283
},
284284

285285
{
286-
path: routePaths.stackComponents.base(':type'),
286+
path: routePaths.stackComponents.base(':type', ':string'),
287287
Component: stackComponents,
288288
visibility: {
289289
authentication: RouteVisibilityAuthentication.authenticatedOnly,

src/routes/routePaths.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ export const routePaths = {
55
forgot: '/forgot-password',
66
home: '/',
77
pipelines: {
8-
base: '/pipelines',
9-
list: '/pipelines/list',
10-
allRuns: '/pipelines/all-runs',
8+
// base: '/pipelines',
9+
base: `/pipelines`,
10+
list: (project: string): string => `/projects/${project}/pipelines/list`,
11+
allRuns: (project: string): string =>
12+
`/projects/${project}/pipelines/all-runs`,
1113
},
1214
pipeline: {
1315
base: (id: TId): string => `/pipelines/${id}`,
@@ -69,7 +71,8 @@ export const routePaths = {
6971
},
7072

7173
stackComponents: {
72-
base: (type: string): string => `/components/${type}`,
74+
base: (type: string, project: string): string =>
75+
`/projects/${project}/components/${type}`,
7376
configuration: (type: string, id: TId): string =>
7477
`/components/${type}/${id}/configuration`,
7578
runs: (type: string, id: TId): string => `/components/${type}/${id}/runs`,

src/ui/layouts/Home.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ import { sessionSelectors } from '../../redux/selectors/session';
2525
import { usePushRoute, useSelector } from '../hooks';
2626
import axios from 'axios';
2727
import { routePaths } from '../../routes/routePaths';
28-
import { stackComponentSelectors } from '../../redux/selectors';
28+
import {
29+
projectSelectors,
30+
stackComponentSelectors,
31+
} from '../../redux/selectors';
2932

3033
export const translate = getTranslateByScope('ui.layouts.Dashboard');
3134

@@ -67,6 +70,7 @@ export const Home: React.FC = () => {
6770
const stackComponentsTypes: any[] = useSelector(
6871
stackComponentSelectors.stackComponentTypes,
6972
);
73+
const selectedProject = useSelector(projectSelectors.selectedProject);
7074
const [fetching, setFetching] = useState(false);
7175
const [dashboardData, setDashboardData] = useState('');
7276
const authToken = useSelector(sessionSelectors.authenticationToken);
@@ -148,11 +152,12 @@ export const Home: React.FC = () => {
148152
} else if (e.text === 'pipelines') {
149153
push(routePaths.pipelines.base);
150154
} else if (e.text === 'runs') {
151-
push(routePaths.pipelines.allRuns);
155+
push(routePaths.pipelines.allRuns(selectedProject));
152156
} else if (e.text === 'components') {
153157
push(
154158
routePaths.stackComponents.base(
155159
stackComponentsTypes[0],
160+
selectedProject,
156161
),
157162
);
158163
}

src/ui/layouts/common/layouts/AuthenticatedLayout/AuthenticatedSidebar/Menu/index.tsx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,18 @@ import { translate } from '../translate';
77
import { useLocationPath } from '../../../../../../hooks';
88
import { matchPath } from 'react-router-dom';
99
import { useSelector } from './../../../../../../../ui/hooks';
10-
import { stackComponentSelectors } from '../../../../../../../redux/selectors';
10+
import {
11+
projectSelectors,
12+
stackComponentSelectors,
13+
} from '../../../../../../../redux/selectors';
1114

1215
export const Menu: React.FC = () => {
1316
const locationPath = useLocationPath();
1417

1518
const stackComponentsTypes: any[] = useSelector(
1619
stackComponentSelectors.stackComponentTypes,
1720
);
21+
const selectedProject = useSelector(projectSelectors.selectedProject);
1822

1923
return (
2024
<>
@@ -34,14 +38,14 @@ export const Menu: React.FC = () => {
3438
Icon={() => (
3539
<icons.pipeline color={iconColors.white} size={iconSizes.md} />
3640
)}
37-
to={routePaths.pipelines.list}
41+
to={routePaths.pipelines.list(selectedProject)}
3842
text={translate('menu.pipelines.text')}
3943
/>
4044
<MenuItem
4145
isActive={() => {
4246
return (
4347
!!matchPath(locationPath, {
44-
path: routePaths.pipelines.allRuns,
48+
path: routePaths.pipelines.allRuns(selectedProject),
4549
exact: false,
4650
}) ||
4751
!!matchPath(locationPath, {
@@ -53,7 +57,7 @@ export const Menu: React.FC = () => {
5357
Icon={() => (
5458
<icons.pipeline color={iconColors.white} size={iconSizes.md} />
5559
)}
56-
to={routePaths.pipelines.allRuns}
60+
to={routePaths.pipelines.allRuns(selectedProject)}
5761
text={'Runs'}
5862
/>
5963
<MenuItem
@@ -79,7 +83,7 @@ export const Menu: React.FC = () => {
7983
<MenuItem
8084
isActive={() => {
8185
return !!matchPath(locationPath, {
82-
path: routePaths.stackComponents.base(''),
86+
path: routePaths.stackComponents.base('', selectedProject),
8387
exact: false,
8488
});
8589
}}
@@ -88,6 +92,7 @@ export const Menu: React.FC = () => {
8892
)}
8993
to={routePaths.stackComponents.base(
9094
stackComponentsTypes ? stackComponentsTypes[0] : '',
95+
selectedProject,
9196
)}
9297
text={translate('menu.stackComponents.text')}
9398
/>
@@ -97,7 +102,7 @@ export const Menu: React.FC = () => {
97102
<MenuItem
98103
isActive={() => {
99104
return !!matchPath(locationPath, {
100-
path: routePaths.stackComponents.base(item),
105+
path: routePaths.stackComponents.base(item, selectedProject),
101106
exact: false,
102107
});
103108
}}
@@ -108,7 +113,7 @@ export const Menu: React.FC = () => {
108113
size={iconSizes.md}
109114
/>
110115
)}
111-
to={routePaths.stackComponents.base(item)}
116+
to={routePaths.stackComponents.base(item, selectedProject)}
112117
text={item}
113118
/>
114119
))}

src/ui/layouts/pipelines/PipelineDetail/index.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import { useService } from './useService';
1111
import FilterComponent, {
1212
getInitialFilterStateForRuns,
1313
} from '../../../components/Filters';
14-
import { useLocationPath } from '../../../hooks';
14+
import { useLocationPath, useSelector } from '../../../hooks';
15+
import { projectSelectors } from '../../../../redux/selectors';
1516

1617
interface Props {
1718
pipelineId: TId;
@@ -60,12 +61,15 @@ const getTabPages = (pipelineId: TId): TabPage[] => {
6061
];
6162
};
6263

63-
const getBreadcrumbs = (pipelineId: TId): TBreadcrumb[] => {
64+
const getBreadcrumbs = (
65+
pipelineId: TId,
66+
selectedProject: string,
67+
): TBreadcrumb[] => {
6468
return [
6569
{
6670
name: translate('header.breadcrumbs.pipelines.text'),
6771
clickable: true,
68-
to: routePaths.pipelines.list,
72+
to: routePaths.pipelines.list(selectedProject),
6973
},
7074
{
7175
name: pipelineId,
@@ -81,9 +85,9 @@ export interface PipelineDetailRouteParams {
8185

8286
export const PipelineDetail: React.FC = () => {
8387
const { pipeline } = useService();
84-
88+
const selectedProject = useSelector(projectSelectors.selectedProject);
8589
const tabPages = getTabPages(pipeline.id);
86-
const breadcrumbs = getBreadcrumbs(pipeline.id);
90+
const breadcrumbs = getBreadcrumbs(pipeline.id, selectedProject);
8791

8892
const boxStyle = {
8993
backgroundColor: '#E9EAEC',

0 commit comments

Comments
 (0)