Skip to content

Commit 517c606

Browse files
role based invite user configuration
1 parent 4d95e88 commit 517c606

File tree

20 files changed

+296
-84
lines changed

20 files changed

+296
-84
lines changed

global.d.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ interface TRequestActionPayload {
1616
failureActionType?: string;
1717
successActionType?: string;
1818
params?: Record<string, unknown>;
19-
onSuccess?: () => void;
19+
onSuccess?: (res: any) => void;
2020
onFailure?: (errorText: string) => void;
2121
}
2222

@@ -112,6 +112,13 @@ interface TStack {
112112
user?: any;
113113
isShared?: Boolean;
114114
}
115+
interface Roles {
116+
id: TId;
117+
created: Date;
118+
updated: Date;
119+
name: string;
120+
permissions: Array;
121+
}
115122
type TRunStatus =
116123
| 'finished'
117124
| 'In Progress'

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"i18next": "^19.6.3",
3838
"i18next-browser-languagedetector": "^5.0.0",
3939
"json2yaml": "^1.1.0",
40+
"jwt-decode": "^3.1.2",
4041
"node-sass": "^4.14.1",
4142
"query-string": "^6.13.1",
4243
"react": "^16.13.1",

src/api/endpoints.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,7 @@ export const endpoints = {
5454
all: `/runs?unlisted=false&hydrated=true`,
5555
get: (runId: TId): string => `/runs/${runId}?unlisted=false&hydrated=true`,
5656
},
57+
roles: {
58+
all: `/roles`,
59+
},
5760
};

src/api/roles/getRolesApi.ts

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 getRolesApi = ({
7+
authenticationToken,
8+
}: {
9+
authenticationToken: string;
10+
}): Promise<Roles> =>
11+
fetchApiWithAuthRequest({
12+
url: apiUrl(endpoints.roles.all),
13+
method: httpMethods.get,
14+
authenticationToken,
15+
});
16+
17+
export default getRolesApi;

src/redux/actionTypes/constants.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ const stackActionTypes = {
3434
RUNS_GET_STACK_FOR_ID: 'RUNS_GET_STACK_FOR_ID',
3535
};
3636

37+
const rolesActionTypes = {
38+
ROLES_GET_ALL_ROLES: 'ROLES_GET_ALL_ROLES',
39+
};
40+
3741
const stackComponentActionTypes = {
3842
STACKCOMPONENTS_GET_STACKCOMPONENTS_TYPE:
3943
'STACKCOMPONENTS_GET_STACKCOMPONENTS_TYPE',
@@ -75,12 +79,11 @@ export const actionTypes = {
7579
...sessionActionTypes,
7680
...userActionTypes,
7781
...organizationActionTypes,
78-
7982
...pipelineActionTypes,
8083
...stackActionTypes,
8184
...runActionTypes,
8285
...runPagesActionTypes,
83-
86+
...rolesActionTypes,
8487
...pipelinePagesActionTypes,
8588
...stackPagesActionTypes,
8689
...stackComponentPagesActionTypes,

src/redux/actionTypes/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export * from './stackComponents';
1010
export * from './runs';
1111
export * from './runPages';
1212

13+
export * from './roles';
1314
export * from './pipelinePages';
1415
export * from './stackPages';
1516
export * from './stackComponentPages';

src/redux/actionTypes/roles.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { actionTypes } from './constants';
2+
import { generateApiActionsTypes } from './generateApiActionsTypes';
3+
4+
export const rolesActionTypes = {
5+
getRoles: generateApiActionsTypes(actionTypes.ROLES_GET_ALL_ROLES),
6+
};

src/redux/actions/organizations/inviteAction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const inviteAction = ({
88
}: {
99
name: string;
1010
onFailure?: (err: any) => void;
11-
onSuccess?: () => void;
11+
onSuccess?: (res: any) => void;
1212
}): TRequestAction => ({
1313
type: organizationActionTypes.invite.request,
1414
payload: {
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { rolesActionTypes } from '../../actionTypes';
2+
import getRolesApi from '../../../api/roles/getRolesApi';
3+
4+
export const getRolesAction = ({
5+
onSuccess,
6+
onFailure,
7+
}: {
8+
onSuccess?: () => void;
9+
onFailure?: () => void;
10+
}): TRequestAction => ({
11+
type: rolesActionTypes.getRoles.request,
12+
payload: {
13+
apiMethod: getRolesApi,
14+
isAuthenticated: true,
15+
failureActionType: rolesActionTypes.getRoles.failure,
16+
successActionType: rolesActionTypes.getRoles.success,
17+
onSuccess,
18+
onFailure,
19+
},
20+
});

src/redux/actions/roles/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { getRolesAction } from './getRolesAction';
2+
3+
export const rolesActions = {
4+
getRoles: getRolesAction,
5+
};

0 commit comments

Comments
 (0)