-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement edit permissions for portal administration components
- Loading branch information
Showing
12 changed files
with
190 additions
and
149 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
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
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
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
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
81 changes: 41 additions & 40 deletions
81
client/apps/portal-administration/src/components/Router/RouteTreeItem.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 |
---|---|---|
@@ -1,45 +1,46 @@ | ||
import { tokens } from "@equinor/eds-tokens"; | ||
import { Route } from "../../types/router-config"; | ||
import { RouteMenu } from "./RouteMenu"; | ||
import { useRouterConfigContext } from "../../context/RouterContext"; | ||
import { Typography } from "@equinor/eds-core-react"; | ||
import styled from "styled-components"; | ||
import { TreeItem } from "../Tree/TreeItem"; | ||
import { tokens } from '@equinor/eds-tokens'; | ||
import { Route } from '../../types/router-config'; | ||
import { RouteMenu } from './RouteMenu'; | ||
import { useRouterConfigContext } from '../../context/RouterContext'; | ||
import { Typography } from '@equinor/eds-core-react'; | ||
import styled from 'styled-components'; | ||
import { TreeItem } from '../Tree/TreeItem'; | ||
|
||
const Style = { | ||
Content: styled.div` | ||
display: flex; | ||
flex-direction: row; | ||
align-items: center; | ||
min-width: 150px; | ||
justify-content: flex-end; | ||
`, | ||
Content: styled.div` | ||
display: flex; | ||
flex-direction: row; | ||
align-items: center; | ||
min-width: 150px; | ||
justify-content: flex-end; | ||
`, | ||
box: styled.div` | ||
min-width: 10px; | ||
`, | ||
}; | ||
|
||
export const RouteTreeItem = ({ route }: { route: Route }) => { | ||
const { activeRoute, setActiveRoute } = useRouterConfigContext(); | ||
return ( | ||
<TreeItem | ||
onClick={() => setActiveRoute(route.id)} | ||
selected={ | ||
activeRoute?.id === route.id | ||
? tokens.colors.interactive.primary__selected_highlight.hex | ||
: undefined | ||
} | ||
title={route.path} | ||
key={route.path} | ||
Render={() => { | ||
return ( | ||
<Style.Content> | ||
<Typography variant="overline">- {route.pageKey}</Typography> | ||
<RouteMenu route={route} /> | ||
</Style.Content> | ||
); | ||
}} | ||
> | ||
{route.children?.map((childRoute) => ( | ||
<RouteTreeItem route={childRoute} key={childRoute.path}></RouteTreeItem> | ||
))} | ||
</TreeItem> | ||
); | ||
export const RouteTreeItem = ({ route, canEdit }: { route: Route; canEdit?: boolean }) => { | ||
const { activeRoute, setActiveRoute } = useRouterConfigContext(); | ||
return ( | ||
<TreeItem | ||
onClick={() => setActiveRoute(route.id)} | ||
selected={ | ||
activeRoute?.id === route.id ? tokens.colors.interactive.primary__selected_highlight.hex : undefined | ||
} | ||
title={route.path} | ||
key={route.path} | ||
Render={() => { | ||
return ( | ||
<Style.Content> | ||
<Typography variant="overline">- {route.pageKey}</Typography> | ||
{canEdit ? <RouteMenu route={route} /> : <Style.box></Style.box>} | ||
</Style.Content> | ||
); | ||
}} | ||
> | ||
{route.children?.map((childRoute) => ( | ||
<RouteTreeItem route={childRoute} key={childRoute.path} canEdit={canEdit}></RouteTreeItem> | ||
))} | ||
</TreeItem> | ||
); | ||
}; |
Oops, something went wrong.