diff --git a/resources/scripts/components/admin/overview/OverviewContainer.tsx b/resources/scripts/components/admin/overview/OverviewContainer.tsx index 64c1f1a66..f8725aa40 100644 --- a/resources/scripts/components/admin/overview/OverviewContainer.tsx +++ b/resources/scripts/components/admin/overview/OverviewContainer.tsx @@ -1,14 +1,89 @@ -import React from 'react'; +import React, { useEffect, useState } from 'react'; import tw from 'twin.macro'; +import useFlash from '@/plugins/useFlash'; import AdminContentBlock from '@/components/admin/AdminContentBlock'; +import FlashMessageRender from '@/components/FlashMessageRender'; +import Spinner from '@/components/elements/Spinner'; +import getVersion, { VersionData } from '@/api/admin/getVersion'; + +const Code = ({ children }: { children: React.ReactNode }) => { + return ( + + {children} + + ); +}; export default () => { + const { clearFlashes, clearAndAddHttpError } = useFlash(); + const [ loading, setLoading ] = useState(true); + const [ versionData, setVersionData ] = useState(undefined); + + useEffect(() => { + clearFlashes('overview'); + + getVersion() + .then(versionData => setVersionData(versionData)) + .catch(error => { + console.error(error); + clearAndAddHttpError(error); + }) + .then(() => setLoading(false)); + }, []); + return ( -
+

Overview

A quick glance at your system.

+ + + +
+ { loading ? +
+ +
+ : +
+
+

+ + + + + System Information +

+
+ +
+ {versionData?.panel.current === 'canary' ? +

+ I hope you enjoy living on the edge because you are + running a {versionData?.panel.current} version + of Pterodactyl. +

+ : versionData?.panel.latest === versionData?.panel.current + ? +

+ Your panel is up-to-date. + The latest version + is {versionData?.panel.latest} and you are + running version {versionData?.panel.current}. +

+ : +

+ Your panel is not up-to-date. + The latest version + is {versionData?.panel.latest} and you are + running version {versionData?.panel.current}. +

+ } +
+
+ } +
); }; diff --git a/resources/scripts/components/admin/roles/RolesContainer.tsx b/resources/scripts/components/admin/roles/RolesContainer.tsx index b35b8dc5c..73cd52b7a 100644 --- a/resources/scripts/components/admin/roles/RolesContainer.tsx +++ b/resources/scripts/components/admin/roles/RolesContainer.tsx @@ -1,8 +1,6 @@ -import CopyOnClick from '@/components/elements/CopyOnClick'; import React, { useEffect, useState } from 'react'; import { useDeepMemoize } from '@/plugins/useDeepMemoize'; import { AdminContext } from '@/state/admin'; -import { httpErrorToHuman } from '@/api/http'; import NewRoleButton from '@/components/admin/roles/NewRoleButton'; import FlashMessageRender from '@/components/FlashMessageRender'; import useFlash from '@/plugins/useFlash'; @@ -12,6 +10,7 @@ import AdminContentBlock from '@/components/admin/AdminContentBlock'; import getRoles from '@/api/admin/roles/getRoles'; import AdminCheckbox from '@/components/admin/AdminCheckbox'; import AdminTable, { ContentWrapper, Loading, NoItems, TableBody, TableHead, TableHeader, TableRow } from '@/components/admin/AdminTable'; +import CopyOnClick from '@/components/elements/CopyOnClick'; const RowCheckbox = ({ id }: { id: number}) => { const isChecked = AdminContext.useStoreState(state => state.roles.selectedRoles.indexOf(id) >= 0); @@ -36,7 +35,7 @@ const RowCheckbox = ({ id }: { id: number}) => { export default () => { const match = useRouteMatch(); - const { addError, clearFlashes } = useFlash(); + const { clearFlashes, clearAndAddHttpError } = useFlash(); const [ loading, setLoading ] = useState(true); const roles = useDeepMemoize(AdminContext.useStoreState(state => state.roles.data)); @@ -53,7 +52,7 @@ export default () => { .then(roles => setRoles(roles)) .catch(error => { console.error(error); - addError({ message: httpErrorToHuman(error), key: 'roles' }); + clearAndAddHttpError(error); }) .then(() => setLoading(false)); }, []);