Skip to content

Commit 7670c7e

Browse files
committed
Merge branch 'main' into feat/aws-code-commit
2 parents a594275 + 13753b5 commit 7670c7e

24 files changed

+790
-12
lines changed

package-lock.json

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtron-labs/devtron-fe-common-lib",
3-
"version": "0.0.95-beta-2",
3+
"version": "0.0.98",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

src/Assets/Icon/ic-arrow-down.svg

Lines changed: 19 additions & 0 deletions
Loading

src/Common/Constants.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ export const FALLBACK_REQUEST_TIMEOUT = 60000
2020
export const Host = window?.__ORCHESTRATOR_ROOT__ ?? '/orchestrator'
2121

2222
export const DOCUMENTATION_HOME_PAGE = 'https://docs.devtron.ai'
23+
export const DOCUMENTATION_VERSION = '/v/v0.7'
2324
export const DISCORD_LINK = 'https://discord.devtron.ai/'
2425
export const DOCUMENTATION = {
25-
APP_TAGS: `${DOCUMENTATION_HOME_PAGE}/v/v0.6/usage/applications/create-application#tags`,
26-
APP_OVERVIEW_TAGS: `${DOCUMENTATION_HOME_PAGE}/v/v0.6/usage/applications/overview#manage-tags`,
27-
BLOB_STORAGE: `${DOCUMENTATION_HOME_PAGE}/v/v0.6/getting-started/install/installation-configuration#configuration-of-blob-storage`,
26+
APP_TAGS: `${DOCUMENTATION_HOME_PAGE}${DOCUMENTATION_VERSION}/usage/applications/create-application#tags`,
27+
APP_OVERVIEW_TAGS: `${DOCUMENTATION_HOME_PAGE}${DOCUMENTATION_VERSION}/usage/applications/overview#manage-tags`,
28+
BLOB_STORAGE: `${DOCUMENTATION_HOME_PAGE}${DOCUMENTATION_VERSION}/getting-started/install/installation-configuration#configuration-of-blob-storage`,
2829
}
2930

3031
export const PATTERNS = {

src/Common/Helper.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import moment from 'moment'
2323
import { useLocation } from 'react-router-dom'
2424
import { toast } from 'react-toastify'
2525
import YAML from 'yaml'
26-
import { ERROR_EMPTY_SCREEN, SortingOrder, TOKEN_COOKIE_NAME, EXCLUDED_FALSY_VALUES, DISCORD_LINK } from './Constants'
26+
import { ERROR_EMPTY_SCREEN, SortingOrder, EXCLUDED_FALSY_VALUES, DISCORD_LINK, ZERO_TIME_STRING } from './Constants'
2727
import { ServerErrors } from './ServerError'
2828
import { toastAccessDenied } from './ToastBody'
2929
import { AsyncOptions, AsyncState, UseSearchString } from './Types'
@@ -301,10 +301,13 @@ export function useForm(stateSchema, validationSchema = {}, callback) {
301301
export function handleUTCTime(ts: string, isRelativeTime = false) {
302302
let timestamp = ''
303303
try {
304-
if (ts && ts.length) {
304+
if (ts && ts.length && ts !== ZERO_TIME_STRING) {
305305
const date = moment(ts)
306-
if (isRelativeTime) timestamp = date.fromNow()
307-
else timestamp = date.format(DATE_TIME_FORMAT_STRING)
306+
if (isRelativeTime) {
307+
timestamp = date.fromNow()
308+
} else {
309+
timestamp = date.format(DATE_TIME_FORMAT_STRING)
310+
}
308311
}
309312
} catch (error) {
310313
console.error('Error Parsing Date:', ts)
@@ -726,10 +729,10 @@ export const handleRelativeDateSorting = (dateStringA, dateStringB, sortOrder) =
726729
return 0 // Both dates are invalid, consider them equal
727730
} else if (isNaN(dateA)) {
728731
// dateA is invalid, move it to the end if sorting ASC, otherwise to the beginning
729-
return sortOrder === SortingOrder.ASC ? -1 : 1
732+
return sortOrder === SortingOrder.ASC ? 1 : -1
730733
} else if (isNaN(dateB)) {
731734
// dateB is invalid, move it to the end if sorting ASC, otherwise to the beginning
732-
return sortOrder === SortingOrder.ASC ? 1 : -1
735+
return sortOrder === SortingOrder.ASC ? -1 : 1
733736
} else {
734737
return sortOrder === SortingOrder.ASC ? dateB - dateA : dateA - dateB
735738
}

src/Common/Reload.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ import loadingFailure from '../Assets/Img/ic-loading-failure.png'
1818
import { ReloadType } from './Types'
1919
import { refresh } from './Helper'
2020

21+
/**
22+
* @deprecated Use APIResponseHandler (Preferred) or error screen manager instead
23+
*/
2124
export default function Reload({ reload, className = '', heightToDeduct = 0 }: ReloadType) {
2225
return (
2326
<article
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
/*
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.
15+
*/
16+
17+
import { Drawer, GenericEmptyState, useAsync } from '../../../Common'
18+
import { getArtifactInfo, getCITriggerInfo } from '../../Services/app.service'
19+
import { APIResponseHandler } from '../APIResponseHandler'
20+
import { ReactComponent as ICClose } from '../../../Assets/Icon/ic-close.svg'
21+
import { ReactComponent as ICArrowDown } from '../../../Assets/Icon/ic-arrow-down.svg'
22+
import { Artifacts, HistoryComponentType } from '../CICDHistory'
23+
import MaterialHistory from '../MaterialHistory/MaterialHistory.component'
24+
import { ArtifactInfoModalProps } from './types'
25+
26+
const ArtifactInfoModal = ({
27+
envId,
28+
ciArtifactId,
29+
handleClose,
30+
renderCIListHeader,
31+
fetchOnlyArtifactInfo = false,
32+
}: ArtifactInfoModalProps) => {
33+
const [isInfoLoading, artifactInfo, infoError, refetchArtifactInfo] = useAsync(
34+
() =>
35+
fetchOnlyArtifactInfo
36+
? getArtifactInfo({
37+
ciArtifactId,
38+
})
39+
: getCITriggerInfo({
40+
ciArtifactId,
41+
envId,
42+
}),
43+
[ciArtifactId, envId, fetchOnlyArtifactInfo],
44+
)
45+
46+
const isArtifactInfoAvailable = !!artifactInfo?.materials?.length
47+
const showDescription = isArtifactInfoAvailable && !fetchOnlyArtifactInfo
48+
49+
return (
50+
<Drawer position="right" width="800px" onEscape={handleClose}>
51+
<div data-testid="visible-modal-commit-info" className="flexbox-col h-100">
52+
<div className="flex dc__content-space py-10 px-20 cn-9 bcn-0 dc__border-bottom">
53+
<div className="flexbox-col dc__content-center">
54+
{!infoError &&
55+
(isInfoLoading ? (
56+
<>
57+
<div className="shimmer h-24 mb-2 w-200" />
58+
<div className="shimmer h-18 w-250" />
59+
</>
60+
) : (
61+
<>
62+
<h1 className="fs-16 fw-6 lh-24 m-0 dc__truncate">
63+
{showDescription
64+
? artifactInfo?.appName
65+
: `Source & image details of ${artifactInfo?.appName}`}
66+
</h1>
67+
{showDescription && (
68+
<p className="fs-13 cn-7 lh-1-5 m-0 dc__truncate">
69+
Deployed on {artifactInfo.environmentName} at{' '}
70+
{artifactInfo.lastDeployedTime}
71+
&nbsp;by {artifactInfo.triggeredByEmail}
72+
</p>
73+
)}
74+
</>
75+
))}
76+
</div>
77+
<button
78+
data-testid="visible-modal-close"
79+
type="button"
80+
className="dc__transparent flex"
81+
onClick={handleClose}
82+
aria-label="Close modal"
83+
>
84+
<ICClose className="icon-dim-24 icon-use-fill-n6" />
85+
</button>
86+
</div>
87+
<div className="flexbox-col flex-grow-1 dc__overflow-scroll dc__window-bg h-100">
88+
<APIResponseHandler
89+
isLoading={isInfoLoading}
90+
progressingProps={{
91+
pageLoader: true,
92+
}}
93+
error={infoError}
94+
errorScreenManagerProps={{
95+
code: infoError?.code,
96+
reload: refetchArtifactInfo,
97+
}}
98+
>
99+
{isArtifactInfoAvailable ? (
100+
<div className="select-material">
101+
{artifactInfo.materials.map((material) => (
102+
<MaterialHistory material={material} pipelineName="" key={material.id} />
103+
))}
104+
<div className="dc__dashed_icon_grid-container">
105+
<hr className="dc__dotted-line" />
106+
<div className="flex">
107+
<ICArrowDown className="scn-6" />
108+
</div>
109+
<hr className="dc__dotted-line" />
110+
</div>
111+
<Artifacts
112+
status=""
113+
artifact={artifactInfo.image}
114+
blobStorageEnabled
115+
isArtifactUploaded={false}
116+
isJobView={false}
117+
type={HistoryComponentType.CI}
118+
imageReleaseTags={artifactInfo.imageReleaseTags}
119+
imageComment={artifactInfo.imageComment}
120+
ciPipelineId={artifactInfo.ciPipelineId}
121+
artifactId={ciArtifactId}
122+
appReleaseTagNames={artifactInfo.appReleaseTags}
123+
tagsEditable={artifactInfo.tagsEditable}
124+
hideImageTaggingHardDelete={false}
125+
renderCIListHeader={renderCIListHeader}
126+
/>
127+
</div>
128+
) : (
129+
<GenericEmptyState
130+
title="Data not available"
131+
subTitle="The data you are looking for is not available"
132+
classname="h-100 bcn-0 flex-grow-1"
133+
/>
134+
)}
135+
</APIResponseHandler>
136+
</div>
137+
</div>
138+
</Drawer>
139+
)
140+
}
141+
142+
export default ArtifactInfoModal
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
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.
15+
*/
16+
17+
export { default as ArtifactInfoModal } from './ArtifactInfoModal.component'
18+
export type { ArtifactInfoModalProps } from './types'
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
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.
15+
*/
16+
17+
import { ArtifactType } from '../CICDHistory'
18+
19+
export type ArtifactInfoModalProps = Pick<ArtifactType, 'renderCIListHeader'> & {
20+
ciArtifactId: number
21+
handleClose: () => void
22+
} & (
23+
| {
24+
envId: number | string
25+
fetchOnlyArtifactInfo?: false
26+
}
27+
| {
28+
envId?: never
29+
/**
30+
* If true, the env and trigger meta data is not fetched
31+
*/
32+
fetchOnlyArtifactInfo: true
33+
}
34+
)
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
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.
15+
*/
16+
17+
import { ReactComponent as CommitIcon } from '../../../Assets/Icon/ic-code-commit.svg'
18+
import { CommitChipCellProps } from './types'
19+
20+
const CommitChipCell = ({ handleClick, commits }: CommitChipCellProps) =>
21+
commits?.length > 0 ? (
22+
<div className="flexbox">
23+
<button
24+
type="button"
25+
className="dc__transparent p-0 flexbox dc__gap-4 fs-14 lh-20 cb-5 dc__ellipsis-right mono cursor"
26+
onClick={handleClick}
27+
>
28+
<span className="flex dc__gap-4 br-4 pl-6 pr-6 bcb-1">
29+
<CommitIcon className="icon-dim-14 dc__no-shrink fcb-5" />
30+
<span>{commits[0].substring(0, 7)}</span>
31+
</span>
32+
{commits.length > 1 && <span className="flex br-4 pl-6 pr-6 bcb-1"></span>}
33+
</button>
34+
</div>
35+
) : (
36+
<span />
37+
)
38+
39+
export default CommitChipCell

0 commit comments

Comments
 (0)