Skip to content

Commit 34d4a63

Browse files
committed
Merge branch 'develop' of github.com:devtron-labs/devtron-fe-common-lib into feat/deployment-exception
2 parents ffc73b7 + 71bb435 commit 34d4a63

33 files changed

+709
-641
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": "1.12.0-beta-2",
3+
"version": "1.12.0-pre-3",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

src/Assets/Icon/ic-nav-rocket.svg

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 4 additions & 0 deletions
Loading

src/Common/CIPipeline.Types.ts

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { DynamicDataTableCellValidationState } from '@Shared/Components'
17+
import { DynamicDataTableCellValidationState, KeyValueTableData } from '@Shared/Components'
1818

1919
export interface MaterialType {
2020
name: string
@@ -158,7 +158,7 @@ export interface PortMapType {
158158
portOnLocal: number
159159
portOnContainer: number
160160
}
161-
interface ConditionDetails {
161+
export interface ConditionDetails {
162162
id: number
163163
conditionOnVariable: string
164164
conditionOperator: string
@@ -266,7 +266,7 @@ export enum WORKFLOW_CACHE_CONFIG_ENUM {
266266

267267
export interface FormType {
268268
name: string
269-
args: { key: string; value: string }[]
269+
args: KeyValueTableData[]
270270
materials: MaterialType[]
271271
gitHost: Githost
272272
webhookEvents: WebhookEvent[]
@@ -314,23 +314,29 @@ export enum InputOutputVariablesHeaderKeys {
314314
VALUE = 'val',
315315
}
316316

317-
export type InputOutputVariablesErrorObj = Record<InputOutputVariablesHeaderKeys, DynamicDataTableCellValidationState>
317+
export enum ConditionDataTableHeaderKeys {
318+
VARIABLE = 'variable',
319+
OPERATOR = 'operator',
320+
VALUE = 'val',
321+
}
322+
323+
type InputOutputVariablesErrorObj = Record<InputOutputVariablesHeaderKeys, DynamicDataTableCellValidationState>
324+
type ConditionDetailsErrorObj = Record<ConditionDataTableHeaderKeys, DynamicDataTableCellValidationState>
325+
326+
interface StepDetailTaskErrorObj {
327+
inputVariables?: Record<number, InputOutputVariablesErrorObj>
328+
outputVariables?: Record<number, InputOutputVariablesErrorObj>
329+
isInputVariablesValid?: boolean
330+
isOutputVariablesValid?: boolean
331+
conditionDetails?: Record<number, ConditionDetailsErrorObj>
332+
isConditionDetailsValid?: boolean
333+
}
318334

319335
export interface TaskErrorObj {
320336
isValid: boolean
321337
name: ErrorObj
322-
inlineStepDetail?: {
323-
inputVariables?: Record<number, InputOutputVariablesErrorObj>
324-
outputVariables?: Record<number, InputOutputVariablesErrorObj>
325-
isInputVariablesValid?: boolean
326-
isOutputVariablesValid?: boolean
327-
}
328-
pluginRefStepDetail?: {
329-
inputVariables?: Record<number, InputOutputVariablesErrorObj>
330-
outputVariables?: Record<number, InputOutputVariablesErrorObj>
331-
isInputVariablesValid?: boolean
332-
isOutputVariablesValid?: boolean
333-
}
338+
inlineStepDetail?: StepDetailTaskErrorObj
339+
pluginRefStepDetail?: StepDetailTaskErrorObj
334340
}
335341
export interface FormErrorObjectType {
336342
name: ErrorObj

src/Common/Common.service.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,14 @@ import {
4545
GlobalVariableDTO,
4646
GlobalVariableOptionType,
4747
UserRole,
48+
EnvAppsMetaDTO,
49+
GetAppsInfoForEnvProps,
50+
AppMeta,
4851
} from './Types'
4952
import { ApiResourceType, STAGE_MAP } from '../Pages'
5053
import { RefVariableType, VariableTypeFormat } from './CIPipeline.Types'
5154
import { get, post } from './API'
55+
import { StatusType } from '@Shared/Components'
5256

5357
export const getTeamListMin = (): Promise<TeamList> => {
5458
// ignore active field
@@ -511,3 +515,25 @@ export const getGlobalVariables = async ({
511515
throw err
512516
}
513517
}
518+
519+
export const getAppsInfoForEnv = async ({ envId, appIds }: GetAppsInfoForEnvProps): Promise<EnvAppsMetaDTO> => {
520+
const url = getUrlWithSearchParams(`${ROUTES.ENV}/${envId}/${ROUTES.APP_METADATA}`, {
521+
appIds: appIds?.join(),
522+
})
523+
const response = await get<EnvAppsMetaDTO>(url)
524+
525+
return {
526+
appCount: response.result?.appCount ?? 0,
527+
apps: (response.result?.apps ?? []).reduce<AppMeta[]>((agg, { appId, appName, appStatus }) => {
528+
if (!appId) {
529+
return agg
530+
}
531+
agg.push({
532+
appId,
533+
appName: appName || '',
534+
appStatus: appStatus || StatusType.UNKNOWN,
535+
})
536+
return agg
537+
}, []),
538+
}
539+
}

src/Common/Constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ export const ROUTES = {
157157
ENVIRONMENT_DATA: 'global/environment-variables',
158158
DASHBOARD_EVENT: 'dashboard-event',
159159
LICENSE_DATA: 'license/data',
160+
ENV: 'env',
161+
APP_METADATA: 'app-metadata',
160162
} as const
161163

162164
export enum KEY_VALUE {

src/Common/Types.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
TargetPlatformItemDTO,
2828
ButtonProps,
2929
ComponentLayoutType,
30+
StatusType,
3031
} from '../Shared'
3132
import {
3233
ACTION_STATE,
@@ -1113,3 +1114,19 @@ export enum ActionTypes {
11131114
EDIT = 'edit',
11141115
APPROVER = 'approver',
11151116
}
1117+
1118+
export interface GetAppsInfoForEnvProps {
1119+
envId: number
1120+
appIds?: number[]
1121+
}
1122+
1123+
export interface AppMeta {
1124+
appId: number
1125+
appStatus: StatusType
1126+
appName: string
1127+
}
1128+
1129+
export interface EnvAppsMetaDTO {
1130+
appCount: number
1131+
apps: AppMeta[]
1132+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import ReactGA from 'react-ga4'
2+
3+
import DevtronCopyright from '@Common/DevtronCopyright'
4+
import { EULA_LINK, PRIVACY_POLICY_LINK, TERMS_OF_USE_LINK } from '@Shared/constants'
5+
import { useMainContext } from '@Shared/Providers'
6+
7+
import { Button, ButtonComponentType, ButtonStyleType, ButtonVariantType } from '../Button'
8+
import { InstallationType } from '../Header/types'
9+
import { Icon } from '../Icon'
10+
11+
const AboutDevtronBody = ({ isFELibAvailable }: { isFELibAvailable: boolean }) => {
12+
const { currentServerInfo } = useMainContext()
13+
14+
const currentVersion = currentServerInfo?.serverInfo?.currentVersion
15+
const isEnterprise = currentServerInfo?.serverInfo?.installationType === InstallationType.ENTERPRISE
16+
17+
const isVersionCompatible = isFELibAvailable === isEnterprise
18+
19+
const handleEULAClick = () => {
20+
ReactGA.event({
21+
category: 'about-devtron',
22+
action: 'ABOUT_DEVTRON_LICENSE_AGREEMENT_CLICKED',
23+
})
24+
}
25+
26+
return (
27+
<div className="flexbox-col p-32 dc__gap-24 br-16 border__secondary bg__secondary">
28+
<div className="flexbox-col dc__align-items-center dc__gap-16 text-center">
29+
<div className="flex p-6 border__primary br-8">
30+
<Icon name="ic-devtron" color="B500" size={40} />
31+
</div>
32+
<div>
33+
<p className="fs-16 cn-9 fw-6 lh-1-5 m-0">Devtron</p>
34+
{isVersionCompatible && (
35+
<p className="fs-13 cn-7 fw-4 lh-20 m-0">{`${isEnterprise ? 'Enterprise' : 'OSS'} Version${currentVersion ? `(${currentVersion})` : ''}`}</p>
36+
)}
37+
</div>
38+
<DevtronCopyright />
39+
</div>
40+
<div className="flexbox flex-wrap dc__content-center dc__gap-4">
41+
<Button
42+
dataTestId="terms-of-service"
43+
text="Terms of service"
44+
variant={ButtonVariantType.text}
45+
style={ButtonStyleType.neutral}
46+
component={ButtonComponentType.anchor}
47+
anchorProps={{
48+
href: TERMS_OF_USE_LINK,
49+
}}
50+
/>
51+
<span></span>
52+
<Button
53+
dataTestId="privacy-policy"
54+
text="Privacy policy"
55+
variant={ButtonVariantType.text}
56+
style={ButtonStyleType.neutral}
57+
component={ButtonComponentType.anchor}
58+
anchorProps={{
59+
href: PRIVACY_POLICY_LINK,
60+
}}
61+
/>
62+
<span></span>
63+
<Button
64+
dataTestId="license-agreement"
65+
text="End-User License agreement"
66+
variant={ButtonVariantType.text}
67+
style={ButtonStyleType.neutral}
68+
onClick={handleEULAClick}
69+
component={ButtonComponentType.anchor}
70+
anchorProps={{
71+
href: EULA_LINK,
72+
}}
73+
/>
74+
</div>
75+
</div>
76+
)
77+
}
78+
79+
export default AboutDevtronBody
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { ComponentSizeType } from '@Shared/constants'
2+
3+
import { Backdrop } from '../Backdrop'
4+
import { Button } from '../Button'
5+
import AboutDevtronBody from './AboutDevtronBody'
6+
7+
const AboutDevtronDialog = ({
8+
handleCloseLicenseInfoDialog,
9+
isFELibAvailable,
10+
}: {
11+
handleCloseLicenseInfoDialog: () => void
12+
isFELibAvailable: boolean
13+
}) => (
14+
<Backdrop onEscape={handleCloseLicenseInfoDialog}>
15+
<div className="flexbox-col w-400 br-12 bg__primary border__primary dc__m-auto mt-40">
16+
<div className="p-24">
17+
<AboutDevtronBody isFELibAvailable={isFELibAvailable} />
18+
</div>
19+
<div className="flex px-24 py-20 dc__content-end">
20+
<Button
21+
dataTestId="license-info-okay"
22+
text="Okay"
23+
size={ComponentSizeType.medium}
24+
onClick={handleCloseLicenseInfoDialog}
25+
/>
26+
</div>
27+
</div>
28+
</Backdrop>
29+
)
30+
31+
export default AboutDevtronDialog

0 commit comments

Comments
 (0)