Skip to content

Commit c026c39

Browse files
committed
Merge branch 'develop' of github.com:devtron-labs/devtron-fe-common-lib into refactor/remove-monaco
2 parents 593b7fe + 71bb435 commit c026c39

34 files changed

+715
-646
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-pre-1",
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
Lines changed: 3 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: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,7 @@ import {
2222
sanitizeUserApprovalList,
2323
stringComparatorBySortOrder,
2424
} from '@Shared/Helpers'
25-
import {
26-
PolicyBlockInfo,
27-
RuntimeParamsAPIResponseType,
28-
RuntimePluginVariables,
29-
} from '@Shared/types'
25+
import { PolicyBlockInfo, RuntimeParamsAPIResponseType, RuntimePluginVariables } from '@Shared/types'
3026
import { GitProviderType, ROUTES } from './Constants'
3127
import { getUrlWithSearchParams, sortCallback } from './Helper'
3228
import {
@@ -49,10 +45,14 @@ import {
4945
GlobalVariableDTO,
5046
GlobalVariableOptionType,
5147
UserRole,
48+
EnvAppsMetaDTO,
49+
GetAppsInfoForEnvProps,
50+
AppMeta,
5251
} from './Types'
5352
import { ApiResourceType, STAGE_MAP } from '../Pages'
5453
import { RefVariableType, VariableTypeFormat } from './CIPipeline.Types'
5554
import { get, post } from './API'
55+
import { StatusType } from '@Shared/Components'
5656

5757
export const getTeamListMin = (): Promise<TeamList> => {
5858
// ignore active field
@@ -264,7 +264,7 @@ export const parseRuntimeParams = (response: RuntimeParamsAPIResponseType): Runt
264264
const runtimeParams = (response?.runtimePluginVariables ?? []).map<RuntimePluginVariables>((variable) => ({
265265
...variable,
266266
defaultValue: variable.value,
267-
stepVariableId: variable.stepVariableId || Math.floor(new Date().valueOf() * Math.random())
267+
stepVariableId: variable.stepVariableId || Math.floor(new Date().valueOf() * Math.random()),
268268
}))
269269

270270
runtimeParams.push(...envVariables)
@@ -515,3 +515,25 @@ export const getGlobalVariables = async ({
515515
throw err
516516
}
517517
}
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,
@@ -1109,3 +1110,19 @@ export enum ActionTypes {
11091110
EDIT = 'edit',
11101111
APPROVER = 'approver',
11111112
}
1113+
1114+
export interface GetAppsInfoForEnvProps {
1115+
envId: number
1116+
appIds?: number[]
1117+
}
1118+
1119+
export interface AppMeta {
1120+
appId: number
1121+
appStatus: StatusType
1122+
appName: string
1123+
}
1124+
1125+
export interface EnvAppsMetaDTO {
1126+
appCount: number
1127+
apps: AppMeta[]
1128+
}
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

0 commit comments

Comments
 (0)