-
Notifications
You must be signed in to change notification settings - Fork 593
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds details page and handles breadcrumb
- Loading branch information
1 parent
8b6567c
commit 15107df
Showing
10 changed files
with
159 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
frontend/packages/console-shared/src/hooks/useTabbedTableBreadcrumb.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { match as RMatch } from 'react-router-dom'; | ||
import { K8sKind } from '@console/internal/module/k8s'; | ||
// FIXME upgrading redux types is causing many errors at this time | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore | ||
// @ts-ignore | ||
import { useSelector } from 'react-redux'; | ||
import { getBreadcrumbPath } from '@console/internal/components/utils/breadcrumbs'; | ||
import { RootState } from '@console/internal/redux'; | ||
import { getActivePerspective, getActiveNamespace } from '@console/internal/reducers/ui'; | ||
import { ALL_NAMESPACES_KEY } from '../constants/common'; | ||
|
||
type Match = RMatch<{ url: string }>; | ||
|
||
export const useTabbedTableBreadcrumbsFor = ( | ||
kindObj: K8sKind, | ||
match: Match, | ||
navOption: string, | ||
subTab: string = null, | ||
) => { | ||
const currentNamespace = useSelector((state: RootState) => getActiveNamespace(state)); | ||
const isAdminPerspective = | ||
useSelector((state: RootState) => getActivePerspective(state)) === 'admin'; | ||
const nsURL = | ||
ALL_NAMESPACES_KEY === currentNamespace ? 'all-namespaces' : `ns/${currentNamespace}`; | ||
|
||
if (subTab == null) { | ||
return []; | ||
} | ||
|
||
return [ | ||
{ | ||
name: kindObj.labelPlural, | ||
path: isAdminPerspective ? `/${navOption}/${nsURL}/${subTab}` : getBreadcrumbPath(match), | ||
}, | ||
{ name: `${kindObj.label} Details`, path: match.url }, | ||
]; | ||
}; |
36 changes: 4 additions & 32 deletions
36
frontend/packages/dev-console/src/components/pipelines/hooks.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,15 @@ | ||
import { match as RMatch } from 'react-router-dom'; | ||
// FIXME upgrading redux types is causing many errors at this time | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore | ||
// @ts-ignore | ||
import { useSelector } from 'react-redux'; | ||
import { getBreadcrumbPath } from '@console/internal/components/utils/breadcrumbs'; | ||
import { useTabbedTableBreadcrumbsFor } from '@console/shared'; | ||
import { K8sKind } from '@console/internal/module/k8s'; | ||
import { RootState } from '@console/internal/redux'; | ||
import { getActivePerspective, getActiveNamespace } from '@console/internal/reducers/ui'; | ||
import { ALL_NAMESPACES_KEY } from '@console/shared'; | ||
import { pipelinesTab } from '../../utils/pipeline-utils'; | ||
|
||
type Match = RMatch<{ url: string }>; | ||
|
||
const useTabbedTableBreadcrumbsFor = (kindObj: K8sKind, match: Match, navOption: string) => { | ||
const currentNamespace = useSelector((state: RootState) => getActiveNamespace(state)); | ||
const isAdminPerspective = | ||
useSelector((state: RootState) => getActivePerspective(state)) === 'admin'; | ||
const nsURL = | ||
ALL_NAMESPACES_KEY === currentNamespace ? 'all-namespaces' : `ns/${currentNamespace}`; | ||
const subTab = pipelinesTab(kindObj); | ||
|
||
if (subTab == null) { | ||
return []; | ||
} | ||
|
||
return [ | ||
{ | ||
name: kindObj.labelPlural, | ||
path: isAdminPerspective ? `/${navOption}/${nsURL}/${subTab}` : getBreadcrumbPath(match), | ||
}, | ||
{ name: `${kindObj.label} Details`, path: match.url }, | ||
]; | ||
}; | ||
|
||
export const usePipelinesBreadcrumbsFor = (kindObj: K8sKind, match: Match) => | ||
useTabbedTableBreadcrumbsFor(kindObj, match, 'pipelines'); | ||
useTabbedTableBreadcrumbsFor(kindObj, match, 'pipelines', pipelinesTab(kindObj)); | ||
|
||
export const useTasksBreadcrumbsFor = (kindObj: K8sKind, match: Match) => | ||
useTabbedTableBreadcrumbsFor(kindObj, match, 'tasks'); | ||
useTabbedTableBreadcrumbsFor(kindObj, match, 'tasks', pipelinesTab(kindObj)); | ||
|
||
export const useTriggersBreadcrumbsFor = (kindObj: K8sKind, match: Match) => | ||
useTabbedTableBreadcrumbsFor(kindObj, match, 'triggers'); | ||
useTabbedTableBreadcrumbsFor(kindObj, match, 'triggers', pipelinesTab(kindObj)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
frontend/packages/knative-plugin/src/components/routes/RouteDetailsPage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import * as React from 'react'; | ||
import { Kebab, navFactory } from '@console/internal/components/utils'; | ||
import { DetailsPage } from '@console/internal/components/factory'; | ||
|
||
import { DetailsForKind } from '@console/internal/components/default-resource'; | ||
import { useServingBreadcrumbsFor } from '../services/hooks'; | ||
import { RouteModel } from '../../models'; | ||
|
||
const RouteDetailsPage: React.FC<React.ComponentProps<typeof DetailsPage>> = (props) => { | ||
const { kindObj, match } = props; | ||
const breadcrumbsFor = useServingBreadcrumbsFor(kindObj, match); | ||
const pages = [navFactory.details(DetailsForKind(props.kind)), navFactory.editYaml()]; | ||
const commonActions = Kebab.factory.common.map((action) => action); | ||
const menuActionsCreator = [...Kebab.getExtensionsActionsForKind(RouteModel), ...commonActions]; | ||
|
||
return ( | ||
<DetailsPage | ||
{...props} | ||
breadcrumbsFor={() => breadcrumbsFor} | ||
pages={pages} | ||
menuActions={menuActionsCreator} | ||
/> | ||
); | ||
}; | ||
|
||
export default RouteDetailsPage; |
26 changes: 26 additions & 0 deletions
26
frontend/packages/knative-plugin/src/components/services/ServiceDetailsPage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import * as React from 'react'; | ||
import { Kebab, navFactory } from '@console/internal/components/utils'; | ||
import { DetailsPage } from '@console/internal/components/factory'; | ||
|
||
import { DetailsForKind } from '@console/internal/components/default-resource'; | ||
import { useServingBreadcrumbsFor } from './hooks'; | ||
import { ServiceModel } from '../../models'; | ||
|
||
const ServiceDetailsPage: React.FC<React.ComponentProps<typeof DetailsPage>> = (props) => { | ||
const { kindObj, match } = props; | ||
const breadcrumbsFor = useServingBreadcrumbsFor(kindObj, match); | ||
const pages = [navFactory.details(DetailsForKind(props.kind)), navFactory.editYaml()]; | ||
const commonActions = Kebab.factory.common.map((action) => action); | ||
const menuActionsCreator = [...Kebab.getExtensionsActionsForKind(ServiceModel), ...commonActions]; | ||
|
||
return ( | ||
<DetailsPage | ||
{...props} | ||
breadcrumbsFor={() => breadcrumbsFor} | ||
pages={pages} | ||
menuActions={menuActionsCreator} | ||
/> | ||
); | ||
}; | ||
|
||
export default ServiceDetailsPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
frontend/packages/knative-plugin/src/components/services/hooks.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { match as RMatch } from 'react-router-dom'; | ||
import { K8sKind } from '@console/internal/module/k8s'; | ||
import { useTabbedTableBreadcrumbsFor } from '@console/shared'; | ||
import { servingTab } from '../../utils/serverless-tab-utils'; | ||
|
||
type Match = RMatch<{ url: string }>; | ||
|
||
export const useServingBreadcrumbsFor = (kindObj: K8sKind, match: Match) => | ||
useTabbedTableBreadcrumbsFor(kindObj, match, 'serving', servingTab(kindObj)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
frontend/packages/knative-plugin/src/utils/serverless-tab-utils.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { K8sKind } from '@console/internal/module/k8s'; | ||
import { RevisionModel, ServiceModel, RouteModel } from '../models'; | ||
|
||
export const servingTab = (kindObj: K8sKind) => { | ||
switch (kindObj.kind) { | ||
case ServiceModel.kind: | ||
return ''; | ||
case RevisionModel.kind: | ||
return 'revisions'; | ||
case RouteModel.kind: | ||
return 'routes'; | ||
default: | ||
return null; | ||
} | ||
}; |