Skip to content

Commit 66d8ef6

Browse files
added project based configuration
1 parent 15b89ff commit 66d8ef6

File tree

25 files changed

+281
-29
lines changed

25 files changed

+281
-29
lines changed

global.d.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,13 @@ interface TWorkspace {
7474
name: string;
7575
createdAt: Date;
7676
}
77-
77+
interface Projects {
78+
id: TId;
79+
created: Date;
80+
updated: Date;
81+
name: string;
82+
description: string;
83+
}
7884
interface TPipeline {
7985
id: TId;
8086
name: string;

src/api/endpoints.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,13 @@ export const endpoints = {
1919
deleteInvite: (id: string): string => `/users/${id}`,
2020
},
2121

22+
projects: {
23+
my: '/projects',
24+
},
25+
2226
pipelines: {
23-
my: '/pipelines?hydrated=true',
27+
my: (project: string): string =>
28+
`/projects/${project}/pipelines?hydrated=true`,
2429
get: (pipelineId: TId): string =>
2530
`/pipelines/${pipelineId}?unlisted=false&hydrated=true`,
2631
},

src/api/pipelines/getMyPipelinesApi.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ import { apiUrl } from '../apiUrl';
55

66
const getMyPipelinesApi = ({
77
authenticationToken,
8+
project,
89
}: {
910
authenticationToken: string;
11+
project: string;
1012
}): Promise<TPipeline> =>
1113
fetchApiWithAuthRequest({
12-
url: apiUrl(endpoints.pipelines.my),
14+
url: apiUrl(endpoints.pipelines.my(project)),
1315
method: httpMethods.get,
1416
authenticationToken,
1517
});
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { fetchApiWithAuthRequest } from '../fetchApi';
2+
import { endpoints } from '../endpoints';
3+
import { httpMethods } from '../constants';
4+
import { apiUrl } from '../apiUrl';
5+
6+
const getMyProjectApi = ({
7+
authenticationToken,
8+
}: {
9+
authenticationToken: string;
10+
}): Promise<TPipeline> =>
11+
fetchApiWithAuthRequest({
12+
url: apiUrl(endpoints.projects.my),
13+
method: httpMethods.get,
14+
authenticationToken,
15+
});
16+
17+
export default getMyProjectApi;

src/redux/actionTypes/constants.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ const pipelineActionTypes = {
2828
PIPELINES_GET_PIPELINE_FOR_ID: 'PIPELINES_GET_PIPELINE_FOR_ID',
2929
RUNS_GET_PIPELINE_FOR_ID: 'RUNS_GET_PIPELINE_FOR_ID',
3030
};
31+
32+
const projectActionTypes = {
33+
PROJECTS_GET_MY_PROJECTS: 'PROJECTS_GET_MY_PROJECTS',
34+
SELECT_PROJECT_FROM_MY_PROJECTS: 'SELECT_PROJECT_FROM_MY_PROJECTS',
35+
};
3136
const stackActionTypes = {
3237
STACKS_GET_MY_STACKS: 'STACKS_GET_MY_STACKS',
3338
STACKS_GET_STACK_FOR_ID: 'STACKS_GET_STACK_FOR_ID',
@@ -79,6 +84,7 @@ export const actionTypes = {
7984
...sessionActionTypes,
8085
...userActionTypes,
8186
...organizationActionTypes,
87+
...projectActionTypes,
8288
...pipelineActionTypes,
8389
...stackActionTypes,
8490
...runActionTypes,

src/redux/actionTypes/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import { actionTypes } from './constants';
22

33
export * from './session';
44
export * from './users';
5+
export * from './projects';
56
export * from './organizations';
6-
7+
export * from './projects';
78
export * from './pipelines';
89
export * from './stacks';
910
export * from './stackComponents';

src/redux/actionTypes/projects.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { actionTypes } from './constants';
2+
import { generateApiActionsTypes } from './generateApiActionsTypes';
3+
4+
export const projectActionTypes = {
5+
getMyProjects: generateApiActionsTypes(actionTypes.PROJECTS_GET_MY_PROJECTS),
6+
selectProject: generateApiActionsTypes(
7+
actionTypes.SELECT_PROJECT_FROM_MY_PROJECTS,
8+
),
9+
};

src/redux/actions/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export * from './session';
22
export * from './showToasterAction';
33
export * from './users';
44
export * from './organizations';
5-
5+
export * from './projects';
66
export * from './pipelines';
77
export * from './stacks';
88
export * from './stackComponents';

src/redux/actions/pipelines/getMyPipelinesAction.ts

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

44
export const getMyPipelinesAction = ({
5+
project,
56
onSuccess,
67
onFailure,
78
}: {
9+
project: string;
810
onSuccess?: () => void;
911
onFailure?: () => void;
1012
}): TRequestAction => ({
@@ -14,6 +16,7 @@ export const getMyPipelinesAction = ({
1416
isAuthenticated: true,
1517
failureActionType: pipelineActionTypes.getMyPipelines.failure,
1618
successActionType: pipelineActionTypes.getMyPipelines.success,
19+
params: { project },
1720
onSuccess,
1821
onFailure,
1922
},
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { projectActionTypes } from '../../actionTypes';
2+
import getMyProjectsApi from '../../../api/projects/getMyProjectsApi';
3+
4+
export const getMyProjectsAction = ({
5+
onSuccess,
6+
onFailure,
7+
}: {
8+
onSuccess?: () => void;
9+
onFailure?: () => void;
10+
}): TRequestAction => ({
11+
type: projectActionTypes.getMyProjects.request,
12+
payload: {
13+
apiMethod: getMyProjectsApi,
14+
isAuthenticated: true,
15+
failureActionType: projectActionTypes.getMyProjects.failure,
16+
successActionType: projectActionTypes.getMyProjects.success,
17+
onSuccess,
18+
onFailure,
19+
},
20+
});

0 commit comments

Comments
 (0)