Skip to content

Commit 56475d8

Browse files
committed
Fix rendering when trying to access server from state
1 parent 813a671 commit 56475d8

File tree

4 files changed

+29
-14
lines changed

4 files changed

+29
-14
lines changed

resources/scripts/components/elements/PageContentBlock.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,20 @@ import { CSSTransition } from 'react-transition-group';
44
import tw from 'twin.macro';
55
import FlashMessageRender from '@/components/FlashMessageRender';
66
import { Helmet } from 'react-helmet';
7-
import useServer from '@/plugins/useServer';
87

9-
interface Props {
8+
export interface PageContentBlockProps {
109
title?: string;
1110
className?: string;
1211
showFlashKey?: string;
1312
}
1413

15-
const PageContentBlock: React.FC<Props> = ({ title, showFlashKey, className, children }) => {
16-
const { name } = useServer();
17-
14+
const PageContentBlock: React.FC<PageContentBlockProps> = ({ title, showFlashKey, className, children }) => {
1815
return (
1916
<CSSTransition timeout={150} classNames={'fade'} appear in>
2017
<>
21-
{!!title &&
18+
{title &&
2219
<Helmet>
23-
<title>{name} | {title}</title>
20+
<title>{title}</title>
2421
</Helmet>
2522
}
2623
<ContentContainer css={tw`my-10`} className={className}>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import useServer from '@/plugins/useServer';
2+
import PageContentBlock, { PageContentBlockProps } from '@/components/elements/PageContentBlock';
3+
import React from 'react';
4+
5+
interface Props extends PageContentBlockProps {
6+
title: string;
7+
}
8+
9+
const ServerContentBlock: React.FC<Props> = ({ title, children, ...props }) => {
10+
const { name } = useServer();
11+
12+
return (
13+
<PageContentBlock title={`${name} | ${title}`} {...props}>
14+
{children}
15+
</PageContentBlock>
16+
);
17+
};
18+
19+
export default ServerContentBlock;

resources/scripts/components/server/network/NetworkContainer.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import React, { useEffect, useState } from 'react';
2-
import { Helmet } from 'react-helmet';
32
import tw from 'twin.macro';
43
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
54
import { faNetworkWired } from '@fortawesome/free-solid-svg-icons';
65
import styled from 'styled-components/macro';
7-
import PageContentBlock from '@/components/elements/PageContentBlock';
86
import GreyRowBox from '@/components/elements/GreyRowBox';
97
import Button from '@/components/elements/Button';
108
import Can from '@/components/elements/Can';
@@ -19,6 +17,7 @@ import { Textarea } from '@/components/elements/Input';
1917
import setServerAllocationNotes from '@/api/server/network/setServerAllocationNotes';
2018
import { debounce } from 'debounce';
2119
import InputSpinner from '@/components/elements/InputSpinner';
20+
import ServerContentBlock from '@/components/elements/ServerContentBlock';
2221

2322
const Code = styled.code`${tw`font-mono py-1 px-2 bg-neutral-900 rounded text-sm block`}`;
2423
const Label = styled.label`${tw`uppercase text-xs mt-1 text-neutral-400 block px-1 select-none transition-colors duration-150`}`;
@@ -61,7 +60,7 @@ const NetworkContainer = () => {
6160
}, [ error ]);
6261

6362
return (
64-
<PageContentBlock showFlashKey={'server:network'} title={'Network'}>
63+
<ServerContentBlock showFlashKey={'server:network'} title={'Network'}>
6564
{!data ?
6665
<Spinner size={'large'} centered/>
6766
:
@@ -109,7 +108,7 @@ const NetworkContainer = () => {
109108
</GreyRowBox>
110109
))
111110
}
112-
</PageContentBlock>
111+
</ServerContentBlock>
113112
);
114113
};
115114

resources/scripts/components/server/startup/StartupContainer.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import React from 'react';
2-
import PageContentBlock from '@/components/elements/PageContentBlock';
32
import TitledGreyBox from '@/components/elements/TitledGreyBox';
43
import useServer from '@/plugins/useServer';
54
import tw from 'twin.macro';
65
import VariableBox from '@/components/server/startup/VariableBox';
6+
import ServerContentBlock from '@/components/elements/ServerContentBlock';
77

88
const StartupContainer = () => {
99
const { invocation, variables } = useServer();
1010

1111
return (
12-
<PageContentBlock title={'Startup Settings'} showFlashKey={'server:startup'}>
12+
<ServerContentBlock title={'Startup Settings'}>
1313
<TitledGreyBox title={'Startup Command'}>
1414
<div css={tw`px-1 py-2`}>
1515
<p css={tw`font-mono bg-neutral-900 rounded py-2 px-4`}>
@@ -20,7 +20,7 @@ const StartupContainer = () => {
2020
<div css={tw`grid gap-8 grid-cols-2 mt-10`}>
2121
{variables.map(variable => <VariableBox key={variable.envVariable} variable={variable}/>)}
2222
</div>
23-
</PageContentBlock>
23+
</ServerContentBlock>
2424
);
2525
};
2626

0 commit comments

Comments
 (0)