Add admin area link to view config

This commit is contained in:
Charles Morgan 2020-11-02 00:14:02 -05:00
parent 964a1436ce
commit 6d909a4a97
No known key found for this signature in database
GPG key ID: D71946CD723249BD
3 changed files with 11 additions and 0 deletions

View file

@ -46,6 +46,7 @@ class ServerTransformer extends BaseClientTransformer
return [ return [
'server_owner' => $this->getKey()->user_id === $server->owner_id, 'server_owner' => $this->getKey()->user_id === $server->owner_id,
'identifier' => $server->uuidShort, 'identifier' => $server->uuidShort,
'internal_id' => $server->id,
'uuid' => $server->uuid, 'uuid' => $server->uuid,
'name' => $server->name, 'name' => $server->name,
'node' => $server->node->name, 'node' => $server->node->name,

View file

@ -13,6 +13,7 @@ export interface Allocation {
export interface Server { export interface Server {
id: string; id: string;
internalId: number;
uuid: string; uuid: string;
name: string; name: string;
node: string; node: string;
@ -43,6 +44,7 @@ export interface Server {
export const rawDataToServerObject = ({ attributes: data }: FractalResponseData): Server => ({ export const rawDataToServerObject = ({ attributes: data }: FractalResponseData): Server => ({
id: data.identifier, id: data.identifier,
internalId: data.internal_id,
uuid: data.uuid, uuid: data.uuid,
name: data.name, name: data.name,
node: data.node, node: data.node,

View file

@ -29,6 +29,8 @@ import InstallListener from '@/components/server/InstallListener';
import StartupContainer from '@/components/server/startup/StartupContainer'; import StartupContainer from '@/components/server/startup/StartupContainer';
import requireServerPermission from '@/hoc/requireServerPermission'; import requireServerPermission from '@/hoc/requireServerPermission';
import ErrorBoundary from '@/components/elements/ErrorBoundary'; import ErrorBoundary from '@/components/elements/ErrorBoundary';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faExternalLinkAlt } from '@fortawesome/free-solid-svg-icons';
const ServerRouter = ({ match, location }: RouteComponentProps<{ id: string }>) => { const ServerRouter = ({ match, location }: RouteComponentProps<{ id: string }>) => {
const rootAdmin = useStoreState(state => state.user.data!.rootAdmin); const rootAdmin = useStoreState(state => state.user.data!.rootAdmin);
@ -40,6 +42,7 @@ const ServerRouter = ({ match, location }: RouteComponentProps<{ id: string }>)
const isInstalling = ServerContext.useStoreState(state => state.server.data?.isInstalling); const isInstalling = ServerContext.useStoreState(state => state.server.data?.isInstalling);
const getServer = ServerContext.useStoreActions(actions => actions.server.getServer); const getServer = ServerContext.useStoreActions(actions => actions.server.getServer);
const clearServerState = ServerContext.useStoreActions(actions => actions.clearServerState); const clearServerState = ServerContext.useStoreActions(actions => actions.clearServerState);
const serverId = ServerContext.useStoreState(state => state.server.data?.internalId);
useEffect(() => () => { useEffect(() => () => {
clearServerState(); clearServerState();
@ -109,6 +112,11 @@ const ServerRouter = ({ match, location }: RouteComponentProps<{ id: string }>)
<Can action={[ 'settings.*', 'file.sftp' ]} matchAny> <Can action={[ 'settings.*', 'file.sftp' ]} matchAny>
<NavLink to={`${match.url}/settings`}>Settings</NavLink> <NavLink to={`${match.url}/settings`}>Settings</NavLink>
</Can> </Can>
{rootAdmin &&
<a href={'/admin/servers/view/' + serverId} rel="noreferrer" target={'_blank'}>
<FontAwesomeIcon icon={faExternalLinkAlt}/>
</a>
}
</div> </div>
</SubNavigation> </SubNavigation>
</CSSTransition> </CSSTransition>