Skip to content

Commit 1671517

Browse files
feat: service connectors (#361)
1 parent c8d432e commit 1671517

File tree

79 files changed

+8868
-1338
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+8868
-1338
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { fetchApiWithAuthRequest } from '../fetchApi';
2+
import { endpoints } from '../endpoints';
3+
import { httpMethods } from '../constants';
4+
import { apiUrl } from '../apiUrl';
5+
6+
const getConnectorComponentsApi = ({
7+
connector_id,
8+
workspace,
9+
sort_by,
10+
logical_operator,
11+
page,
12+
size,
13+
name,
14+
filtersParam,
15+
// id,
16+
authenticationToken,
17+
}: {
18+
connector_id?: string;
19+
workspace: string;
20+
sort_by: string;
21+
logical_operator: string;
22+
page: number;
23+
size: number;
24+
name?: string;
25+
filtersParam?: object;
26+
// id?: any;
27+
authenticationToken: string;
28+
}): Promise<any> =>
29+
fetchApiWithAuthRequest({
30+
url: apiUrl(endpoints.Connectors.connectorComponents),
31+
params: {
32+
connector_id,
33+
sort_by,
34+
logical_operator,
35+
page,
36+
size,
37+
name,
38+
...filtersParam,
39+
// id,
40+
},
41+
method: httpMethods.get,
42+
authenticationToken,
43+
});
44+
45+
export default getConnectorComponentsApi;

src/api/connectors/getConnectorsTypesApi.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const getConnectorsTypesApi = ({
1010
logical_operator,
1111
page,
1212
size,
13-
name,
13+
connector_type,
1414
filtersParam,
1515
// id,
1616
authenticationToken,
@@ -21,7 +21,7 @@ const getConnectorsTypesApi = ({
2121
logical_operator: string;
2222
page: number;
2323
size: number;
24-
name?: string;
24+
connector_type?: string;
2525
filtersParam?: object;
2626
// id?: any;
2727
authenticationToken: string;
@@ -34,7 +34,7 @@ const getConnectorsTypesApi = ({
3434
logical_operator,
3535
page,
3636
size,
37-
name,
37+
connector_type,
3838
...filtersParam,
3939
// id,
4040
},

src/api/endpoints.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,5 +91,6 @@ export const endpoints = {
9191
`/workspaces/${workspace}/service_connectors`,
9292
get: (connectorId: TId): string => `/service_connectors/${connectorId}`,
9393
connectorsTypes: `/service_connector_types`,
94+
connectorComponents: `/components`,
9495
},
9596
};

src/redux/actionTypes/connectors.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ export const connectorActionTypes = {
88
getConnectorForId: generateApiActionsTypes(
99
actionTypes.CONNECTORS_GET_CONNECTOR_FOR_ID,
1010
),
11-
ConnectorsTypes: generateApiActionsTypes(
11+
connectorsTypes: generateApiActionsTypes(
1212
actionTypes.CONNECTORS_GET_CONNECTORS_TYPES,
1313
),
14+
getConnectorComponents: generateApiActionsTypes(
15+
actionTypes.CONNECTORS_GET_CONNECTORCOMPONENTS_TYPES,
16+
),
1417
};

src/redux/actionTypes/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ const connectorActionTypes = {
6161
CONNECTORS_GET_MY_CONNECTORS: 'CONNECTORS_GET_MY_CONNECTORS',
6262
CONNECTORS_GET_CONNECTOR_FOR_ID: 'CONNECTORS_GET_CONNECTOR_FOR_ID',
6363
CONNECTORS_GET_CONNECTORS_TYPES: 'CONNECTORS_GET_CONNECTORS_TYPES',
64+
CONNECTORS_GET_CONNECTORCOMPONENTS_TYPES:
65+
'CONNECTORS_GET_CONNECTORCOMPONENTS_TYPES',
6466
};
6567

6668
const rolesActionTypes = {
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { connectorActionTypes } from '../../actionTypes';
2+
import getConnectorComponentsApi from '../../../api/connectors/getConnectorComponentsApi';
3+
4+
export const getConnectorComponentAction = ({
5+
connector_id,
6+
workspace,
7+
page,
8+
size,
9+
type,
10+
name,
11+
sort_by,
12+
logical_operator,
13+
filtersParam,
14+
onSuccess,
15+
onFailure,
16+
}: {
17+
connector_id?: any;
18+
workspace?: any;
19+
page?: number;
20+
size?: number;
21+
type?: string;
22+
name?: string;
23+
logical_operator?: any;
24+
filtersParam?: any;
25+
sort_by?: string;
26+
onSuccess?: (res: any) => void;
27+
onFailure?: () => void;
28+
}): TRequestAction => ({
29+
type: connectorActionTypes.getConnectorComponents.request,
30+
payload: {
31+
apiMethod: getConnectorComponentsApi,
32+
isAuthenticated: true,
33+
failureActionType: connectorActionTypes.getConnectorComponents.failure,
34+
successActionType: connectorActionTypes.getConnectorComponents.success,
35+
params: {
36+
type,
37+
page,
38+
size,
39+
name,
40+
sort_by,
41+
filtersParam,
42+
connector_id,
43+
logical_operator,
44+
},
45+
onSuccess,
46+
onFailure,
47+
},
48+
});

src/redux/actions/connectors/getConnectorsTypesAction.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,30 @@ export const getConnectorsTypesAction = ({
55
page,
66
size,
77
type,
8-
name,
8+
connector_type,
99
sort_by,
1010
onSuccess,
1111
onFailure,
1212
}: {
1313
page?: number;
1414
size?: number;
1515
type?: string;
16-
name?: string;
16+
connector_type?: string;
1717
sort_by?: string;
1818
onSuccess?: (res: any) => void;
1919
onFailure?: () => void;
2020
}): TRequestAction => ({
21-
type: connectorActionTypes.ConnectorsTypes.request,
21+
type: connectorActionTypes.connectorsTypes.request,
2222
payload: {
2323
apiMethod: getConnectorsTypesApi,
2424
isAuthenticated: true,
25-
failureActionType: connectorActionTypes.ConnectorsTypes.failure,
26-
successActionType: connectorActionTypes.ConnectorsTypes.success,
25+
failureActionType: connectorActionTypes.connectorsTypes.failure,
26+
successActionType: connectorActionTypes.connectorsTypes.success,
2727
params: {
2828
type,
2929
page,
3030
size,
31-
name,
31+
connector_type,
3232
sort_by,
3333
},
3434
onSuccess,
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { getMyConnectorsAction } from './getMyConnectorsAction';
22
import { getConnectorByIdAction } from './getConnectorByIdAction';
33
import { getConnectorsTypesAction } from './getConnectorsTypesAction';
4-
4+
import { getConnectorComponentAction } from './getConnectorComponentAction';
55
export const connectorsActions = {
66
getMy: getMyConnectorsAction,
77
connectorForId: getConnectorByIdAction,
88
getConnectorsTypes: getConnectorsTypesAction,
9+
getConnectorComponent: getConnectorComponentAction,
910
};

src/redux/reducers/connectorsReducer.ts

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ export interface State {
66
ids: TId[];
77
byId: Record<TId, any>;
88
myConnectorIds: TId[];
9+
connectorComponentsIds: TId[];
10+
connectorTypes: any[];
11+
// connectorTypeIds: TId[];
912
paginated: any;
1013
}
1114

@@ -24,6 +27,9 @@ export const initialState: State = {
2427
ids: [],
2528
byId: {},
2629
myConnectorIds: [],
30+
connectorComponentsIds: [],
31+
connectorTypes: [],
32+
// connectorTypeIds: [],
2733
paginated: {},
2834
};
2935

@@ -53,6 +59,20 @@ const connectorsReducer = (
5359

5460
return { ...newState(state, connectors, action.payload), myConnectorIds };
5561
}
62+
case connectorActionTypes.getConnectorComponents.success: {
63+
const connectorComponents: any[] = camelCaseArray(
64+
action.payload.items as ConnectorsPayload,
65+
);
66+
// debugger;
67+
const connectorComponentsIds: TId[] = connectorComponents.map(
68+
(stack: any) => stack.id,
69+
);
70+
71+
return {
72+
...newState(state, connectorComponents, action.payload),
73+
connectorComponentsIds,
74+
};
75+
}
5676

5777
case connectorActionTypes.getConnectorForId.success: {
5878
const payload: ConnectorPayload = action.payload;
@@ -62,15 +82,18 @@ const connectorsReducer = (
6282
return { ...state, ...newState(state, [connector]) };
6383
}
6484

65-
case connectorActionTypes.ConnectorsTypes.success: {
66-
const connectorsTypes: any[] = camelCaseArray(
67-
action.payload.items as ConnectorsTypesPayload,
85+
case connectorActionTypes.connectorsTypes.success: {
86+
const connectorTypes: any[] = camelCaseArray(
87+
action.payload as ConnectorsTypesPayload,
6888
);
6989

70-
// const connectorIds: TId[] = connectorsTypes.map(
90+
// const connectorTypeIds: TId[] = connectorsTypes.map(
7191
// (connector: any) => connector.id,
7292
// );
73-
return { ...newState(state, connectorsTypes, action.payload) };
93+
return {
94+
...state,
95+
connectorTypes,
96+
};
7497

7598
// return { ...state, ...newState(state, connectorsTypes) };
7699
}

src/redux/sagas/actionTypesHandledByRequestSaga.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ export const actionTypesHandledByRequestSaga: string[] = [
5555

5656
connectorActionTypes.getMyConnectors.request,
5757
connectorActionTypes.getConnectorForId.request,
58-
connectorActionTypes.ConnectorsTypes.request,
58+
connectorActionTypes.connectorsTypes.request,
59+
connectorActionTypes.getConnectorComponents.request,
5960

6061
runActionTypes.getArtifact.request,
6162
runActionTypes.getStep.request,

0 commit comments

Comments
 (0)