diff --git a/package-lock.json b/package-lock.json index 0e562582e..32fa66d3f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.22.8-beta-4", + "version": "1.22.8-beta-5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.22.8-beta-4", + "version": "1.22.8-beta-5", "hasInstallScript": true, "license": "ISC", "dependencies": { diff --git a/package.json b/package.json index f82753005..0d089755e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@devtron-labs/devtron-fe-common-lib", - "version": "1.22.8-beta-4", + "version": "1.22.8-beta-5", "description": "Supporting common component library", "type": "module", "main": "dist/index.js", diff --git a/src/Common/Common.service.ts b/src/Common/Common.service.ts index 990d3fa31..457c151ff 100644 --- a/src/Common/Common.service.ts +++ b/src/Common/Common.service.ts @@ -23,7 +23,7 @@ import { sanitizeUserApprovalList, stringComparatorBySortOrder, } from '@Shared/Helpers' -import { EnvListMinDTO, PolicyBlockInfo, RuntimeParamsAPIResponseType, RuntimePluginVariables } from '@Shared/types' +import { EnvListMinDTO, PolicyBlockInfo, RegistryType, RuntimeParamsAPIResponseType, RuntimePluginVariables } from '@Shared/types' import { GitProviderType, ROUTES } from './Constants' import { getUrlWithSearchParams, sortCallback } from './Helper' import { @@ -683,3 +683,13 @@ export const getDetailedClusterList = async ( ) .sort((a, b) => stringComparatorBySortOrder(a.clusterName, b.clusterName)) } + +export const getDockerRegistriesListMin = async ( + signal: AbortSignal, +): Promise> => get(ROUTES.DOCKER_REGISTRY_MIN, { signal }) + +export const getGitProvidersListMin = async ( + signal: AbortSignal, +): Promise< + ResponseType<{ id: number; name: string; url: string; authMode: 'SSH' | 'USERNAME_PASSWORD' | 'ANONYMOUS' }[]> +> => get(ROUTES.GIT_PROVIDER_MIN, { signal }) diff --git a/src/Common/Constants.ts b/src/Common/Constants.ts index d3ef9d1d2..2581fdf30 100644 --- a/src/Common/Constants.ts +++ b/src/Common/Constants.ts @@ -33,6 +33,7 @@ export const DEVTRON_GPT_LINK = 'https://chatgpt.com/g/g-6826efa4362c8191b23e7bf export const PATTERNS = { STRING: /^[a-zA-Z0-9_]+$/, + APP_NAME: '^[a-z][a-z0-9-]*[a-z0-9]$/*', DECIMAL_NUMBERS: /^-?\d*\.?\d*$/, POSITIVE_DECIMAL_NUMBERS: /^\d*\.?\d*$/, NATURAL_NUMBERS: /^[1-9]\d*$/, @@ -227,6 +228,8 @@ export const ROUTES = { ENV: 'env', APP_METADATA: 'app-metadata', RESOURCE_CONFLICTS_LIST: 'app/:appId/cd-pipeline/:pipelineId/history/:wfrId/helm-ownership-conflicts', + GIT_PROVIDER_MIN: 'git/provider/autocomplete', + DOCKER_REGISTRY_MIN: 'docker/registry/autocomplete', } as const export enum KEY_VALUE { diff --git a/src/Shared/Components/Header/PageHeader.tsx b/src/Shared/Components/Header/PageHeader.tsx index 7d0c48c9b..8a30877f7 100644 --- a/src/Shared/Components/Header/PageHeader.tsx +++ b/src/Shared/Components/Header/PageHeader.tsx @@ -22,9 +22,9 @@ import { handleAnalyticsEvent } from '@Shared/Analytics' import { ComponentSizeType } from '@Shared/constants' import { InstallationType } from '@Shared/types' -import { TippyCustomized, TippyTheme, Tooltip } from '../../../Common' +import { TippyCustomized, TippyTheme } from '../../../Common' import { POSTHOG_EVENT_ONBOARDING } from '../../../Common/Constants' -import { SidePanelTab, useMainContext, useTheme, useUserEmail } from '../../Providers' +import { useMainContext, useTheme, useUserEmail } from '../../Providers' import { Button, ButtonStyleType, ButtonVariantType } from '../Button' import { Icon } from '../Icon' import { ImageWithFallback } from '../ImageWithFallback' @@ -55,10 +55,10 @@ const PageHeader = ({ const { setLoginCount, setShowGettingStartedCard, - setSidePanelConfig, sidePanelConfig, tempAppWindowConfig, featureAskDevtronExpert, + AskDevtronButton, } = useMainContext() const { showSwitchThemeLocationTippy, handleShowSwitchThemeLocationTippyChange } = useTheme() @@ -136,28 +136,12 @@ const PageHeader = ({ ) - const onAskButtonClick = () => { - handleAnalyticsEvent({ - category: 'AI', - action: 'HELP_ASK_DEVTRON_AI', - }) - setSidePanelConfig((prev) => ({ ...prev, state: SidePanelTab.ASK_DEVTRON })) - } - const renderLogoutHelpSection = () => ( <> - {featureAskDevtronExpert && sidePanelConfig.state === 'closed' && !tempAppWindowConfig.open && ( - - - - )} + {AskDevtronButton && + featureAskDevtronExpert && + sidePanelConfig.state === 'closed' && + !tempAppWindowConfig.open && } > AIRecommendations?: FunctionComponent featureAskDevtronExpert: EnvironmentDataValuesDTO['featureAskDevtronExpert'] + AskDevtronButton?: FunctionComponent } | { isLicenseDashboard: true @@ -236,6 +237,7 @@ export type MainContext = CommonMainContextProps & setTempAppWindowConfig: null AIRecommendations?: null featureAskDevtronExpert?: null + AskDevtronButton?: null } ) diff --git a/src/Shared/validations.tsx b/src/Shared/validations.tsx index 1f3d936a0..ac5d9cb75 100644 --- a/src/Shared/validations.tsx +++ b/src/Shared/validations.tsx @@ -561,3 +561,31 @@ export const validateCronExpression = (expression: string): ValidationResponseTy } } } + +export const validateAppName = (value: string): Required => { + const re = PATTERNS.APP_NAME + const regExp = new RegExp(re) + const test = regExp.test(value) + + if (value.length === 0) { + return { isValid: false, message: 'Please provide app name' } + } + + if (value.length < 3) { + return { isValid: false, message: MESSAGES.getMinCharMessage(3) } + } + + if (value.length > 30) { + return { isValid: false, message: MESSAGES.getMaxCharMessage(30) } + } + + if (!test) { + return { + isValid: false, + message: + "Min 3 chars; Start with alphabet; End with alphanumeric; Use only lowercase; Allowed:(-); Do not use 'spaces'", + } + } + + return { isValid: true, message: '' } +}