Skip to content

Commit b07ed17

Browse files
Merge pull request #1012 from devtron-labs/feat/ai-actions-and-feedback
feat: ai actions and feedback
2 parents aff2fc3 + 22a27ac commit b07ed17

8 files changed

Lines changed: 55 additions & 27 deletions

File tree

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.22.8-beta-4",
3+
"version": "1.22.8-beta-5",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

src/Common/Common.service.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {
2323
sanitizeUserApprovalList,
2424
stringComparatorBySortOrder,
2525
} from '@Shared/Helpers'
26-
import { EnvListMinDTO, PolicyBlockInfo, RuntimeParamsAPIResponseType, RuntimePluginVariables } from '@Shared/types'
26+
import { EnvListMinDTO, PolicyBlockInfo, RegistryType, RuntimeParamsAPIResponseType, RuntimePluginVariables } from '@Shared/types'
2727
import { GitProviderType, ROUTES } from './Constants'
2828
import { getUrlWithSearchParams, sortCallback } from './Helper'
2929
import {
@@ -683,3 +683,13 @@ export const getDetailedClusterList = async (
683683
)
684684
.sort((a, b) => stringComparatorBySortOrder(a.clusterName, b.clusterName))
685685
}
686+
687+
export const getDockerRegistriesListMin = async (
688+
signal: AbortSignal,
689+
): Promise<ResponseType<{ id: string; registryType: RegistryType; isDefault: boolean }[]>> => get(ROUTES.DOCKER_REGISTRY_MIN, { signal })
690+
691+
export const getGitProvidersListMin = async (
692+
signal: AbortSignal,
693+
): Promise<
694+
ResponseType<{ id: number; name: string; url: string; authMode: 'SSH' | 'USERNAME_PASSWORD' | 'ANONYMOUS' }[]>
695+
> => get(ROUTES.GIT_PROVIDER_MIN, { signal })

src/Common/Constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export const DEVTRON_GPT_LINK = 'https://chatgpt.com/g/g-6826efa4362c8191b23e7bf
3333

3434
export const PATTERNS = {
3535
STRING: /^[a-zA-Z0-9_]+$/,
36+
APP_NAME: '^[a-z][a-z0-9-]*[a-z0-9]$/*',
3637
DECIMAL_NUMBERS: /^-?\d*\.?\d*$/,
3738
POSITIVE_DECIMAL_NUMBERS: /^\d*\.?\d*$/,
3839
NATURAL_NUMBERS: /^[1-9]\d*$/,
@@ -227,6 +228,8 @@ export const ROUTES = {
227228
ENV: 'env',
228229
APP_METADATA: 'app-metadata',
229230
RESOURCE_CONFLICTS_LIST: 'app/:appId/cd-pipeline/:pipelineId/history/:wfrId/helm-ownership-conflicts',
231+
GIT_PROVIDER_MIN: 'git/provider/autocomplete',
232+
DOCKER_REGISTRY_MIN: 'docker/registry/autocomplete',
230233
} as const
231234

232235
export enum KEY_VALUE {

src/Shared/Components/Header/PageHeader.tsx

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ import { handleAnalyticsEvent } from '@Shared/Analytics'
2222
import { ComponentSizeType } from '@Shared/constants'
2323
import { InstallationType } from '@Shared/types'
2424

25-
import { TippyCustomized, TippyTheme, Tooltip } from '../../../Common'
25+
import { TippyCustomized, TippyTheme } from '../../../Common'
2626
import { POSTHOG_EVENT_ONBOARDING } from '../../../Common/Constants'
27-
import { SidePanelTab, useMainContext, useTheme, useUserEmail } from '../../Providers'
27+
import { useMainContext, useTheme, useUserEmail } from '../../Providers'
2828
import { Button, ButtonStyleType, ButtonVariantType } from '../Button'
2929
import { Icon } from '../Icon'
3030
import { ImageWithFallback } from '../ImageWithFallback'
@@ -55,10 +55,10 @@ const PageHeader = ({
5555
const {
5656
setLoginCount,
5757
setShowGettingStartedCard,
58-
setSidePanelConfig,
5958
sidePanelConfig,
6059
tempAppWindowConfig,
6160
featureAskDevtronExpert,
61+
AskDevtronButton,
6262
} = useMainContext()
6363
const { showSwitchThemeLocationTippy, handleShowSwitchThemeLocationTippyChange } = useTheme()
6464

@@ -136,28 +136,12 @@ const PageHeader = ({
136136
</div>
137137
)
138138

139-
const onAskButtonClick = () => {
140-
handleAnalyticsEvent({
141-
category: 'AI',
142-
action: 'HELP_ASK_DEVTRON_AI',
143-
})
144-
setSidePanelConfig((prev) => ({ ...prev, state: SidePanelTab.ASK_DEVTRON }))
145-
}
146-
147139
const renderLogoutHelpSection = () => (
148140
<>
149-
{featureAskDevtronExpert && sidePanelConfig.state === 'closed' && !tempAppWindowConfig.open && (
150-
<Tooltip content="Ask Devtron AI" placement="bottom" alwaysShowTippyOnHover delay={[500, null]}>
151-
<button
152-
className="enable-svg-animation--hover flex dc__no-background p-2 dc__outline-none-imp dc__no-border"
153-
onClick={onAskButtonClick}
154-
type="button"
155-
aria-label="Ask Devtron Expert"
156-
>
157-
<Icon name="ic-devtron-ai" color={null} size={28} />
158-
</button>
159-
</Tooltip>
160-
)}
141+
{AskDevtronButton &&
142+
featureAskDevtronExpert &&
143+
sidePanelConfig.state === 'closed' &&
144+
!tempAppWindowConfig.open && <AskDevtronButton />}
161145

162146
<HelpButton
163147
serverInfo={currentServerInfo.serverInfo}

src/Shared/Hooks/useGetResourceKindsOptions/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@
1414
* limitations under the License.
1515
*/
1616

17+
export { getProjectOptions } from './service'
1718
export type { UseGetResourceKindOptionsReturnType, UseGetResourceKindsOptionsProps } from './types'
1819
export { default as useGetResourceKindsOptions } from './useGetResourceKindsOptions'

src/Shared/Providers/MainContextProvider/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ export type MainContext = CommonMainContextProps &
216216
setTempAppWindowConfig: Dispatch<SetStateAction<TempAppWindowConfig>>
217217
AIRecommendations?: FunctionComponent
218218
featureAskDevtronExpert: EnvironmentDataValuesDTO['featureAskDevtronExpert']
219+
AskDevtronButton?: FunctionComponent
219220
}
220221
| {
221222
isLicenseDashboard: true
@@ -236,6 +237,7 @@ export type MainContext = CommonMainContextProps &
236237
setTempAppWindowConfig: null
237238
AIRecommendations?: null
238239
featureAskDevtronExpert?: null
240+
AskDevtronButton?: null
239241
}
240242
)
241243

src/Shared/validations.tsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,3 +561,31 @@ export const validateCronExpression = (expression: string): ValidationResponseTy
561561
}
562562
}
563563
}
564+
565+
export const validateAppName = (value: string): Required<ValidationResponseType> => {
566+
const re = PATTERNS.APP_NAME
567+
const regExp = new RegExp(re)
568+
const test = regExp.test(value)
569+
570+
if (value.length === 0) {
571+
return { isValid: false, message: 'Please provide app name' }
572+
}
573+
574+
if (value.length < 3) {
575+
return { isValid: false, message: MESSAGES.getMinCharMessage(3) }
576+
}
577+
578+
if (value.length > 30) {
579+
return { isValid: false, message: MESSAGES.getMaxCharMessage(30) }
580+
}
581+
582+
if (!test) {
583+
return {
584+
isValid: false,
585+
message:
586+
"Min 3 chars; Start with alphabet; End with alphanumeric; Use only lowercase; Allowed:(-); Do not use 'spaces'",
587+
}
588+
}
589+
590+
return { isValid: true, message: '' }
591+
}

0 commit comments

Comments
 (0)