Skip to content

Commit dc2e8d4

Browse files
committed
Merge branch 'main' into feat/plugin-version
2 parents 0e15a65 + 1d4fe5c commit dc2e8d4

31 files changed

+305
-6710
lines changed

package-lock.json

Lines changed: 3 additions & 6596 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtron-labs/devtron-fe-common-lib",
3-
"version": "0.1.11-beta-1",
3+
"version": "0.1.13",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",
@@ -109,4 +109,4 @@
109109
"monaco-editor": "0.44.0"
110110
}
111111
}
112-
}
112+
}

src/Common/Constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,8 @@ export const ZERO_TIME_STRING = '0001-01-01T00:00:00Z'
480480
export const EXCLUDED_FALSY_VALUES = [undefined, null, '', NaN] as const
481481

482482
export const API_STATUS_CODES = {
483+
OK: 200,
484+
NO_CONTENT: 204,
483485
BAD_REQUEST: 400,
484486
UNAUTHORIZED: 401,
485487
PERMISSION_DENIED: 403,

src/Common/ErrorScreenManager.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import notFound from '../Assets/Img/ic-not-found.svg'
1818
import badRequest from '../Assets/Img/ic-page-not-found.svg'
1919
import unauthorized from '../Assets/Img/ic-not-authorized.svg'
20-
import { ERROR_STATUS_CODE, ERROR_EMPTY_SCREEN, ROUTES } from './Constants'
20+
import { ERROR_STATUS_CODE, ERROR_EMPTY_SCREEN } from './Constants'
2121
import Reload from './Reload'
2222
import ErrorPage from './ErrorPage'
2323
import { ErrorScreenManagerProps, ImageType } from './Types'
@@ -28,7 +28,7 @@ const ErrorScreenManager = ({
2828
subtitle,
2929
reloadClass,
3030
heightToDeduct,
31-
redirectURL = ROUTES.APP_LIST,
31+
redirectURL,
3232
}: ErrorScreenManagerProps) => {
3333
const getMessage = () => {
3434
switch (code) {

src/Common/MultiSelectCustomization.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,23 @@ import { Checkbox } from './Checkbox'
2323
import { CHECKBOX_VALUE } from './Types'
2424

2525
export const Option = (props) => {
26-
const { selectOption, data } = props
26+
const { selectOption, data, isDisabled } = props
2727

2828
const handleChange = (e) => {
2929
selectOption(data)
3030
}
3131

3232
return (
3333
<div
34-
className="flex left pl-12 cursor dc__gap-8"
34+
className={`flex left pl-12 cursor dc__gap-8 ${isDisabled ? 'dc__disabled' : ''}`}
3535
style={{ background: props.isFocused ? 'var(--N100)' : 'transparent' }}
3636
>
3737
<Checkbox
3838
isChecked={props.isSelected || false}
3939
onChange={handleChange}
4040
value={CHECKBOX_VALUE.CHECKED}
4141
rootClassName="mb-0 w-20"
42+
disabled={isDisabled || false}
4243
/>
4344
<components.Option {...props} />
4445
</div>

src/Shared/Components/ButtonWithSelector/ButtonWithSelector.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { ReactComponent as ICDropdown } from '../../../Assets/Icon/ic-chevron-do
1919
import { PopupMenu } from '../../../Common'
2020
import { ButtonWithSelectorProps } from './types'
2121
import './buttonWithSelector.scss'
22+
import { ButtonWithLoader } from '../ButtonWithLoader'
2223

2324
/**
2425
* Button With Selector
@@ -42,19 +43,21 @@ const ButtonWithSelector = ({
4243
popUpBodyClassName = '',
4344
showPopUp = true,
4445
disabled = false,
46+
isLoading = false,
4547
}: ButtonWithSelectorProps) => {
4648
const [isMenuOpen, setIsMenuOpen] = useState<boolean>(false)
4749

4850
return (
4951
<div className="flexbox bcb-5 br-4">
50-
<button
51-
className={`cta flex h-28 ${showPopUp ? 'dc__no-right-radius' : ''} dc__no-border-imp fs-12 fw-6 lh-20-imp ${className}`}
52+
<ButtonWithLoader
53+
isLoading={isLoading}
54+
rootClassName={`cta flex h-28 ${showPopUp ? 'dc__no-right-radius' : ''} dc__no-border-imp fs-12 fw-6 lh-20-imp ${className}`}
5255
type="button"
5356
onClick={onClick}
54-
disabled={disabled}
57+
disabled={isLoading || disabled}
5558
>
5659
{content}
57-
</button>
60+
</ButtonWithLoader>
5861
{showPopUp && (
5962
<PopupMenu autoClose autoPosition onToggleCallback={setIsMenuOpen}>
6063
<PopupMenu.Button

src/Shared/Components/ButtonWithSelector/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ export interface ButtonWithSelectorProps {
2424
popUpBodyClassName?: string
2525
showPopUp?: boolean
2626
disabled?: boolean
27+
isLoading?: boolean
2728
}

src/Shared/Components/CICDHistory/Artifacts.tsx

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
import { useEffect, useState } from 'react'
1818
import { useParams } from 'react-router'
19+
import { useDownload } from '@Shared/Hooks'
1920
import {
20-
showError,
2121
GenericEmptyState,
2222
ImageTagsContainer,
2323
ClipboardButton,
@@ -122,7 +122,7 @@ const Artifacts = ({
122122
artifact,
123123
blobStorageEnabled,
124124
isArtifactUploaded,
125-
getArtifactPromise,
125+
downloadArtifactUrl,
126126
ciPipelineId,
127127
artifactId,
128128
isJobView,
@@ -137,6 +137,7 @@ const Artifacts = ({
137137
renderCIListHeader,
138138
}: ArtifactType) => {
139139
const { isSuperAdmin } = useSuperAdmin()
140+
const { handleDownload } = useDownload()
140141

141142
const { triggerId, buildId } = useParams<{
142143
triggerId: string
@@ -152,16 +153,10 @@ const Artifacts = ({
152153
}, [copied])
153154

154155
async function handleArtifact() {
155-
try {
156-
const response = await getArtifactPromise()
157-
const b = await (response as any).blob()
158-
const a = document.createElement('a')
159-
a.href = URL.createObjectURL(b)
160-
a.download = `${buildId || triggerId}.zip`
161-
a.click()
162-
} catch (err) {
163-
showError(err)
164-
}
156+
await handleDownload({
157+
downloadUrl: downloadArtifactUrl,
158+
fileName: `${buildId || triggerId}.zip`,
159+
})
165160
}
166161

167162
if (status.toLowerCase() === TERMINAL_STATUS_MAP.RUNNING || status.toLowerCase() === TERMINAL_STATUS_MAP.STARTING) {
@@ -251,7 +246,7 @@ const Artifacts = ({
251246
</CIListItem>
252247
)}
253248
{blobStorageEnabled &&
254-
getArtifactPromise &&
249+
downloadArtifactUrl &&
255250
(type === HistoryComponentType.CD || isArtifactUploaded || isJobView) && (
256251
<CIListItem
257252
type="report"

src/Shared/Components/CICDHistory/TriggerOutput.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ import {
6363
VirtualHistoryArtifactProps,
6464
RunSourceType,
6565
} from './types'
66-
import { getTagDetails, getTriggerDetails, cancelCiTrigger, cancelPrePostCdTrigger, getCDBuildReport } from './service'
66+
import { getTagDetails, getTriggerDetails, cancelCiTrigger, cancelPrePostCdTrigger } from './service'
6767
import { DEFAULT_ENV, TIMEOUT_VALUE, WORKER_POD_BASE_URL } from './constants'
6868
import { GitTriggers } from '../../types'
6969
import warn from '../../../Assets/Icon/ic-warning.svg'
@@ -561,6 +561,8 @@ const HistoryLogs: React.FC<{
561561
workflowId: triggerDetails.id,
562562
}
563563

564+
const CDBuildReportUrl = `app/cd-pipeline/workflow/download/${appId}/${envId}/${pipelineId}/${triggerId}`
565+
564566
const [ref, scrollToTop, scrollToBottom] = useScrollable({
565567
autoBottomScroll: triggerDetails.status.toLowerCase() !== 'succeeded',
566568
})
@@ -665,7 +667,7 @@ const HistoryLogs: React.FC<{
665667
tagsEditable={tagsEditable}
666668
appReleaseTagNames={appReleaseTags}
667669
hideImageTaggingHardDelete={hideImageTaggingHardDelete}
668-
getArtifactPromise={() => getCDBuildReport(appId, envId, pipelineId, triggerId)}
670+
downloadArtifactUrl={CDBuildReportUrl}
669671
type={HistoryComponentType.CD}
670672
renderCIListHeader={renderCIListHeader}
671673
/>

src/Shared/Components/CICDHistory/service.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,6 @@ export const getDeploymentDiffSelector = (
268268
return get(url)
269269
}
270270

271-
export function getCDBuildReport(appId, envId, pipelineId, workflowId) {
272-
return get(`app/cd-pipeline/workflow/download/${appId}/${envId}/${pipelineId}/${workflowId}`)
273-
}
274-
275271
export const getTriggerHistory = async ({
276272
appId,
277273
envId,

src/Shared/Components/CICDHistory/types.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ export interface ArtifactType {
551551
artifact: string
552552
blobStorageEnabled: boolean
553553
isArtifactUploaded?: boolean
554-
getArtifactPromise?: () => Promise<any>
554+
downloadArtifactUrl?: string
555555
isJobView?: boolean
556556
isJobCI?: boolean
557557
type: HistoryComponentType

src/Shared/Components/EnvironmentSelector/EnvironmentSelector.component.tsx

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
/*
2-
* Copyright (c) 2024 Devtron Inc.
3-
* All rights reserved.
4-
5-
* Licensed under the Apache License, Version 2.0 (the "License");
6-
* you may not use this file except in compliance with the License.
7-
* You may obtain a copy of the License at
8-
9-
* http://www.apache.org/licenses/LICENSE-2.0
10-
11-
* Unless required by applicable law or agreed to in writing, software
12-
* distributed under the License is distributed on an "AS IS" BASIS,
13-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
* See the License for the specific language governing permissions and
15-
* limitations under the License.
2+
* Copyright (c) 2024. Devtron Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
1615
*/
1716

1817
import { useMemo } from 'react'

src/Shared/Components/EnvironmentSelector/constants.ts

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
/*
2-
* Copyright (c) 2024 Devtron Inc.
3-
* All rights reserved.
4-
5-
* Licensed under the Apache License, Version 2.0 (the "License");
6-
* you may not use this file except in compliance with the License.
7-
* You may obtain a copy of the License at
8-
9-
* http://www.apache.org/licenses/LICENSE-2.0
10-
11-
* Unless required by applicable law or agreed to in writing, software
12-
* distributed under the License is distributed on an "AS IS" BASIS,
13-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
* See the License for the specific language governing permissions and
15-
* limitations under the License.
2+
* Copyright (c) 2024. Devtron Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
1615
*/
1716

1817
export const ENVIRONMENT_SELECTOR_TEXT = {
Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
/*
2-
* Copyright (c) 2024 Devtron Inc.
3-
* All rights reserved.
4-
5-
* Licensed under the Apache License, Version 2.0 (the "License");
6-
* you may not use this file except in compliance with the License.
7-
* You may obtain a copy of the License at
8-
9-
* http://www.apache.org/licenses/LICENSE-2.0
10-
11-
* Unless required by applicable law or agreed to in writing, software
12-
* distributed under the License is distributed on an "AS IS" BASIS,
13-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
* See the License for the specific language governing permissions and
15-
* limitations under the License.
2+
* Copyright (c) 2024. Devtron Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
1615
*/
1716

1817
export { default as EnvironmentSelector } from './EnvironmentSelector.component'

src/Shared/Components/EnvironmentSelector/service.ts

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
/*
2-
* Copyright (c) 2024 Devtron Inc.
3-
* All rights reserved.
4-
5-
* Licensed under the Apache License, Version 2.0 (the "License");
6-
* you may not use this file except in compliance with the License.
7-
* You may obtain a copy of the License at
8-
9-
* http://www.apache.org/licenses/LICENSE-2.0
10-
11-
* Unless required by applicable law or agreed to in writing, software
12-
* distributed under the License is distributed on an "AS IS" BASIS,
13-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
* See the License for the specific language governing permissions and
15-
* limitations under the License.
2+
* Copyright (c) 2024. Devtron Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
1615
*/
1716

1817
import { get, ResponseType, ROUTES, showError } from '../../../Common'

src/Shared/Components/EnvironmentSelector/types.ts

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
/*
2-
* Copyright (c) 2024 Devtron Inc.
3-
* All rights reserved.
4-
5-
* Licensed under the Apache License, Version 2.0 (the "License");
6-
* you may not use this file except in compliance with the License.
7-
* You may obtain a copy of the License at
8-
9-
* http://www.apache.org/licenses/LICENSE-2.0
10-
11-
* Unless required by applicable law or agreed to in writing, software
12-
* distributed under the License is distributed on an "AS IS" BASIS,
13-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
* See the License for the specific language governing permissions and
15-
* limitations under the License.
2+
* Copyright (c) 2024. Devtron Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
1615
*/
1716

1817
import { OptionType } from '../../../Common'

0 commit comments

Comments
 (0)