-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
215 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; | ||
import { FormattedMessage } from "react-intl"; | ||
import { Link } from "react-router-dom"; | ||
|
||
import IHomeCardProps from "./HomeCardProps"; | ||
|
||
import { Card, CardContent, CardFooter } from "@/components/ui/card"; | ||
|
||
const HomeCard = (props: IHomeCardProps) => { | ||
const enabled = props.calculateEnabled ? props.calculateEnabled(props.queryData) : true; | ||
const RenderCard = () => ( | ||
<Card | ||
className={enabled ? "text-primary hover:text-primary-foreground" : "text-destructive"}> | ||
<CardContent style={{ height: "245px" }} className="text-center border-0"> | ||
<FontAwesomeIcon className="w-4/5 h-4/5 mt-4 mb-4" icon={props.icon} /> | ||
<hr /> | ||
</CardContent> | ||
<CardFooter className={"justify-center font-bold text-lg" + (enabled ? "" : "italic")}> | ||
<FormattedMessage id={props.localeNameId} /> | ||
</CardFooter> | ||
</Card> | ||
); | ||
return ( | ||
<div className="m-4"> | ||
{enabled ? <Link to={props.path}>{RenderCard()}</Link> : RenderCard()} | ||
</div> | ||
); | ||
}; | ||
export default HomeCard; |
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,11 @@ | ||
import { IconProp } from "@fortawesome/fontawesome-svg-core"; | ||
|
||
import { HomeCardPermissionsQuery$data } from "../graphql/__generated__/HomeCardPermissionsQuery.graphql"; | ||
|
||
export default interface IHomeCardProps { | ||
icon: IconProp; | ||
localeNameId: string; | ||
path: string; | ||
calculateEnabled?: (data: HomeCardPermissionsQuery$data) => boolean | undefined; | ||
queryData: HomeCardPermissionsQuery$data; | ||
} |
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,83 @@ | ||
import { | ||
faCogs, | ||
faHdd, | ||
faInfoCircle, | ||
faKey, | ||
faTools, | ||
faUser | ||
} from "@fortawesome/free-solid-svg-icons"; | ||
import { lazy } from "react"; | ||
import { RouteObject } from "react-router-dom"; | ||
|
||
import HomeCardProps from "./HomeCard/HomeCardProps"; | ||
|
||
import NotFound from "@/components/core/NotFound/NotFound"; | ||
import devDelay from "@/lib/devDelay"; | ||
|
||
const Configuration = lazy( | ||
async () => | ||
await devDelay( | ||
() => import("@/components/routed/Configuration/Configuration"), | ||
"Component Load: Configuration" | ||
) | ||
); | ||
|
||
interface IHomeRouteProtected { | ||
unprotected?: boolean; | ||
} | ||
|
||
type HomeRoute = RouteObject & IHomeRouteProtected & Omit<HomeCardProps, "queryData">; | ||
|
||
const HomeRoutes: HomeRoute[] = [ | ||
{ | ||
path: "instances", | ||
icon: faHdd, | ||
localeNameId: "routes.instancelist", | ||
calculateEnabled: data => | ||
data.node?.effectivePermissionSet?.instanceManagerRights.canList || | ||
data.node?.effectivePermissionSet?.instanceManagerRights.canRead, | ||
element: <NotFound /> | ||
}, | ||
{ | ||
path: "users", | ||
icon: faUser, | ||
localeNameId: "routes.usermanager", | ||
calculateEnabled: data => | ||
data.node?.effectivePermissionSet?.administrationRights.canReadUsers || | ||
data.node?.effectivePermissionSet?.administrationRights.canWriteUsers, | ||
element: <NotFound /> | ||
}, | ||
{ | ||
path: "admin", | ||
icon: faTools, | ||
localeNameId: "routes.admin", | ||
calculateEnabled: data => | ||
data.node?.effectivePermissionSet?.administrationRights.canChangeVersion || | ||
data.node?.effectivePermissionSet?.administrationRights.canDownloadLogs || | ||
data.node?.effectivePermissionSet?.administrationRights.canUploadVersion, | ||
element: <NotFound /> | ||
}, | ||
{ | ||
path: "/users/passwd", | ||
icon: faKey, | ||
localeNameId: "routes.passwd", | ||
calculateEnabled: data => | ||
data.node?.effectivePermissionSet?.administrationRights.canEditOwnPassword, | ||
element: <NotFound /> | ||
}, | ||
{ | ||
path: "/config", | ||
icon: faCogs, | ||
localeNameId: "routes.config", | ||
element: <Configuration />, | ||
unprotected: true | ||
}, | ||
{ | ||
path: "/info", | ||
icon: faInfoCircle, | ||
localeNameId: "routes.info", | ||
element: <NotFound /> | ||
} | ||
]; | ||
|
||
export default HomeRoutes; |
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 { graphql } from "react-relay"; | ||
|
||
const HomeCardPermissions = graphql` | ||
query HomeCardPermissionsQuery($userID: ID!) { | ||
node(id: $userID) { | ||
... on User { | ||
effectivePermissionSet { | ||
administrationRights { | ||
canChangeVersion | ||
canDownloadLogs | ||
canUploadVersion | ||
canEditOwnPassword | ||
canReadUsers | ||
canWriteUsers | ||
} | ||
instanceManagerRights { | ||
canList | ||
canRead | ||
} | ||
} | ||
} | ||
} | ||
} | ||
`; | ||
|
||
export default HomeCardPermissions; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ const ServerLogin = graphql` | |
loginResult { | ||
bearer | ||
user { | ||
id | ||
...CommonUserDetailsFragment | ||
} | ||
} | ||
|
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