Skip to content

Commit bdbaf5c

Browse files
author
Aleksander Obrestad
committed
Merge branch 'oversitsside-for-funksjoner' into spire-dev
2 parents 376dbca + 6693c3c commit bdbaf5c

File tree

2 files changed

+88
-1
lines changed

2 files changed

+88
-1
lines changed

packages/app/src/App.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ExplorePage } from '@backstage-community/plugin-explore';
22
import { LighthousePage } from '@backstage-community/plugin-lighthouse';
33
import { createApp } from '@backstage/app-defaults';
4-
import { AppRouter, FlatRoutes } from '@backstage/core-app-api';
4+
import { AppRouter, FeatureFlagged, FlatRoutes } from '@backstage/core-app-api';
55
import {
66
AlertDisplay,
77
OAuthRequestDialog,
@@ -55,6 +55,7 @@ import {
5555
} from '@kartverket/backstage-plugin-catalog-creator';
5656
import { NotificationsPage } from '@backstage/plugin-notifications';
5757
import { SignalsDisplay } from '@backstage/plugin-signals';
58+
import { FunctionsPage } from './components/functions/FunctionsPage';
5859

5960
const app = createApp({
6061
__experimentalTranslations: {
@@ -131,6 +132,9 @@ const routes = (
131132
<HomePage />
132133
</Route>
133134
<Route path="/catalog" element={<CatalogIndexPage />} />
135+
<FeatureFlagged with="show-functions-page">
136+
<Route path="/functions" element={<FunctionsPage />} />
137+
</FeatureFlagged>
134138
<Route
135139
path="/catalog/:namespace/:kind/:name"
136140
element={<CatalogEntityPage />}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import { Grid } from '@material-ui/core';
2+
import {
3+
CatalogTable,
4+
CatalogTableColumnsFunc,
5+
} from '@backstage/plugin-catalog';
6+
import { Content, Header, InfoCard, Page } from '@backstage/core-components';
7+
import {
8+
catalogApiRef,
9+
EntityKindPicker,
10+
EntityListProvider,
11+
} from '@backstage/plugin-catalog-react';
12+
import { EntityRelationsGraph } from '@backstage/plugin-catalog-graph';
13+
import { useApi } from '@backstage/core-plugin-api';
14+
import { useEffect, useState } from 'react';
15+
16+
type RootEntityNamesType = {
17+
kind: string;
18+
namespace: string;
19+
name: string;
20+
};
21+
22+
const functionColumns: CatalogTableColumnsFunc = entityListContext => {
23+
if (entityListContext.filters.kind?.value === 'function') {
24+
return [
25+
CatalogTable.columns.createNameColumn({ defaultKind: 'function' }),
26+
CatalogTable.columns.createOwnerColumn(),
27+
CatalogTable.columns.createSpecTypeColumn(),
28+
];
29+
}
30+
31+
return CatalogTable.defaultColumnsFunc(entityListContext);
32+
};
33+
34+
export const FunctionsPage = () => {
35+
const [rootEntity, setRootEntity] = useState<RootEntityNamesType[]>([]);
36+
const catalogApi = useApi(catalogApiRef);
37+
38+
useEffect(() => {
39+
catalogApi.getEntities({ filter: { kind: 'function' } }).then(response => {
40+
const filteredResponse = response.items.filter(item =>
41+
item.metadata.name === 'rootfunction' ? item : null,
42+
);
43+
setRootEntity(
44+
filteredResponse.map(item => ({
45+
kind: item.kind,
46+
namespace: item.metadata.namespace || 'default',
47+
name: item.metadata.name,
48+
})),
49+
);
50+
});
51+
}, [catalogApi]);
52+
53+
return (
54+
<Page themeId="functions">
55+
<Header
56+
title="Forretningsfunksjoner i Kartverket"
57+
subtitle="Oversikt over hva Kartverket må kunne gjøre for å levere på sitt samfunnsoppdrag, og hvordan dette støttes av del-funksjoner, systemer og team."
58+
/>
59+
<Content>
60+
<EntityListProvider>
61+
<Grid container spacing={3}>
62+
<Grid item xs={12} md={6}>
63+
<EntityKindPicker initialFilter="function" hidden />
64+
<CatalogTable
65+
title="Alle forretningsfunksjoner"
66+
columns={functionColumns}
67+
/>
68+
</Grid>
69+
<Grid item xs={12} md={6}>
70+
<InfoCard title="Funksjonshierarki">
71+
<EntityRelationsGraph
72+
rootEntityNames={rootEntity}
73+
kinds={['function']}
74+
maxDepth={2}
75+
/>
76+
</InfoCard>
77+
</Grid>
78+
</Grid>
79+
</EntityListProvider>
80+
</Content>
81+
</Page>
82+
);
83+
};

0 commit comments

Comments
 (0)