Skip to content

Commit 1cc5763

Browse files
committed
feat: update project navigation links and refactor ProjectList component
1 parent 4898c08 commit 1cc5763

File tree

10 files changed

+61
-103
lines changed

10 files changed

+61
-103
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"private": true,
55
"homepage": "/dashboard",
66
"dependencies": {
7-
"@devtron-labs/devtron-fe-common-lib": "1.22.6",
7+
"@devtron-labs/devtron-fe-common-lib": "1.22.6-beta-2",
88
"@esbuild-plugins/node-globals-polyfill": "0.2.3",
99
"@rjsf/core": "^5.13.3",
1010
"@rjsf/utils": "^5.13.3",

src/Pages-Devtron-2.0/ApplicationManagement/Overview/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const GLANCE_METRICS_CARDS_CONFIG: Record<
1212
[GlanceMetricKeys.PROJECTS]: {
1313
iconName: 'ic-bg-project',
1414
metricTitle: 'Projects',
15-
redirectionLink: COMMON_URLS.APPLICATION_MANAGEMENT_PROJECTS,
15+
redirectionLink: COMMON_URLS.GLOBAL_CONFIG_PROJECTS,
1616
tooltipContent: 'Number of projects',
1717
},
1818
[GlanceMetricKeys.YOUR_APPLICATIONS]: {

src/components/Navigation/constants.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,6 @@ const NAVIGATION_LIST: NavigationGroupType[] = [
154154
href: URLS.APPLICATION_MANAGEMENT_BULK_EDIT,
155155
},
156156
...(APPLICATION_MANAGEMENT_TEMPLATES_NAV_ITEM ? [APPLICATION_MANAGEMENT_TEMPLATES_NAV_ITEM] : []),
157-
{
158-
title: 'Projects',
159-
dataTestId: 'click-on-projects',
160-
id: 'application-management-projects',
161-
icon: 'ic-folder',
162-
href: COMMON_URLS.APPLICATION_MANAGEMENT_PROJECTS,
163-
},
164157
{
165158
title: 'Configurations',
166159
dataTestId: 'click-on-configurations',
@@ -310,6 +303,14 @@ const NAVIGATION_LIST: NavigationGroupType[] = [
310303
href: URLS.GLOBAL_CONFIG_DOCKER,
311304
isAvailableInEA: true,
312305
},
306+
{
307+
title: 'Projects',
308+
dataTestId: 'click-on-projects',
309+
id: 'global-configuration-projects',
310+
icon: 'ic-folder',
311+
href: COMMON_URLS.GLOBAL_CONFIG_PROJECTS,
312+
isAvailableInEA: true,
313+
},
313314
{
314315
title: 'Authorization',
315316
dataTestId: 'authorization',

src/components/checkList/AppCheckList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class AppCheckList extends Component<AppCheckListProps, AppCheckListState
4242
)}
4343
{!project && (
4444
<NavLink
45-
to={COMMON_URLS.APPLICATION_MANAGEMENT_PROJECTS}
45+
to={COMMON_URLS.GLOBAL_CONFIG_PROJECTS}
4646
className="dc__no-decor mt-8 flex left"
4747
style={{ color: project ? `var(--N500)` : `var(--B500)` }}
4848
>

src/components/checkList/ChartCheckList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export class ChartCheckList extends Component<ChartCheckListProps, {}> {
3232
<div className="fs-13">
3333
{!this.props.chartChecklist.project && (
3434
<NavLink
35-
to={COMMON_URLS.APPLICATION_MANAGEMENT_PROJECTS}
35+
to={COMMON_URLS.GLOBAL_CONFIG_PROJECTS}
3636
className="dc__no-decor mt-8 flex left"
3737
style={{ color: project ? `var(--N500)` : `var(--B500)` }}
3838
>

src/components/common/navigation/NavigationRoutes.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ import './navigation.scss'
106106

107107
const Charts = lazy(() => import('../../charts/Charts'))
108108

109-
const ProjectList = lazy(() => import('@Components/project/ProjectList'))
110109
const GlobalConfig = lazy(() => import('../../globalConfigurations/GlobalConfiguration'))
111110
const BulkEdit = lazy(() => import('../../bulkEdits/BulkEdits'))
112111
const ResourceBrowser = lazy(() => import('../../ResourceBrowser/ResourceBrowserRouter'))
@@ -604,11 +603,6 @@ const NavigationRoutes = ({ reloadVersionConfig }: Readonly<NavigationRoutesType
604603
path={URLS.APPLICATION_MANAGEMENT_BULK_EDIT}
605604
render={() => <BulkEdit />}
606605
/>,
607-
<Route path={CommonURLS.APPLICATION_MANAGEMENT_PROJECTS}>
608-
{(props) => (
609-
<ProjectList {...props} isSuperAdmin={isSuperAdmin} />
610-
)}
611-
</Route>,
612606
<Route path={CommonURLS.APPLICATION_MANAGEMENT_CONFIGURATIONS}>
613607
<ApplicationManagementConfigurationsRouter />
614608
</Route>,

src/components/globalConfigurations/GlobalConfiguration.tsx

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ const Clusters = lazy(() => import('@Pages/GlobalConfigurations/ClustersAndEnvir
5555
const ChartRepo = lazy(() => import('@Components/chartRepo/ChartRepo'))
5656
const ExternalLinks = lazy(() => import('@Components/externalLinks/ExternalLinks'))
5757
const Authorization = lazy(() => import('@Pages/GlobalConfigurations/Authorization'))
58+
const ProjectList = lazy(() => import('@Components/project/ProjectList'))
5859

5960
export default function GlobalConfiguration(props) {
6061
const location = useLocation()
@@ -214,12 +215,16 @@ const NavItem = ({ serverMode }) => {
214215
}
215216

216217
const sideNavigationList: SideNavigationProps['list'] = [
217-
...(serverMode === SERVER_MODE.FULL ? [{
218-
id: 'host-url',
219-
title: 'Host URL',
220-
dataTestId: 'global-configurations-host-url',
221-
href: URLS.GLOBAL_CONFIG_HOST_URL,
222-
}] : []),
218+
...(serverMode === SERVER_MODE.FULL
219+
? [
220+
{
221+
id: 'host-url',
222+
title: 'Host URL',
223+
dataTestId: 'global-configurations-host-url',
224+
href: URLS.GLOBAL_CONFIG_HOST_URL,
225+
},
226+
]
227+
: []),
223228
{
224229
title: 'External Links',
225230
dataTestId: 'click-on-configurations-external-links',
@@ -244,6 +249,12 @@ const NavItem = ({ serverMode }) => {
244249
dataTestId: 'global-configurations-container-oci-registry',
245250
href: URLS.GLOBAL_CONFIG_DOCKER,
246251
},
252+
{
253+
id: 'global-configurations-projects',
254+
title: 'Projects',
255+
dataTestId: 'global-configurations-projects',
256+
href: CommonURLS.GLOBAL_CONFIG_PROJECTS,
257+
},
247258
{
248259
id: 'authorization',
249260
title: 'Authorization',
@@ -299,23 +310,17 @@ const Body = ({ getHostURLConfig, serverMode, handleChecklistUpdate, isSuperAdmi
299310
return URLS.GLOBAL_CONFIG_CLUSTER
300311
}
301312
if (serverMode === SERVER_MODE.EA_ONLY) {
302-
return CommonURLS.APPLICATION_MANAGEMENT_PROJECTS
313+
return CommonURLS.GLOBAL_CONFIG_PROJECTS
303314
}
304315
return URLS.GLOBAL_CONFIG_HOST_URL
305316
}
306317

307318
return (
308319
<Switch>
309-
<Route
310-
key={URLS.GLOBAL_CONFIG_EXTERNAL_LINKS}
311-
path={URLS.GLOBAL_CONFIG_EXTERNAL_LINKS}
312-
>
320+
<Route key={URLS.GLOBAL_CONFIG_EXTERNAL_LINKS} path={URLS.GLOBAL_CONFIG_EXTERNAL_LINKS}>
313321
<ExternalLinks />
314322
</Route>
315-
<Route
316-
key={URLS.GLOBAL_CONFIG_CHART_REPO}
317-
path={URLS.GLOBAL_CONFIG_CHART_REPO}
318-
>
323+
<Route key={URLS.GLOBAL_CONFIG_CHART_REPO} path={URLS.GLOBAL_CONFIG_CHART_REPO}>
319324
{(props) => <ChartRepo {...props} isSuperAdmin={isSuperAdmin} />}
320325
</Route>
321326
<Route
@@ -324,6 +329,10 @@ const Body = ({ getHostURLConfig, serverMode, handleChecklistUpdate, isSuperAdmi
324329
return <Clusters />
325330
}}
326331
/>
332+
<Route key={CommonURLS.GLOBAL_CONFIG_PROJECTS} path={CommonURLS.GLOBAL_CONFIG_PROJECTS}>
333+
<ProjectList isSuperAdmin={isSuperAdmin} />
334+
</Route>
335+
327336
{!window._env_.K8S_CLIENT && [
328337
...(serverMode !== SERVER_MODE.EA_ONLY
329338
? [

src/components/project/ProjectList.tsx

Lines changed: 20 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,14 @@ import {
2222
ErrorScreenNotAuthorized,
2323
ToastVariantType,
2424
ToastManager,
25-
PageHeader,
26-
BreadCrumb,
27-
useBreadcrumb,
28-
getApplicationManagementBreadcrumb,
29-
BreadcrumbText,
30-
DOCUMENTATION,
3125
} from '@devtron-labs/devtron-fe-common-lib'
32-
import { HEADER_TEXT, ViewType } from '../../config'
26+
import { ViewType } from '../../config'
3327
import { createProject, getProjectList } from './service'
3428
import { Project } from './Project'
3529
import { ProjectListState, ProjectType, ProjectListProps } from './types'
3630
import { ReactComponent as Add } from '../../assets/icons/ic-add.svg'
3731
import './project.scss'
3832
import { PROJECT_EXIST_MSG, REQUIRED_FIELD_MSG } from '../../config/constantMessaging'
39-
import { useLocation } from 'react-router-dom'
4033

4134
export default class ProjectList extends Component<ProjectListProps, ProjectListState> {
4235
constructor(props) {
@@ -59,6 +52,8 @@ export default class ProjectList extends Component<ProjectListProps, ProjectList
5952
}
6053

6154
getProjectList = () => {
55+
this.setState({ view: ViewType.LOADING })
56+
6257
getProjectList()
6358
.then((response) => {
6459
this.setState({
@@ -168,7 +163,7 @@ export default class ProjectList extends Component<ProjectListProps, ProjectList
168163
})
169164
.catch((errors) => {
170165
showError(errors)
171-
this.setState({ view: ViewType.ERROR, code: errors.code, loadingData: false })
166+
this.setState({ loadingData: false })
172167
})
173168
}
174169

@@ -207,45 +202,12 @@ export default class ProjectList extends Component<ProjectListProps, ProjectList
207202
}
208203
}
209204

210-
renderBreadcrumbs = () => {
211-
const { pathname } = useLocation()
212-
213-
const { breadcrumbs } = useBreadcrumb(
214-
{
215-
alias: {
216-
...getApplicationManagementBreadcrumb(),
217-
projects: { component: <BreadcrumbText heading="Projects" isActive /> },
218-
},
219-
},
220-
[pathname],
221-
)
222-
223-
return <BreadCrumb breadcrumbs={breadcrumbs} />
224-
}
225-
226-
renderPageHeader = () => (
227-
<PageHeader
228-
breadCrumbs={this.renderBreadcrumbs}
229-
isBreadcrumbs
230-
tippyProps={{
231-
isTippyCustomized: true,
232-
tippyRedirectLink: HEADER_TEXT.PROJECTS.docLink,
233-
tippyMessage: HEADER_TEXT.PROJECTS.description,
234-
tippyHeader: 'Projects',
235-
}}
236-
docPath={DOCUMENTATION.APP_MANAGEMENT}
237-
/>
238-
)
239-
240205
render() {
241206
if (!this.props.isSuperAdmin) {
242207
return (
243-
<>
244-
{this.renderPageHeader()}
245-
<div className="dc__align-reload-center">
246-
<ErrorScreenNotAuthorized />
247-
</div>
248-
</>
208+
<div className="dc__align-reload-center">
209+
<ErrorScreenNotAuthorized />
210+
</div>
249211
)
250212
}
251213
if (this.state.view === ViewType.LOADING) {
@@ -254,26 +216,23 @@ export default class ProjectList extends Component<ProjectListProps, ProjectList
254216
if (this.state.view === ViewType.ERROR) {
255217
return (
256218
<div className="dc__align-reload-center">
257-
<ErrorScreenManager code={this.state.code} />
219+
<ErrorScreenManager code={this.state.code} reload={this.getProjectList} />
258220
</div>
259221
)
260222
}
261223
return (
262-
<>
263-
{this.renderPageHeader()}
264-
<section className="flex-grow-1 flex top p-24 bg__secondary dc__overflow-auto">
265-
<div className="project-list-container flex-grow-1">
266-
{this.renderAddProject()}
267-
{this.state.projects.map((project, index) => {
268-
return (
269-
<React.Fragment key={`${project.name}-${index}`}>
270-
{this.renderProjects(project, index)}
271-
</React.Fragment>
272-
)
273-
})}
274-
</div>
275-
</section>
276-
</>
224+
<section className="flex-grow-1 flex top p-24 bg__secondary dc__overflow-auto">
225+
<div className="project-list-container flex-grow-1">
226+
{this.renderAddProject()}
227+
{this.state.projects.map((project, index) => {
228+
return (
229+
<React.Fragment key={`${project.name}-${index}`}>
230+
{this.renderProjects(project, index)}
231+
</React.Fragment>
232+
)
233+
})}
234+
</div>
235+
</section>
277236
)
278237
}
279238
}

src/config/constants.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -367,11 +367,6 @@ export const HEADER_TEXT: Record<string, { title: string; description: string; d
367367
description: 'Manage notifications for build and deployment pipelines.',
368368
docLink: "GLOBAL_CONFIG_NOTIFICATION"
369369
},
370-
PROJECTS: {
371-
title: 'Projects',
372-
description: "Manage your organization's projects.",
373-
docLink: "GLOBAL_CONFIG_PROJECT"
374-
},
375370
SSO_LOGIN: {
376371
title: 'SSO Login Service',
377372
description: 'Configure and manage login service for your organization.',

yarn.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1729,9 +1729,9 @@ __metadata:
17291729
languageName: node
17301730
linkType: hard
17311731

1732-
"@devtron-labs/devtron-fe-common-lib@npm:1.22.6":
1733-
version: 1.22.6
1734-
resolution: "@devtron-labs/devtron-fe-common-lib@npm:1.22.6"
1732+
"@devtron-labs/devtron-fe-common-lib@npm:1.22.6-beta-2":
1733+
version: 1.22.6-beta-2
1734+
resolution: "@devtron-labs/devtron-fe-common-lib@npm:1.22.6-beta-2"
17351735
dependencies:
17361736
"@codemirror/autocomplete": "npm:6.18.6"
17371737
"@codemirror/lang-json": "npm:6.0.1"
@@ -1785,7 +1785,7 @@ __metadata:
17851785
react-select: 5.8.0
17861786
rxjs: ^7.8.1
17871787
yaml: ^2.4.1
1788-
checksum: 10c0/2d549cb24e69a87d7cfdc32b12eee4dca51bac33408f81afba06d297a50753b62de2215fe44c7ac0237768fd3909939465201e559c8c6f3d13c0b119eab92e30
1788+
checksum: 10c0/b9802ebfbbb6b547d81c4585ad560e4a1a41808e065f9d5da090c5b754cd6ac67fd764ff446790c594365ca7cf1992b3c12588450c692d8bb1871256b425f491
17891789
languageName: node
17901790
linkType: hard
17911791

@@ -5599,7 +5599,7 @@ __metadata:
55995599
version: 0.0.0-use.local
56005600
resolution: "dashboard@workspace:."
56015601
dependencies:
5602-
"@devtron-labs/devtron-fe-common-lib": "npm:1.22.6"
5602+
"@devtron-labs/devtron-fe-common-lib": "npm:1.22.6-beta-2"
56035603
"@esbuild-plugins/node-globals-polyfill": "npm:0.2.3"
56045604
"@playwright/test": "npm:^1.32.1"
56055605
"@rjsf/core": "npm:^5.13.3"

0 commit comments

Comments
 (0)