Skip to content

Commit 1094cef

Browse files
Merge pull request #887 from devtron-labs/feat/cmd-bar-chart-search
feat: cmd bar resource search
2 parents 5c4425f + bff4787 commit 1094cef

File tree

8 files changed

+40
-37
lines changed

8 files changed

+40
-37
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.20.1-pre-1",
3+
"version": "1.20.1-pre-2",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

src/Shared/Hooks/useGetResourceKindsOptions/service.ts

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@ import { ROUTES } from '@Common/Constants'
2020
import { ResponseType, Teams } from '@Common/Types'
2121
import { EnvironmentTypeEnum } from '@Shared/constants'
2222
import { stringComparatorBySortOrder } from '@Shared/Helpers'
23-
import { ClusterType } from '@Shared/Services'
2423
import { EnvListMinDTO } from '@Shared/types'
2524

26-
import { AppsGroupedByProjectsType, ClusterDTO, EnvironmentsGroupedByClustersType } from './types'
25+
import { AppsGroupedByProjectsType, EnvironmentsGroupedByClustersType } from './types'
2726

2827
export const getAppOptionsGroupedByProjects = async (): Promise<AppsGroupedByProjectsType> => {
2928
const { result } = (await get(ROUTES.APP_LIST_MIN)) as ResponseType<AppsGroupedByProjectsType>
@@ -55,23 +54,6 @@ export const getProjectOptions = async (): Promise<Pick<Teams, 'id' | 'name'>[]>
5554
.sort((a, b) => stringComparatorBySortOrder(a.name, b.name))
5655
}
5756

58-
export const getClusterOptions = async (): Promise<ClusterType[]> => {
59-
const { result } = (await get(ROUTES.CLUSTER_LIST_MIN)) as ResponseType<ClusterDTO[]>
60-
61-
if (!result) {
62-
return []
63-
}
64-
65-
return result
66-
.map(({ id, cluster_name: name, isVirtualCluster, isProd }) => ({
67-
id,
68-
name,
69-
isVirtual: isVirtualCluster ?? false,
70-
isProd: isProd ?? false,
71-
}))
72-
.sort((a, b) => stringComparatorBySortOrder(a.name, b.name))
73-
}
74-
7557
export const getEnvironmentOptionsGroupedByClusters = async (): Promise<EnvironmentsGroupedByClustersType> => {
7658
const { result } = (await get(ROUTES.ENVIRONMENT_LIST_MIN)) as ResponseType<EnvListMinDTO[]>
7759

src/Shared/Hooks/useGetResourceKindsOptions/types.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@
1717
// ====== Service Types: Start ====== //
1818

1919
import { ServerErrors } from '@Common/ServerError'
20+
import { getClusterOptions } from '@Shared/index'
2021
import { EnvironmentType, ResourceKindType } from '@Shared/types'
2122

22-
import { getAppOptionsGroupedByProjects, getClusterOptions, getProjectOptions } from './service'
23+
import { getAppOptionsGroupedByProjects, getProjectOptions } from './service'
2324

2425
export interface AppType {
2526
name: string
@@ -36,13 +37,6 @@ export type EnvironmentsGroupedByClustersType = {
3637
envList: EnvironmentType[]
3738
}[]
3839

39-
export interface ClusterDTO {
40-
id: number
41-
cluster_name: string
42-
isVirtualCluster: boolean
43-
isProd: boolean
44-
}
45-
4640
// ====== Service Types: End ====== //
4741

4842
export interface UseGetResourceKindsOptionsProps {

src/Shared/Hooks/useGetResourceKindsOptions/useGetResourceKindsOptions.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,10 @@
1717
import { useMemo } from 'react'
1818

1919
import { useAsync } from '@Common/Helper'
20+
import { getClusterOptions } from '@Shared/index'
2021
import { ResourceKindType } from '@Shared/types'
2122

22-
import {
23-
getAppOptionsGroupedByProjects,
24-
getClusterOptions,
25-
getEnvironmentOptionsGroupedByClusters,
26-
getProjectOptions,
27-
} from './service'
23+
import { getAppOptionsGroupedByProjects, getEnvironmentOptionsGroupedByClusters, getProjectOptions } from './service'
2824
import { UseGetResourceKindOptionsReturnType, UseGetResourceKindsOptionsProps } from './types'
2925
import { getResourcesToFetchMap } from './utils'
3026

src/Shared/Hooks/useUserPreferences/types.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,13 @@ export type CommandBarAdditionalItemsId =
122122
| 'app-management-flux-app-list'
123123
| 'app-management-argo-app-list'
124124
| `app-management-devtron-app-list-${number}`
125+
| 'search-app-list-view'
126+
| `chart-list-${number}`
127+
| 'search-chart-list-view'
128+
| `helm-app-list-${number}`
129+
| 'search-helm-app-list-view'
130+
| `cluster-list-${number}`
131+
| 'search-cluster-list-view'
125132

126133
export interface GetUserPreferencesParsedDTO {
127134
viewPermittedEnvOnly?: boolean

src/Shared/Services/common.service.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import { AppConfigProps, GetTemplateAPIRouteType } from '@Pages/index'
1818

1919
import { get, getUrlWithSearchParams, post, ROUTES } from '../../Common'
20-
import { getTemplateAPIRoute } from '..'
20+
import { ClusterMinDTO, ClusterType, getTemplateAPIRoute, stringComparatorBySortOrder } from '..'
2121
import { EnvironmentDataValuesDTO, GetPolicyApiUrlProps, GetResourceApiUrlProps } from './types'
2222

2323
export const getResourceApiUrl = <T>({ baseUrl, kind, version, suffix, queryParams }: GetResourceApiUrlProps<T>) =>
@@ -40,3 +40,20 @@ export const saveCDPipeline = (request, { isTemplateView }: Required<Pick<AppCon
4040
}
4141

4242
export const getEnvironmentData = () => get<EnvironmentDataValuesDTO>(ROUTES.ENVIRONMENT_DATA)
43+
44+
export const getClusterOptions = async (): Promise<ClusterType[]> => {
45+
const { result } = await get<ClusterMinDTO[]>(ROUTES.CLUSTER_LIST_MIN)
46+
47+
if (!result) {
48+
return []
49+
}
50+
51+
return result
52+
.map(({ id, cluster_name: name, isVirtualCluster, isProd }) => ({
53+
id,
54+
name,
55+
isVirtual: isVirtualCluster ?? false,
56+
isProd: isProd ?? false,
57+
}))
58+
.sort((a, b) => stringComparatorBySortOrder(a.name, b.name))
59+
}

src/Shared/Services/types.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,10 @@ export interface EnvironmentDataValuesDTO extends Pick<MainContext, 'featureGitO
6262
devtronManagedLicensingEnabled: boolean
6363
isResourceRecommendationEnabled?: boolean
6464
}
65+
66+
export interface ClusterMinDTO {
67+
id: number
68+
cluster_name: string
69+
isVirtualCluster: boolean
70+
isProd: boolean
71+
}

0 commit comments

Comments
 (0)