Skip to content

Commit 0b76ac7

Browse files
feat: add code repositories (#340)
1 parent f48b3f8 commit 0b76ac7

Some content is hidden

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

70 files changed

+3258
-4
lines changed

global.d.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,27 @@ interface TUser {
5555
created: any;
5656
}
5757

58+
interface TRepository {
59+
id: TId;
60+
created: string;
61+
updated: string;
62+
user: TUser;
63+
workspace: TWorkspace;
64+
name: string;
65+
logo_url: string;
66+
description: string;
67+
config: {
68+
owner: string;
69+
repository: string;
70+
token: string;
71+
};
72+
source: {
73+
module: string;
74+
attribute: string;
75+
type: string;
76+
};
77+
}
78+
5879
interface THubUser {
5980
id: string;
6081
email: string;

src/App.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ html {
5555
padding-right: 0;
5656
}
5757

58-
a[class*='active'] .sidebar-fill path {
58+
a[class*='MenuItem'][class*='active'] .sidebar-fill path {
5959
stroke: transparent !important;
6060
fill: #e8a562 !important;
6161
}
6262

63-
a:hover .sidebar-fill path {
63+
a[class*='MenuItem']:hover .sidebar-fill path {
6464
stroke: transparent !important;
6565
fill: #e8a562 !important;
6666
}

src/api/endpoints.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ export const endpoints = {
3838
my: `/secrets`,
3939
get: (secretId: TId): string => `/secrets/${secretId}`,
4040
},
41+
repositories: {
42+
getAll: (workspace: string) => `/workspaces/${workspace}/code_repositories`,
43+
getByID: (repositoryID: string) => `/code_repositories/${repositoryID}`,
44+
},
4145
StackComponents: {
4246
types: '/component-types',
4347
my: (type: string, workspace: string): string =>
@@ -53,6 +57,10 @@ export const endpoints = {
5357
pipeline: {
5458
get: (pipelineId: TId): string => `/runs?pipeline_id=${pipelineId}`,
5559
},
60+
repository: {
61+
get: (repositoryId: TId): string =>
62+
`/runs?code_repository_id=${repositoryId}`,
63+
},
5664
stack: {
5765
get: (stackId: TId): string => `/runs?stack_id=${stackId}`,
5866
},
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 getRepositories = ({
7+
component_id,
8+
workspace,
9+
sort_by,
10+
logical_operator,
11+
page,
12+
size,
13+
name,
14+
filtersParam,
15+
// id,
16+
authenticationToken,
17+
}: {
18+
component_id?: any;
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<TStack> =>
29+
fetchApiWithAuthRequest({
30+
url: apiUrl(endpoints.repositories.getAll(workspace)),
31+
params: {
32+
component_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 getRepositories;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { fetchApiWithAuthRequest } from '../fetchApi';
2+
import { endpoints } from '../endpoints';
3+
import { httpMethods } from '../constants';
4+
import { apiUrl } from '../apiUrl';
5+
6+
const getRepositoryByID = ({
7+
authenticationToken,
8+
repositoryID,
9+
}: {
10+
authenticationToken: string;
11+
repositoryID: TId;
12+
}): Promise<any> =>
13+
fetchApiWithAuthRequest({
14+
url: apiUrl(endpoints.repositories.getByID(repositoryID)),
15+
method: httpMethods.get,
16+
authenticationToken,
17+
});
18+
19+
export default getRepositoryByID;
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { fetchApiWithAuthRequest } from '../fetchApi';
2+
import { endpoints } from '../endpoints';
3+
import { httpMethods } from '../constants';
4+
import { apiUrl } from '../apiUrl';
5+
6+
const getAllRunsByRepositoryIdApi = ({
7+
authenticationToken,
8+
repositoryID,
9+
sort_by,
10+
logical_operator,
11+
page,
12+
size,
13+
filtersParam,
14+
}: {
15+
sort_by: string;
16+
logical_operator: string;
17+
page: number;
18+
size: number;
19+
filtersParam?: any;
20+
authenticationToken: string;
21+
repositoryID: TId;
22+
}): Promise<TOrganization> =>
23+
fetchApiWithAuthRequest({
24+
url: apiUrl(endpoints.runs.repository.get(repositoryID)),
25+
params: { sort_by, logical_operator, page, size, ...filtersParam }, // todo: get runs by pipeline id please update endpoint
26+
method: httpMethods.get,
27+
authenticationToken,
28+
});
29+
30+
export default getAllRunsByRepositoryIdApi;

src/constants/constantCommands.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ export const constantCommandsToCreateSecret = {
3434
'https://docs.zenml.io/starter-guide/production-fundamentals/secrets-management',
3535
};
3636

37+
export const constantCommandsToCreateRepository = {
38+
documentation:
39+
'https://docs.zenml.io/starter-guide/production-fundamentals/code-repositories',
40+
};
41+
3742
export const constantCommandsToCreatePipeline = {
3843
title: 'Pipeline Cheatsheet',
3944
documentation: 'https://docs.zenml.io/starter-guide/pipelines',

src/redux/actionTypes/constants.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,16 @@ const runActionTypes = {
8585
GRAPH_FOR_RUN_ID: 'GRAPH_FOR_RUN_ID',
8686
};
8787

88+
const repositoryActionTypes = {
89+
REPOSITORY_GET_ALL: 'REPOSITORY_GET_ALL',
90+
REPOSITORY_BY_ID: 'REPOSITORY_BY_ID',
91+
RUNS_GET_BY_REPOSITORY_ID: 'RUNS_GET_BY_REPOSITORY_ID',
92+
};
93+
94+
const repositoryPagesActionTypes = {
95+
REPOSITORY_PAGES_SET_FETCHING: 'REPOSITORY_PAGES_SET_FETCHING',
96+
};
97+
8898
const pipelinePagesActionTypes = {
8999
PIPELINE_PAGES_SET_SELECTED_RUN_IDS: 'PIPELINE_PAGES_SET_SELECTED_RUN_IDS',
90100
PIPELINE_PAGES_SET_FETCHING: 'PIPELINE_PAGES_SET_FETCHING',
@@ -127,12 +137,14 @@ export const actionTypes = {
127137
...runActionTypes,
128138
...runPagesActionTypes,
129139
...rolesActionTypes,
140+
...repositoryActionTypes,
130141
...pipelinePagesActionTypes,
131142
...stackPagesActionTypes,
132143
...stackComponentPagesActionTypes,
133144
...stackComponentActionTypes,
134145
...flavorActionTypes,
135146
...flavorPagesActionTypes,
147+
...repositoryPagesActionTypes,
136148
...serverInfoActionTypes,
137149
};
138150

src/redux/actionTypes/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,7 @@ export * from './secrets';
1818
export * from './stackComponentPages';
1919
export * from './flavors';
2020
export * from './flavorsPages';
21+
export * from './repositories';
22+
export * from './repositoriesPages';
2123
export * from './serverInfo';
2224
export const SHOW_TOASTER_ACTION_TYPE = actionTypes.SHOW_TOASTER;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { actionTypes } from './constants';
2+
import { generateApiActionsTypes } from './generateApiActionsTypes';
3+
4+
export const repositoryActionTypes = {
5+
getRepositories: generateApiActionsTypes(actionTypes.REPOSITORY_GET_ALL),
6+
getRepositoryByID: generateApiActionsTypes(actionTypes.REPOSITORY_BY_ID),
7+
getRunsByRepoID: generateApiActionsTypes(
8+
actionTypes.RUNS_GET_BY_REPOSITORY_ID,
9+
),
10+
};

0 commit comments

Comments
 (0)