Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
12 changes: 11 additions & 1 deletion src/Common/Common.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -683,3 +683,13 @@ export const getDetailedClusterList = async (
)
.sort((a, b) => stringComparatorBySortOrder(a.clusterName, b.clusterName))
}

export const getDockerRegistriesListMin = async (
signal: AbortSignal,
): Promise<ResponseType<{ id: string; registryType: RegistryType; isDefault: boolean }[]>> => 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 })
3 changes: 3 additions & 0 deletions src/Common/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]$/*',

Copilot AI Feb 10, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PATTERNS.APP_NAME is currently a string (while almost all other PATTERNS entries are RegExps) and it also contains a trailing $/*, which looks unintentional. This mixed typing makes PATTERNS easy to misuse elsewhere (e.g., calling .test on APP_NAME would throw) and the extra /* is confusing. Consider making APP_NAME a RegExp like the other patterns (and remove the trailing /*).

Suggested change
APP_NAME: '^[a-z][a-z0-9-]*[a-z0-9]$/*',
APP_NAME: /^[a-z][a-z0-9-]*[a-z0-9]$/,

Copilot uses AI. Check for mistakes.
DECIMAL_NUMBERS: /^-?\d*\.?\d*$/,
POSITIVE_DECIMAL_NUMBERS: /^\d*\.?\d*$/,
NATURAL_NUMBERS: /^[1-9]\d*$/,
Expand Down Expand Up @@ -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 {
Expand Down
30 changes: 7 additions & 23 deletions src/Shared/Components/Header/PageHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -55,10 +55,10 @@ const PageHeader = ({
const {
setLoginCount,
setShowGettingStartedCard,
setSidePanelConfig,
sidePanelConfig,
tempAppWindowConfig,
featureAskDevtronExpert,
AskDevtronButton,
} = useMainContext()
const { showSwitchThemeLocationTippy, handleShowSwitchThemeLocationTippyChange } = useTheme()

Expand Down Expand Up @@ -136,28 +136,12 @@ const PageHeader = ({
</div>
)

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 && (
<Tooltip content="Ask Devtron AI" placement="bottom" alwaysShowTippyOnHover delay={[500, null]}>
<button
className="enable-svg-animation--hover flex dc__no-background p-2 dc__outline-none-imp dc__no-border"
onClick={onAskButtonClick}
type="button"
aria-label="Ask Devtron Expert"
>
<Icon name="ic-devtron-ai" color={null} size={28} />
</button>
</Tooltip>
)}
{AskDevtronButton &&
featureAskDevtronExpert &&
sidePanelConfig.state === 'closed' &&
!tempAppWindowConfig.open && <AskDevtronButton />}

<HelpButton
serverInfo={currentServerInfo.serverInfo}
Expand Down
1 change: 1 addition & 0 deletions src/Shared/Hooks/useGetResourceKindsOptions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
* limitations under the License.
*/

export { getProjectOptions } from './service'
export type { UseGetResourceKindOptionsReturnType, UseGetResourceKindsOptionsProps } from './types'
export { default as useGetResourceKindsOptions } from './useGetResourceKindsOptions'
2 changes: 2 additions & 0 deletions src/Shared/Providers/MainContextProvider/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ export type MainContext = CommonMainContextProps &
setTempAppWindowConfig: Dispatch<SetStateAction<TempAppWindowConfig>>
AIRecommendations?: FunctionComponent
featureAskDevtronExpert: EnvironmentDataValuesDTO['featureAskDevtronExpert']
AskDevtronButton?: FunctionComponent
}
| {
isLicenseDashboard: true
Expand All @@ -236,6 +237,7 @@ export type MainContext = CommonMainContextProps &
setTempAppWindowConfig: null
AIRecommendations?: null
featureAskDevtronExpert?: null
AskDevtronButton?: null
}
)

Expand Down
28 changes: 28 additions & 0 deletions src/Shared/validations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -561,3 +561,31 @@ export const validateCronExpression = (expression: string): ValidationResponseTy
}
}
}

export const validateAppName = (value: string): Required<ValidationResponseType> => {
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: '' }
}