Skip to content

Commit bf287c4

Browse files
committed
Logic improvements, move stat blocks to right side
1 parent ad6e9f0 commit bf287c4

File tree

5 files changed

+27
-32
lines changed

5 files changed

+27
-32
lines changed

resources/scripts/components/elements/CopyOnClick.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Portal from '@/components/elements/Portal';
44
import copy from 'copy-to-clipboard';
55
import classNames from 'classnames';
66

7-
const CopyOnClick: React.FC<{ text: any; disabled?: boolean }> = ({ text, disabled, children }) => {
7+
const CopyOnClick: React.FC<{ text: string | number | null | undefined }> = ({ text, children }) => {
88
const [copied, setCopied] = useState(false);
99

1010
useEffect(() => {
@@ -23,12 +23,12 @@ const CopyOnClick: React.FC<{ text: any; disabled?: boolean }> = ({ text, disabl
2323
throw new Error('Component passed to <CopyOnClick/> must be a valid React element.');
2424
}
2525

26-
const child = disabled
26+
const child = !text
2727
? React.Children.only(children)
2828
: React.cloneElement(React.Children.only(children), {
2929
className: classNames(children.props.className || '', 'cursor-pointer'),
3030
onClick: (e: React.MouseEvent<HTMLElement>) => {
31-
copy(text);
31+
copy(String(text));
3232
setCopied(true);
3333
if (typeof children.props.onClick === 'function') {
3434
children.props.onClick(e);

resources/scripts/components/server/console/PowerButtons.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,25 +50,21 @@ export default ({ className }: PowerButtonProps) => {
5050
</Dialog.Confirm>
5151
<Can action={'control.start'}>
5252
<Button
53-
className={'w-full sm:w-24'}
53+
className={'flex-1'}
5454
disabled={status !== 'offline'}
5555
onClick={onButtonClick.bind(this, 'start')}
5656
>
5757
Start
5858
</Button>
5959
</Can>
6060
<Can action={'control.restart'}>
61-
<Button.Text
62-
className={'w-full sm:w-24'}
63-
disabled={!status}
64-
onClick={onButtonClick.bind(this, 'restart')}
65-
>
61+
<Button.Text className={'flex-1'} disabled={!status} onClick={onButtonClick.bind(this, 'restart')}>
6662
Restart
6763
</Button.Text>
6864
</Can>
6965
<Can action={'control.stop'}>
7066
<Button.Danger
71-
className={'w-full sm:w-24'}
67+
className={'flex-1'}
7268
disabled={status === 'offline'}
7369
onClick={onButtonClick.bind(this, killable ? 'kill' : 'stop')}
7470
>

resources/scripts/components/server/console/ServerConsoleContainer.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,24 @@ const ServerConsoleContainer = () => {
2323

2424
return (
2525
<ServerContentBlock title={'Console'} className={'flex flex-col gap-2 sm:gap-4'}>
26-
<div className={'flex gap-4 items-end'}>
27-
<div className={'hidden sm:block flex-1'}>
26+
<div className={'grid grid-cols-4 gap-4'}>
27+
<div className={'hidden sm:block sm:col-span-2 lg:col-span-3 pr-4'}>
2828
<h1 className={'font-header text-2xl text-gray-50 leading-relaxed line-clamp-1'}>{name}</h1>
2929
<p className={'text-sm line-clamp-2'}>{description}</p>
3030
</div>
31-
<div className={'flex-1'}>
31+
<div className={'col-span-4 sm:col-span-2 lg:col-span-1 self-end'}>
3232
<Can action={['control.start', 'control.stop', 'control.restart']} matchAny>
3333
<PowerButtons className={'flex sm:justify-end space-x-2'} />
3434
</Can>
3535
</div>
3636
</div>
3737
<div className={'grid grid-cols-4 gap-2 sm:gap-4'}>
38-
<ServerDetailsBlock className={'col-span-4 lg:col-span-1 order-last lg:order-none'} />
3938
<div className={'col-span-4 lg:col-span-3'}>
4039
<Spinner.Suspense>
4140
<Console />
4241
</Spinner.Suspense>
4342
</div>
43+
<ServerDetailsBlock className={'col-span-4 lg:col-span-1 order-last lg:order-none'} />
4444
{isInstalling ? (
4545
<div css={tw`mt-4 rounded bg-yellow-500 p-3`}>
4646
<ContentContainer>

resources/scripts/components/server/console/StatBlock.tsx

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,30 @@ export default ({ title, copyOnClick, icon, color, description, className, child
2222

2323
return (
2424
<Tooltip arrow placement={'top'} disabled={!description} content={description || ''}>
25-
<CopyOnClick text={copyOnClick} disabled={!copyOnClick}>
26-
<div className={classNames(styles.stat_block, 'bg-gray-600', className)}>
27-
<div className={classNames(styles.status_bar, color || 'bg-gray-700')} />
28-
<div className={classNames(styles.icon, color || 'bg-gray-700')}>
29-
<Icon
30-
icon={icon}
31-
className={classNames({
32-
'text-gray-100': !color || color === 'bg-gray-700',
33-
'text-gray-50': color && color !== 'bg-gray-700',
34-
})}
35-
/>
36-
</div>
37-
<div className={'flex flex-col justify-center overflow-hidden w-full'}>
38-
<p className={'font-header leading-tight text-xs md:text-sm text-gray-200'}>{title}</p>
25+
<div className={classNames(styles.stat_block, 'bg-gray-600', className)}>
26+
<div className={classNames(styles.status_bar, color || 'bg-gray-700')} />
27+
<div className={classNames(styles.icon, color || 'bg-gray-700')}>
28+
<Icon
29+
icon={icon}
30+
className={classNames({
31+
'text-gray-100': !color || color === 'bg-gray-700',
32+
'text-gray-50': color && color !== 'bg-gray-700',
33+
})}
34+
/>
35+
</div>
36+
<div className={'flex flex-col justify-center overflow-hidden w-full'}>
37+
<p className={'font-header leading-tight text-xs md:text-sm text-gray-200'}>{title}</p>
38+
<CopyOnClick text={copyOnClick}>
3939
<div
4040
ref={ref}
4141
className={'h-[1.75rem] w-full font-semibold text-gray-50 truncate'}
4242
style={{ fontSize }}
4343
>
4444
{children}
4545
</div>
46-
</div>
46+
</CopyOnClick>
4747
</div>
48-
</CopyOnClick>
48+
</div>
4949
</Tooltip>
5050
);
5151
};

resources/scripts/lib/objects.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
* Determines if the value provided to the function is an object type that
33
* is not null.
44
*/
5-
// eslint-disable-next-line @typescript-eslint/ban-types
6-
function isObject(val: unknown): val is {} {
5+
function isObject(val: unknown): val is Record<string, unknown> {
76
return typeof val === 'object' && val !== null && !Array.isArray(val);
87
}
98

0 commit comments

Comments
 (0)