@devtron-labs/devtron-fe-common-lib 0.0.48-beta-6 → 0.0.48-beta-8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +75 -0
- package/.eslintrc.js +84 -16
- package/.github/pull_request_template.md +25 -0
- package/.github/workflows/ci.yml +31 -0
- package/.github/workflows/release-package.yml +2 -3
- package/.husky/pre-commit +5 -0
- package/.lintstagedrc +3 -0
- package/.nvmrc +1 -0
- package/dist/Common/BreadCrumb/BreadCrumb.d.ts +1 -1
- package/dist/Common/BreadCrumb/BreadcrumbStore.d.ts +2 -2
- package/dist/Common/Common.service.d.ts +0 -1
- package/dist/Common/Constants.d.ts +1 -2
- package/dist/Common/CustomInput/CustomInput.d.ts +1 -1
- package/dist/Common/CustomInput/Types.d.ts +2 -1
- package/dist/Common/CustomTagSelector/ResizableTagTextArea.d.ts +1 -1
- package/dist/Common/DeleteComponentModal/DeleteComponent.d.ts +1 -1
- package/dist/Common/DevtronProgressing/DevtronProgressing.d.ts +1 -1
- package/dist/Common/Dialogs/ConfirmationDialog.d.ts +6 -6
- package/dist/Common/Dialogs/DeleteDialog.d.ts +1 -1
- package/dist/Common/Dialogs/ForceDeleteDialog.d.ts +1 -1
- package/dist/Common/Dialogs/Types.d.ts +1 -1
- package/dist/Common/EmptyState/EmptyState.d.ts +20 -17
- package/dist/Common/EmptyState/GenericEmptyState.d.ts +1 -1
- package/dist/Common/Error.d.ts +2 -1
- package/dist/Common/ErrorScreenNotFound.d.ts +1 -1
- package/dist/Common/Helper.d.ts +1 -10
- package/dist/Common/ImageTags.d.ts +1 -1
- package/dist/Common/InfoColorBar/InfoColourbar.d.ts +1 -1
- package/dist/Common/Modals/Modal.d.ts +2 -2
- package/dist/Common/Modals/OpaqueModal.d.ts +3 -3
- package/dist/Common/Modals/VisibleModal.d.ts +3 -3
- package/dist/Common/Modals/VisibleModal2.d.ts +3 -3
- package/dist/Common/MultiSelectCustomization.d.ts +1 -1
- package/dist/Common/Policy.Types.d.ts +2 -2
- package/dist/Common/PopupMenu.d.ts +5 -5
- package/dist/Common/Progressing.d.ts +2 -2
- package/dist/Common/RadioGroup/RadioGroup.d.ts +1 -1
- package/dist/Common/ResizableTextarea.d.ts +1 -1
- package/dist/Common/TippyCustomized.d.ts +1 -1
- package/dist/Common/ToastBody.d.ts +5 -5
- package/dist/Common/Types.d.ts +0 -64
- package/dist/Common/index.d.ts +0 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +380 -2083
- package/package.json +19 -4
- package/src/Common/AddCDButton/AddCDButton.tsx +1 -2
- package/src/Common/Api.ts +21 -26
- package/src/Common/AppStatus/AppStatus.tsx +12 -12
- package/src/Common/AppStatus/utils.ts +6 -5
- package/src/Common/BreadCrumb/BreadCrumb.tsx +32 -28
- package/src/Common/BreadCrumb/BreadcrumbStore.tsx +2 -2
- package/src/Common/BreadCrumb/Types.ts +11 -12
- package/src/Common/Checkbox.tsx +17 -19
- package/src/Common/ClipboardButton/ClipboardButton.tsx +1 -1
- package/src/Common/ClipboardButton/__tests__/ClipboardButton.test.tsx +0 -1
- package/src/Common/Common.service.ts +59 -68
- package/src/Common/Constants.ts +9 -10
- package/src/Common/CustomInput/CustomInput.tsx +22 -28
- package/src/Common/CustomInput/Types.ts +4 -3
- package/src/Common/CustomInput/index.ts +1 -1
- package/src/Common/CustomTagSelector/PropagateTagInfo.tsx +15 -18
- package/src/Common/CustomTagSelector/ResizableTagTextArea.tsx +9 -9
- package/src/Common/CustomTagSelector/TagDetails.tsx +9 -3
- package/src/Common/CustomTagSelector/TagLabelSelect.tsx +7 -9
- package/src/Common/CustomTagSelector/TagLabelValueSelector.tsx +31 -35
- package/src/Common/CustomTagSelector/TagSelector.utils.ts +2 -3
- package/src/Common/CustomTagSelector/Types.ts +1 -1
- package/src/Common/CustomTagSelector/ValidationRules.ts +18 -22
- package/src/Common/CustomTagSelector/index.ts +2 -2
- package/src/Common/DebouncedSearch/DebouncedSearch.tsx +2 -1
- package/src/Common/DebouncedSearch/__tests__/DebouncedSearch.test.tsx +0 -1
- package/src/Common/DeleteComponentModal/DeleteComponent.tsx +27 -32
- package/src/Common/DeleteComponentModal/types.ts +1 -1
- package/src/Common/DevtronProgressing/DevtronProgressing.tsx +5 -8
- package/src/Common/Dialogs/ConfirmationDialog.tsx +24 -24
- package/src/Common/Dialogs/DeleteDialog.tsx +3 -5
- package/src/Common/Dialogs/DialogForm.tsx +31 -35
- package/src/Common/Dialogs/ForceDeleteDialog.tsx +13 -7
- package/src/Common/Dialogs/Types.ts +12 -12
- package/src/Common/Dialogs/index.ts +1 -1
- package/src/Common/Drawer/Drawer.tsx +1 -1
- package/src/Common/EmptyState/EmptyState.tsx +13 -17
- package/src/Common/EmptyState/GenericEmptyState.tsx +25 -15
- package/src/Common/Error.tsx +5 -5
- package/src/Common/ErrorScreenNotFound.tsx +9 -12
- package/src/Common/Grid/Grid.tsx +1 -2
- package/src/Common/Helper.tsx +23 -125
- package/src/Common/Hooks/UseClickOutside/UseClickOutside.tsx +1 -1
- package/src/Common/Hooks/UseSuperAdmin/UseSuperAdmin.tsx +1 -1
- package/src/Common/ImageTags.Types.ts +2 -3
- package/src/Common/ImageTags.tsx +61 -66
- package/src/Common/InfoColorBar/InfoColourbar.tsx +10 -5
- package/src/Common/Modals/Modal.tsx +3 -3
- package/src/Common/Modals/OpaqueModal.tsx +25 -18
- package/src/Common/Modals/VisibleModal.tsx +7 -3
- package/src/Common/Modals/VisibleModal2.tsx +20 -15
- package/src/Common/MultiSelectCustomization.tsx +9 -13
- package/src/Common/Policy.Types.ts +38 -38
- package/src/Common/PopupMenu.tsx +10 -9
- package/src/Common/Progressing.tsx +15 -18
- package/src/Common/RJSF/Form.tsx +0 -1
- package/src/Common/RJSF/common/FieldRow.tsx +0 -1
- package/src/Common/RJSF/config.ts +0 -1
- package/src/Common/RJSF/templates/ArrayFieldItemTemplate.tsx +1 -1
- package/src/Common/RJSF/templates/ArrayFieldTemplate.tsx +0 -1
- package/src/Common/RJSF/templates/BaseInput.tsx +0 -1
- package/src/Common/RJSF/templates/ButtonTemplates/AddButton.tsx +0 -1
- package/src/Common/RJSF/templates/ButtonTemplates/RemoveButton.tsx +0 -1
- package/src/Common/RJSF/templates/ButtonTemplates/SubmitButton.tsx +1 -6
- package/src/Common/RJSF/templates/Description.tsx +0 -1
- package/src/Common/RJSF/templates/Field.tsx +14 -3
- package/src/Common/RJSF/templates/FieldErrorTemplate.tsx +6 -9
- package/src/Common/RJSF/templates/ObjectFieldTemplate.tsx +5 -7
- package/src/Common/RJSF/templates/TitleField.tsx +0 -1
- package/src/Common/RJSF/templates/WrapIfAdditionalTemplate.tsx +0 -1
- package/src/Common/RJSF/utils.ts +53 -57
- package/src/Common/RJSF/widgets/Checkbox.tsx +2 -2
- package/src/Common/RJSF/widgets/Select.tsx +0 -1
- package/src/Common/RadioGroup/RadioGroup.tsx +18 -23
- package/src/Common/RadioGroup.tsx +24 -23
- package/src/Common/Reload.tsx +0 -1
- package/src/Common/ResizableTextarea.tsx +18 -17
- package/src/Common/Security/ScanVulnerabilitiesTable.tsx +29 -34
- package/src/Common/ServerError.ts +5 -1
- package/src/Common/TippyCustomized.tsx +41 -38
- package/src/Common/ToastBody.tsx +6 -7
- package/src/Common/Toggle/Toggle.tsx +3 -3
- package/src/Common/Types.ts +12 -81
- package/src/Common/index.ts +0 -1
- package/src/custom.d.ts +7 -7
- package/src/index.ts +1 -1
- package/dist/Common/ChartVersionAndTypeSelector.d.ts +0 -4
- package/src/Common/ChartVersionAndTypeSelector.tsx +0 -78
package/package.json
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devtron-labs/devtron-fe-common-lib",
|
|
3
|
-
"version": "0.0.48-beta-
|
|
3
|
+
"version": "0.0.48-beta-8",
|
|
4
4
|
"description": "Supporting common component library",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
+
"prepare": "husky install",
|
|
8
|
+
"lint": "tsc --noEmit && eslint 'src/**/*.{js,jsx,ts,tsx}' --max-warnings 0",
|
|
9
|
+
"lint-fix": "eslint 'src/**/*.{js,jsx,ts,tsx}' --fix",
|
|
7
10
|
"test": "exit 0",
|
|
8
11
|
"build-lib": "rollup -c --bundleConfigAsCjs",
|
|
9
|
-
"build-watch": "rollup -c --bundleConfigAsCjs -w"
|
|
12
|
+
"build-watch": "rollup -c --bundleConfigAsCjs -w",
|
|
13
|
+
"lint-staged": "lint-staged"
|
|
10
14
|
},
|
|
11
15
|
"repository": {
|
|
12
16
|
"type": "git",
|
|
@@ -30,7 +34,20 @@
|
|
|
30
34
|
"@types/react": "17.0.39",
|
|
31
35
|
"@types/react-dom": "17.0.13",
|
|
32
36
|
"@types/react-router-dom": "^5.3.3",
|
|
37
|
+
"@typescript-eslint/eslint-plugin": "^6.17.0",
|
|
38
|
+
"@typescript-eslint/parser": "^6.17.0",
|
|
39
|
+
"eslint": "^8.56.0",
|
|
40
|
+
"eslint-config-airbnb": "^19.0.4",
|
|
41
|
+
"eslint-config-prettier": "^9.1.0",
|
|
42
|
+
"eslint-plugin-import": "^2.29.1",
|
|
43
|
+
"eslint-plugin-jsx-a11y": "^6.8.0",
|
|
44
|
+
"eslint-plugin-prettier": "^5.1.2",
|
|
45
|
+
"eslint-plugin-react": "^7.33.2",
|
|
46
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
47
|
+
"husky": "^7.0.4",
|
|
48
|
+
"lint-staged": "^12.5.0",
|
|
33
49
|
"moment": "^2.29.4",
|
|
50
|
+
"prettier": "^3.1.1",
|
|
34
51
|
"react-select": "5.2.2",
|
|
35
52
|
"react-toastify": "^8.2.0",
|
|
36
53
|
"rollup": "^3.10.0",
|
|
@@ -50,8 +67,6 @@
|
|
|
50
67
|
"react-router-dom": "^5.3.0"
|
|
51
68
|
},
|
|
52
69
|
"dependencies": {
|
|
53
|
-
"fast-json-patch": "^3.1.1",
|
|
54
|
-
"jsonpath-plus": "^7.2.0",
|
|
55
70
|
"sass": "^1.56.2",
|
|
56
71
|
"tslib": "^2.4.1"
|
|
57
72
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
1
|
import Tippy from '@tippyjs/react'
|
|
3
2
|
import { AddCDButtonProps, TooltipContentProps } from './types'
|
|
4
3
|
import { AddCDPositions } from '../Types'
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
const TooltipContent = ({ tooltipContent }: TooltipContentProps) => {
|
|
7
6
|
if (tooltipContent) {
|
|
8
7
|
return (
|
|
9
8
|
<div className="dc__white-space-pre-wrap">
|
package/src/Common/Api.ts
CHANGED
|
@@ -79,12 +79,12 @@ function handleLogout() {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
async function handleServerError(contentType, response) {
|
|
82
|
-
//Test for HTTP Status Code
|
|
83
|
-
|
|
82
|
+
// Test for HTTP Status Code
|
|
83
|
+
const code: number = response.status
|
|
84
84
|
let status: string = response.statusText || responseMessages[code]
|
|
85
|
-
|
|
85
|
+
const serverError = new ServerErrors({ code, errors: [] })
|
|
86
86
|
if (contentType !== 'application/json') {
|
|
87
|
-
//used for better debugging,
|
|
87
|
+
// used for better debugging,
|
|
88
88
|
status = `${responseMessages[code]}. Please try again.`
|
|
89
89
|
} else {
|
|
90
90
|
const responseBody = await response.json()
|
|
@@ -105,12 +105,12 @@ async function fetchAPI(
|
|
|
105
105
|
preventAutoLogout = false,
|
|
106
106
|
isMultipartRequest?: boolean,
|
|
107
107
|
): Promise<ResponseType> {
|
|
108
|
-
|
|
108
|
+
const options = {
|
|
109
109
|
method: type,
|
|
110
110
|
signal,
|
|
111
111
|
body: data ? JSON.stringify(data) : undefined,
|
|
112
|
+
credentials: 'include' as RequestCredentials,
|
|
112
113
|
}
|
|
113
|
-
options['credentials'] = 'include' as RequestCredentials
|
|
114
114
|
return fetch(
|
|
115
115
|
`${Host}/${url}`,
|
|
116
116
|
!isMultipartRequest
|
|
@@ -121,7 +121,7 @@ async function fetchAPI(
|
|
|
121
121
|
} as RequestInit),
|
|
122
122
|
).then(
|
|
123
123
|
async (response) => {
|
|
124
|
-
|
|
124
|
+
const contentType = response.headers.get('Content-Type')
|
|
125
125
|
if (response.status === 401) {
|
|
126
126
|
if (preventAutoLogout) {
|
|
127
127
|
throw new ServerErrors({
|
|
@@ -140,22 +140,23 @@ async function fetchAPI(
|
|
|
140
140
|
if (contentType === 'application/json') {
|
|
141
141
|
return response.json().then((responseBody) => {
|
|
142
142
|
if (responseBody.code >= 300 && responseBody.code <= 599) {
|
|
143
|
-
//Test Code in Response Body, despite successful HTTP Response Code
|
|
143
|
+
// Test Code in Response Body, despite successful HTTP Response Code
|
|
144
144
|
throw new ServerErrors({ code: responseBody.code, errors: responseBody.errors })
|
|
145
145
|
} else {
|
|
146
|
-
//Successfull Response. Expected Response Type {code, result, status}
|
|
146
|
+
// Successfull Response. Expected Response Type {code, result, status}
|
|
147
147
|
return responseBody
|
|
148
148
|
}
|
|
149
149
|
})
|
|
150
|
-
}
|
|
151
|
-
|
|
150
|
+
}
|
|
151
|
+
if (contentType === 'octet-stream' || contentType === 'application/octet-stream') {
|
|
152
|
+
// used in getArtifact() API only
|
|
152
153
|
return response
|
|
153
154
|
}
|
|
154
155
|
}
|
|
155
156
|
},
|
|
156
157
|
(error) => {
|
|
157
|
-
//Network call fails. Handle Failed to Fetch
|
|
158
|
-
|
|
158
|
+
// Network call fails. Handle Failed to Fetch
|
|
159
|
+
const err = {
|
|
159
160
|
code: 0,
|
|
160
161
|
userMessage: error.message,
|
|
161
162
|
internalMessage: error.message,
|
|
@@ -176,7 +177,7 @@ function fetchInTime(
|
|
|
176
177
|
const controller = new AbortController()
|
|
177
178
|
const { signal } = controller
|
|
178
179
|
const timeoutPromise: Promise<ResponseType> = new Promise((resolve, reject) => {
|
|
179
|
-
|
|
180
|
+
const timeout = options?.timeout ? options.timeout : RequestTimeout
|
|
180
181
|
setTimeout(() => {
|
|
181
182
|
controller.abort()
|
|
182
183
|
reject({
|
|
@@ -211,18 +212,12 @@ export const post = (
|
|
|
211
212
|
data: object,
|
|
212
213
|
options?: APIOptions,
|
|
213
214
|
isMultipartRequest?: boolean,
|
|
214
|
-
): Promise<ResponseType> =>
|
|
215
|
-
return fetchInTime(url, 'POST', data, options, isMultipartRequest)
|
|
216
|
-
}
|
|
215
|
+
): Promise<ResponseType> => fetchInTime(url, 'POST', data, options, isMultipartRequest)
|
|
217
216
|
|
|
218
|
-
export const put = (url: string, data: object, options?: APIOptions): Promise<ResponseType> =>
|
|
219
|
-
|
|
220
|
-
}
|
|
217
|
+
export const put = (url: string, data: object, options?: APIOptions): Promise<ResponseType> =>
|
|
218
|
+
fetchInTime(url, 'PUT', data, options)
|
|
221
219
|
|
|
222
|
-
export const get = (url: string, options?: APIOptions): Promise<ResponseType> =>
|
|
223
|
-
return fetchInTime(url, 'GET', null, options)
|
|
224
|
-
}
|
|
220
|
+
export const get = (url: string, options?: APIOptions): Promise<ResponseType> => fetchInTime(url, 'GET', null, options)
|
|
225
221
|
|
|
226
|
-
export const trash = (url: string, data?: object, options?: APIOptions): Promise<ResponseType> =>
|
|
227
|
-
|
|
228
|
-
}
|
|
222
|
+
export const trash = (url: string, data?: object, options?: APIOptions): Promise<ResponseType> =>
|
|
223
|
+
fetchInTime(url, 'DELETE', data, options)
|
|
@@ -25,24 +25,24 @@ export default function AppStatus({
|
|
|
25
25
|
const renderIcon = () => {
|
|
26
26
|
if (iconClass) {
|
|
27
27
|
return <span className={`dc__app-summary__icon icon-dim-16 ${iconClass} ${iconClass}--node`} />
|
|
28
|
-
}
|
|
28
|
+
}
|
|
29
|
+
if (isVirtualEnv) {
|
|
29
30
|
return (
|
|
30
31
|
<span
|
|
31
32
|
className={`dc__app-summary__icon icon-dim-16 ${StatusConstants.NOT_DEPLOYED.lowerCase} ${StatusConstants.NOT_DEPLOYED.lowerCase}--node`}
|
|
32
33
|
/>
|
|
33
34
|
)
|
|
34
|
-
} else {
|
|
35
|
-
return (
|
|
36
|
-
<Tippy
|
|
37
|
-
className="default-tt w-200"
|
|
38
|
-
arrow={false}
|
|
39
|
-
placement="top"
|
|
40
|
-
content="To fetch app status for GitOps based deployments open the app detail page"
|
|
41
|
-
>
|
|
42
|
-
<InfoIcon className="icon-dim-16 fcn-6" />
|
|
43
|
-
</Tippy>
|
|
44
|
-
)
|
|
45
35
|
}
|
|
36
|
+
return (
|
|
37
|
+
<Tippy
|
|
38
|
+
className="default-tt w-200"
|
|
39
|
+
arrow={false}
|
|
40
|
+
placement="top"
|
|
41
|
+
content="To fetch app status for GitOps based deployments open the app detail page"
|
|
42
|
+
>
|
|
43
|
+
<InfoIcon className="icon-dim-16 fcn-6" />
|
|
44
|
+
</Tippy>
|
|
45
|
+
)
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
return hideStatusMessage ? (
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { TIMELINE_STATUS } from './constants'
|
|
2
2
|
|
|
3
3
|
export const triggerStatus = (triggerDetailStatus: string): string => {
|
|
4
|
-
|
|
4
|
+
const triggerStatus = triggerDetailStatus?.toUpperCase()
|
|
5
5
|
if (triggerStatus === TIMELINE_STATUS.ABORTED || triggerStatus === TIMELINE_STATUS.DEGRADED) {
|
|
6
6
|
return 'Failed'
|
|
7
|
-
}
|
|
7
|
+
}
|
|
8
|
+
if (triggerStatus === TIMELINE_STATUS.HEALTHY) {
|
|
8
9
|
return 'Succeeded'
|
|
9
|
-
}
|
|
10
|
+
}
|
|
11
|
+
if (triggerStatus === TIMELINE_STATUS.INPROGRESS) {
|
|
10
12
|
return 'Inprogress'
|
|
11
|
-
} else {
|
|
12
|
-
return triggerDetailStatus
|
|
13
13
|
}
|
|
14
|
+
return triggerDetailStatus
|
|
14
15
|
}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useMemo, useEffect } from 'react'
|
|
2
|
+
import * as React from 'react'
|
|
2
3
|
import { Link, useRouteMatch, useParams } from 'react-router-dom'
|
|
3
4
|
import { useBreadcrumbContext } from './BreadcrumbStore'
|
|
4
5
|
import { ConditionalWrap } from '../Helper'
|
|
5
6
|
import { Breadcrumb, Breadcrumbs, UseBreadcrumbOptionalProps, UseBreadcrumbState } from './Types'
|
|
7
|
+
|
|
6
8
|
export const BreadcrumbContext = React.createContext(null)
|
|
7
9
|
|
|
8
10
|
export function useBreadcrumb(props?: UseBreadcrumbOptionalProps, deps?: any[]): UseBreadcrumbState {
|
|
9
|
-
|
|
11
|
+
const sep = props?.sep || '/'
|
|
10
12
|
deps = deps || []
|
|
11
13
|
const { url, path } = useRouteMatch()
|
|
12
14
|
const params = useParams()
|
|
@@ -30,7 +32,7 @@ export function useBreadcrumb(props?: UseBreadcrumbOptionalProps, deps?: any[]):
|
|
|
30
32
|
setState((state) => ({ ...state, alias: tempAlias }))
|
|
31
33
|
}
|
|
32
34
|
|
|
33
|
-
|
|
35
|
+
const levels: Breadcrumb[] = useMemo(() => {
|
|
34
36
|
const paths = path.split('/').filter(Boolean)
|
|
35
37
|
const urls = url.split('/').filter(Boolean)
|
|
36
38
|
return paths.map((path, idx) => {
|
|
@@ -41,29 +43,31 @@ export function useBreadcrumb(props?: UseBreadcrumbOptionalProps, deps?: any[]):
|
|
|
41
43
|
return crumb
|
|
42
44
|
})
|
|
43
45
|
}, [path, url])
|
|
44
|
-
const { res: breadcrumbs } = useMemo(
|
|
45
|
-
|
|
46
|
-
(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
? state.alias[name]
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
46
|
+
const { res: breadcrumbs } = useMemo(
|
|
47
|
+
() =>
|
|
48
|
+
levels.reduce(
|
|
49
|
+
(agg, curr, idx) => {
|
|
50
|
+
const { res, prefix } = agg
|
|
51
|
+
const { to, name } = curr
|
|
52
|
+
res.push({
|
|
53
|
+
to:
|
|
54
|
+
!state.alias[name]?.component || (state.alias[name]?.component && state.alias[name]?.linked)
|
|
55
|
+
? `${prefix}${to}`
|
|
56
|
+
: null,
|
|
57
|
+
name:
|
|
58
|
+
typeof state.alias[name] === 'object'
|
|
59
|
+
? state.alias[name]?.component
|
|
60
|
+
? state.alias[name].component
|
|
61
|
+
: null
|
|
62
|
+
: state.alias[name] || name,
|
|
63
|
+
className: curr.className || '',
|
|
64
|
+
})
|
|
65
|
+
return { res, prefix: `${prefix}${curr.to}${sep}` }
|
|
66
|
+
},
|
|
67
|
+
{ res: [], prefix: '/' },
|
|
68
|
+
),
|
|
69
|
+
[levels, state],
|
|
70
|
+
)
|
|
67
71
|
|
|
68
72
|
return { breadcrumbs, setCrumb, resetCrumb }
|
|
69
73
|
}
|
|
@@ -76,7 +80,7 @@ export const BreadCrumb: React.FC<Breadcrumbs> = ({
|
|
|
76
80
|
const { url } = useRouteMatch()
|
|
77
81
|
const filteredCrumbs = breadcrumbs.filter((crumb) => !!crumb.name)
|
|
78
82
|
return (
|
|
79
|
-
|
|
83
|
+
<>
|
|
80
84
|
{filteredCrumbs.map((breadcrumb, idx) => (
|
|
81
85
|
<React.Fragment key={idx}>
|
|
82
86
|
<ConditionalWrap
|
|
@@ -100,6 +104,6 @@ export const BreadCrumb: React.FC<Breadcrumbs> = ({
|
|
|
100
104
|
)}
|
|
101
105
|
</React.Fragment>
|
|
102
106
|
))}
|
|
103
|
-
|
|
107
|
+
</>
|
|
104
108
|
)
|
|
105
109
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useContext, createContext, useState } from 'react'
|
|
2
2
|
|
|
3
3
|
const initialState = {
|
|
4
4
|
alias: {},
|
|
@@ -15,7 +15,7 @@ export const BreadcrumbContext = createContext({
|
|
|
15
15
|
})
|
|
16
16
|
|
|
17
17
|
export function useBreadcrumbContext() {
|
|
18
|
-
const context =
|
|
18
|
+
const context = useContext(BreadcrumbContext)
|
|
19
19
|
if (!context) {
|
|
20
20
|
throw new Error(`breadcrumb components cannot be used outside Breadcrumb context`)
|
|
21
21
|
}
|
|
@@ -1,24 +1,23 @@
|
|
|
1
|
-
|
|
2
1
|
export interface Breadcrumb {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
to: string
|
|
3
|
+
name: string
|
|
4
|
+
className?: string
|
|
6
5
|
}
|
|
7
6
|
|
|
8
7
|
export interface UseBreadcrumbState {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
breadcrumbs: Breadcrumb[]
|
|
9
|
+
setCrumb: (props: { [key: string]: any }) => void
|
|
10
|
+
resetCrumb: (props: string[]) => void
|
|
12
11
|
}
|
|
13
12
|
|
|
14
13
|
export interface AdvancedAlias {
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
component: any
|
|
15
|
+
linked: boolean
|
|
17
16
|
}
|
|
18
17
|
|
|
19
18
|
export interface UseBreadcrumbProps {
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
sep?: string
|
|
20
|
+
alias?: { [key: string]: AdvancedAlias | any }
|
|
22
21
|
}
|
|
23
22
|
|
|
24
23
|
export interface Breadcrumbs {
|
|
@@ -27,4 +26,4 @@ export interface Breadcrumbs {
|
|
|
27
26
|
className?: string
|
|
28
27
|
}
|
|
29
28
|
|
|
30
|
-
export type UseBreadcrumbOptionalProps = UseBreadcrumbProps | null
|
|
29
|
+
export type UseBreadcrumbOptionalProps = UseBreadcrumbProps | null
|
package/src/Common/Checkbox.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Component } from 'react'
|
|
2
2
|
import { CheckboxProps } from './Types'
|
|
3
3
|
|
|
4
4
|
/*
|
|
@@ -12,25 +12,23 @@ Valid States of Checkbox:
|
|
|
12
12
|
*/
|
|
13
13
|
export class Checkbox extends Component<CheckboxProps> {
|
|
14
14
|
render() {
|
|
15
|
-
|
|
15
|
+
const rootClassName = `${this.props.rootClassName ? this.props.rootClassName : ''}`
|
|
16
16
|
return (
|
|
17
|
-
|
|
18
|
-
<
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
</label>
|
|
33
|
-
</>
|
|
17
|
+
<label className={`dc__position-rel flex left cursor ${rootClassName}`} onClick={this.props?.onClick}>
|
|
18
|
+
<input
|
|
19
|
+
type="checkbox"
|
|
20
|
+
className="form__checkbox"
|
|
21
|
+
disabled={this.props.disabled}
|
|
22
|
+
value={this.props.value}
|
|
23
|
+
onChange={this.props.onChange}
|
|
24
|
+
tabIndex={this.props.tabIndex}
|
|
25
|
+
checked={this.props.isChecked}
|
|
26
|
+
id={this.props.id}
|
|
27
|
+
data-testid={this.props.dataTestId}
|
|
28
|
+
/>
|
|
29
|
+
<span className="form__checkbox-container" data-testid={`${this.props.dataTestId}-chk-span`} />
|
|
30
|
+
<span className="form__checkbox-label">{this.props.children}</span>
|
|
31
|
+
</label>
|
|
34
32
|
)
|
|
35
33
|
}
|
|
36
34
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import moment from 'moment'
|
|
2
|
-
import {get, post} from './Api'
|
|
1
|
+
import moment from 'moment'
|
|
2
|
+
import { get, post } from './Api'
|
|
3
3
|
import { ROUTES } from './Constants'
|
|
4
|
-
import { sortCallback } from './Helper'
|
|
4
|
+
import { sortCallback } from './Helper'
|
|
5
5
|
import {
|
|
6
6
|
TeamList,
|
|
7
7
|
ResponseType,
|
|
@@ -17,23 +17,21 @@ import {
|
|
|
17
17
|
} from './Types'
|
|
18
18
|
|
|
19
19
|
export const getTeamListMin = (): Promise<TeamList> => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
});
|
|
36
|
-
};
|
|
20
|
+
// ignore active field
|
|
21
|
+
const URL = `${ROUTES.PROJECT_LIST_MIN}`
|
|
22
|
+
return get(URL).then((response) => {
|
|
23
|
+
let list = []
|
|
24
|
+
if (response && response.result && Array.isArray(response.result)) {
|
|
25
|
+
list = response.result
|
|
26
|
+
}
|
|
27
|
+
list = list.sort((a, b) => sortCallback('name', a, b))
|
|
28
|
+
return {
|
|
29
|
+
code: response.code,
|
|
30
|
+
status: response.status,
|
|
31
|
+
result: list,
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
}
|
|
37
35
|
|
|
38
36
|
interface UserRole extends ResponseType {
|
|
39
37
|
result?: {
|
|
@@ -59,14 +57,12 @@ export function getUserRole(appName?: string): Promise<UserRole> {
|
|
|
59
57
|
return get(`${ROUTES.USER_CHECK_ROLE}${appName ? `?appName=${appName}` : ''}`)
|
|
60
58
|
}
|
|
61
59
|
|
|
62
|
-
export function setImageTags(request, pipelineId: number, artifactId: number){
|
|
63
|
-
return post(`${ROUTES.IMAGE_TAGGING}/${pipelineId}/${artifactId}`,request
|
|
60
|
+
export function setImageTags(request, pipelineId: number, artifactId: number) {
|
|
61
|
+
return post(`${ROUTES.IMAGE_TAGGING}/${pipelineId}/${artifactId}`, request)
|
|
64
62
|
}
|
|
65
63
|
|
|
66
64
|
const processURL = (url: string, params: object) => {
|
|
67
|
-
const validParams = Object.keys(params).filter((key) =>
|
|
68
|
-
return params[key] != null
|
|
69
|
-
})
|
|
65
|
+
const validParams = Object.keys(params).filter((key) => params[key] != null)
|
|
70
66
|
|
|
71
67
|
if (!validParams.length) {
|
|
72
68
|
return url
|
|
@@ -75,11 +71,11 @@ const processURL = (url: string, params: object) => {
|
|
|
75
71
|
const queryString = validParams
|
|
76
72
|
.map((key) => {
|
|
77
73
|
if (Array.isArray(params[key])) {
|
|
78
|
-
return `${key}=${params[key].join(',')}`
|
|
74
|
+
return `${key}=${params[key].join(',')}`
|
|
79
75
|
}
|
|
80
76
|
return `${key}=${params[key]}`
|
|
81
77
|
})
|
|
82
|
-
.join('&')
|
|
78
|
+
.join('&')
|
|
83
79
|
|
|
84
80
|
return `${url}?${queryString}`
|
|
85
81
|
}
|
|
@@ -136,25 +132,23 @@ const cdMaterialListModal = (artifacts: any[], offset: number, artifactId?: numb
|
|
|
136
132
|
// It is going to be null but required in type so can't remove
|
|
137
133
|
lastExecution: material.lastExecution,
|
|
138
134
|
materialInfo: material.material_info
|
|
139
|
-
? material.material_info.map((mat) => {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
}
|
|
157
|
-
})
|
|
135
|
+
? material.material_info.map((mat) => ({
|
|
136
|
+
modifiedTime: mat.modifiedTime
|
|
137
|
+
? moment(mat.modifiedTime).format('ddd, DD MMM YYYY, hh:mm A')
|
|
138
|
+
: '',
|
|
139
|
+
commitLink: createGitCommitUrl(mat.url, mat.revision),
|
|
140
|
+
author: mat.author || '',
|
|
141
|
+
message: mat.message || '',
|
|
142
|
+
revision: mat.revision || '',
|
|
143
|
+
tag: mat.tag || '',
|
|
144
|
+
webhookData: mat.webhookData || '',
|
|
145
|
+
url: mat.url || '',
|
|
146
|
+
branch:
|
|
147
|
+
(material.ciConfigureSourceType === SourceTypeMap.WEBHOOK
|
|
148
|
+
? material.ciConfigureSourceValue
|
|
149
|
+
: mat.branch) || '',
|
|
150
|
+
type: material.ciConfigureSourceType || '',
|
|
151
|
+
}))
|
|
158
152
|
: [],
|
|
159
153
|
filterState,
|
|
160
154
|
appliedFiltersTimestamp: material.appliedFiltersTimestamp ?? '',
|
|
@@ -237,9 +231,7 @@ const processCDMaterialServiceResponse = (
|
|
|
237
231
|
// TODO: On update of service would remove from here
|
|
238
232
|
const filteredMaterials =
|
|
239
233
|
filter && filter === CDMaterialFilterQuery.RESOURCE
|
|
240
|
-
? materials.filter((material) =>
|
|
241
|
-
return material.filterState === FilterStates.ALLOWED
|
|
242
|
-
})
|
|
234
|
+
? materials.filter((material) => material.filterState === FilterStates.ALLOWED)
|
|
243
235
|
: materials
|
|
244
236
|
|
|
245
237
|
return {
|
|
@@ -263,7 +255,7 @@ export const genericCDMaterialsService = (
|
|
|
263
255
|
): Promise<CDMaterialResponseType> => {
|
|
264
256
|
// TODO: On update of service would remove from here
|
|
265
257
|
const manipulatedParams = getSanitizedQueryParams(queryParams)
|
|
266
|
-
|
|
258
|
+
|
|
267
259
|
let URL
|
|
268
260
|
switch (serviceType) {
|
|
269
261
|
case CDMaterialServiceEnum.ROLLBACK:
|
|
@@ -272,13 +264,16 @@ export const genericCDMaterialsService = (
|
|
|
272
264
|
|
|
273
265
|
// Meant for handling getCDMaterialList
|
|
274
266
|
default:
|
|
275
|
-
URL = processURL(`${ROUTES.CD_MATERIAL_GET}/${cdMaterialID}/material`, {
|
|
267
|
+
URL = processURL(`${ROUTES.CD_MATERIAL_GET}/${cdMaterialID}/material`, {
|
|
268
|
+
...manipulatedParams,
|
|
269
|
+
stage: stageMap[stage],
|
|
270
|
+
})
|
|
276
271
|
break
|
|
277
272
|
}
|
|
278
273
|
|
|
279
|
-
return get(URL, { signal }).then((response) =>
|
|
280
|
-
|
|
281
|
-
|
|
274
|
+
return get(URL, { signal }).then((response) =>
|
|
275
|
+
processCDMaterialServiceResponse(response.result, stage, queryParams.offset, queryParams.filter),
|
|
276
|
+
)
|
|
282
277
|
}
|
|
283
278
|
|
|
284
279
|
export function extractImage(image: string): string {
|
|
@@ -287,29 +282,25 @@ export function extractImage(image: string): string {
|
|
|
287
282
|
|
|
288
283
|
export function createGitCommitUrl(url: string, revision: string): string {
|
|
289
284
|
if (!url || !revision) {
|
|
290
|
-
return
|
|
285
|
+
return 'NA'
|
|
291
286
|
}
|
|
292
|
-
if (url.indexOf(
|
|
293
|
-
|
|
287
|
+
if (url.indexOf('gitlab') > 0 || url.indexOf('github') > 0 || url.indexOf('azure') > 0) {
|
|
288
|
+
const urlpart = url.split('@')
|
|
294
289
|
if (urlpart.length > 1) {
|
|
295
|
-
return
|
|
290
|
+
return `https://${urlpart[1].split('.git')[0]}/commit/${revision}`
|
|
296
291
|
}
|
|
297
292
|
if (urlpart.length == 1) {
|
|
298
|
-
return urlpart[0].split(
|
|
293
|
+
return `${urlpart[0].split('.git')[0]}/commit/${revision}`
|
|
299
294
|
}
|
|
300
295
|
}
|
|
301
|
-
if (url.indexOf(
|
|
302
|
-
|
|
296
|
+
if (url.indexOf('bitbucket') > 0) {
|
|
297
|
+
const urlpart = url.split('@')
|
|
303
298
|
if (urlpart.length > 1) {
|
|
304
|
-
return
|
|
299
|
+
return `https://${urlpart[1].split('.git')[0]}/commits/${revision}`
|
|
305
300
|
}
|
|
306
301
|
if (urlpart.length == 1) {
|
|
307
|
-
return urlpart[0].split(
|
|
302
|
+
return `${urlpart[0].split('.git')[0]}/commits/${revision}`
|
|
308
303
|
}
|
|
309
304
|
}
|
|
310
|
-
return
|
|
305
|
+
return 'NA'
|
|
311
306
|
}
|
|
312
|
-
|
|
313
|
-
export function fetchChartTemplateVersions() {
|
|
314
|
-
return get(`${ROUTES.DEPLOYMENT_TEMPLATE_LIST}?appId=-1&envId=-1`)
|
|
315
|
-
}
|