mirror of
https://github.com/pterodactyl/panel.git
synced 2026-12-05 13:55:44 -05:00
workbench polish
This commit is contained in:
@@ -18,7 +18,7 @@ return [
|
||||
'enabled' => (bool) env('PTERODACTYL_EXTENSIONS_ENABLED', true),
|
||||
|
||||
'panel_version' => config('app.version') === 'canary' ? '2.0.0-dev' : config('app.version'),
|
||||
'sdk_version' => '2.0.0-beta.4',
|
||||
'sdk_version' => '2.0.0-beta.5',
|
||||
'progress_retention_seconds' => 3600,
|
||||
|
||||
// How long the result of a head tag callback (registerHeadTags) is cached; 0 disables it.
|
||||
|
||||
@@ -21,6 +21,6 @@
|
||||
"views": ["dashboard.serverCard", "server.files.details", "server.files.editor"]
|
||||
},
|
||||
"requires": {
|
||||
"sdk": ">=2.0.0-beta.4 <3.0"
|
||||
"sdk": ">=2.0.0-beta.5 <3.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env node
|
||||
// Theme author tooling: list the panel's views, eject classic's source for one, print a classic skin.
|
||||
import { existsSync, mkdirSync, readdirSync, readFileSync, realpathSync, statSync, writeFileSync } from 'node:fs';
|
||||
import { existsSync, mkdirSync, readFileSync, realpathSync, statSync, writeFileSync } from 'node:fs';
|
||||
import { basename, dirname, extname, relative, resolve, sep } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
@@ -199,15 +199,97 @@ function eject(positional, flags, out) {
|
||||
out(`\nAdd it to your theme entry:\n\n ${importLine}\n\n ${viewsLine}`);
|
||||
}
|
||||
|
||||
/** Classic's skins, one file per primitive under `skins/`, by primitive name. */
|
||||
/** The top-level statements of a module: split on `;` outside brackets, strings and comments. */
|
||||
function statements(source) {
|
||||
const found = [];
|
||||
let depth = 0;
|
||||
let start = 0;
|
||||
|
||||
for (let index = 0; index < source.length; index++) {
|
||||
const char = source[index];
|
||||
|
||||
if (char === '/' && source[index + 1] === '/') {
|
||||
index = source.indexOf('\n', index);
|
||||
if (index === -1) break;
|
||||
} else if (char === '/' && source[index + 1] === '*') {
|
||||
index = source.indexOf('*/', index + 2) + 1;
|
||||
if (index === 0) break;
|
||||
} else if (char === "'" || char === '"' || char === '`') {
|
||||
for (index++; index < source.length && source[index] !== char; index++) {
|
||||
if (source[index] === '\\') index++;
|
||||
}
|
||||
} else if ('([{'.includes(char)) depth++;
|
||||
else if (')]}'.includes(char)) depth--;
|
||||
else if (char === ';' && depth === 0) {
|
||||
found.push(source.slice(start, index + 1).trim());
|
||||
start = index + 1;
|
||||
}
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
/** The constant a statement declares, past any comments before it. */
|
||||
const declared = (statement) =>
|
||||
/^(?:export\s+)?const\s+(\w+)\s*=/.exec(statement.replace(/^(?:\/\/[^\n]*\n\s*|\/\*[\s\S]*?\*\/\s*)*/, ''))?.[1];
|
||||
|
||||
/** A skin's declaration in a classic skins file, after the constants of that file it reads. */
|
||||
function skinSource(file, exportName, primitive) {
|
||||
const all = statements(readFileSync(file, 'utf8'));
|
||||
const byName = new Map(all.flatMap((statement) => (declared(statement) ? [[declared(statement), statement]] : [])));
|
||||
const needed = new Set([exportName]);
|
||||
const queue = [exportName];
|
||||
|
||||
while (queue.length) {
|
||||
const statement = byName.get(queue.shift()) ?? '';
|
||||
|
||||
for (const name of byName.keys()) {
|
||||
if (!needed.has(name) && new RegExp(`\\b${name}\\b`).test(statement.slice(statement.indexOf('=')))) {
|
||||
needed.add(name);
|
||||
queue.push(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!byName.has(exportName)) {
|
||||
throw new CliError(`Classic's skins/${basename(file)} does not declare ${exportName}.`);
|
||||
}
|
||||
|
||||
return [
|
||||
`// Classic's ${primitive} skin (skins/${basename(file)}) from @pterodactyl/sdk ${version}.`,
|
||||
`// Add it to defineTheme({ ui: { ${primitive}: ${exportName} } }) and edit it. Typed as Skin<'${primitive}'>`,
|
||||
"// instead of CompleteSkin, it may leave parts out; those keep classic's recipe.",
|
||||
"import type { CompleteSkin } from '@pterodactyl/sdk/theme';",
|
||||
'',
|
||||
...all.filter((statement) => needed.has(declared(statement))).map((statement) => `${statement}\n`),
|
||||
].join('\n');
|
||||
}
|
||||
|
||||
/** Classic's skin of each primitive, by primitive name, as `skins/index.ts` maps them. */
|
||||
export function classicSkins(root = classicRoot) {
|
||||
const directory = resolve(root, 'skins');
|
||||
const files = existsSync(directory)
|
||||
? readdirSync(directory).filter((file) => /\.tsx?$/.test(file) && !/^index\.|\.spec\./.test(file))
|
||||
: [];
|
||||
const index = resolve(root, 'skins/index.ts');
|
||||
|
||||
if (!existsSync(index)) return new Map();
|
||||
|
||||
const source = readFileSync(index, 'utf8');
|
||||
const imports = new Map();
|
||||
|
||||
for (const [, names, specifier] of source.matchAll(/import\s*\{([^}]*)\}\s*from\s*'(\.{1,2}\/[^']+)'/g)) {
|
||||
for (const binding of names.split(',').map((name) => name.trim()).filter(Boolean)) {
|
||||
const [imported, local = imported] = binding.split(/\s+as\s+/);
|
||||
|
||||
imports.set(local, { file: resolveModule(index, specifier), exportName: imported });
|
||||
}
|
||||
}
|
||||
|
||||
return new Map(
|
||||
files.sort().map((file) => [basename(file, extname(file)), () => readFileSync(resolve(directory, file), 'utf8')])
|
||||
[...source.matchAll(/^\s*([A-Z]\w*):\s*(\w+),?\s*$/gm)]
|
||||
.filter(([, , local]) => imports.has(local))
|
||||
.map(([, primitive, local]) => {
|
||||
const { file, exportName } = imports.get(local);
|
||||
|
||||
return [primitive, () => skinSource(file, exportName, primitive)];
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pterodactyl/sdk",
|
||||
"version": "2.0.0-beta.4",
|
||||
"version": "2.0.0-beta.5",
|
||||
"description": "SDK for building Pterodactyl panel extensions: types for the runtime API and the Vite build preset.",
|
||||
"license": "MIT",
|
||||
"type": "module",
|
||||
|
||||
@@ -5,7 +5,7 @@ import { tmpdir } from 'node:os';
|
||||
import { dirname, resolve } from 'node:path';
|
||||
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
||||
// @ts-expect-error The bin is plain JavaScript without declarations.
|
||||
import { classicSkins, ejectView, rewriteImports, run } from './bin/pterodactyl-theme.mjs';
|
||||
import { classicSkins, ejectView, run } from './bin/pterodactyl-theme.mjs';
|
||||
|
||||
const root = resolve(__dirname, '../..');
|
||||
const bin = resolve(__dirname, 'bin/pterodactyl-theme.mjs');
|
||||
@@ -163,22 +163,72 @@ export default defineTheme({
|
||||
});
|
||||
|
||||
describe('skins', () => {
|
||||
it('lists classic skins and prints one with SDK imports', () => {
|
||||
write('classic/skins/Button.ts', "import { skin } from '@/sdk/theme';\nexport default skin('Button', {});\n");
|
||||
write('classic/skins/index.ts', 'export {};\n');
|
||||
it('lists the primitives classic skins and prints one with the constants it reads', () => {
|
||||
write(
|
||||
'classic/skins/forms.ts',
|
||||
[
|
||||
"import type { CompleteSkin } from '@/sdk/theme';",
|
||||
'',
|
||||
"// Shared by the inputs; a ; in a comment does not end it.",
|
||||
"const control = { base: 'p-3 border', variants: { error: { true: 'border-destructive' } } };",
|
||||
"const unused = 'x';",
|
||||
"export const input = { root: control } satisfies CompleteSkin<'Input'>;",
|
||||
"export const label = { root: 'block; text-sm' } satisfies CompleteSkin<'Label'>;",
|
||||
'',
|
||||
].join('\n')
|
||||
);
|
||||
write(
|
||||
'classic/skins/index.ts',
|
||||
"import type { CompleteSkins } from '@/sdk/theme';\nimport { input, label as fieldLabel } from './forms';\n\nexport const classicSkins = {\n Input: input,\n Label: fieldLabel,\n} satisfies CompleteSkins;\n"
|
||||
);
|
||||
|
||||
const skins: Map<string, () => string> = classicSkins(resolve(directory, 'classic'));
|
||||
const input = skins.get('Input')!();
|
||||
|
||||
expect([...skins.keys()]).toEqual(['Button']);
|
||||
expect(rewriteImports(skins.get('Button')!())).toContain("from '@pterodactyl/sdk/theme'");
|
||||
expect([...skins.keys()]).toEqual(['Input', 'Label']);
|
||||
expect(input).toContain("import type { CompleteSkin } from '@pterodactyl/sdk/theme';");
|
||||
expect(input).toContain("// Shared by the inputs; a ; in a comment does not end it.\nconst control = {");
|
||||
expect(input).toContain("export const input = { root: control } satisfies CompleteSkin<'Input'>;");
|
||||
expect(input).not.toContain('unused');
|
||||
expect(input).not.toContain('export const label');
|
||||
expect(skins.get('Label')!()).toContain("export const label = { root: 'block; text-sm' }");
|
||||
});
|
||||
|
||||
it('explains when classic skins nothing yet', () => {
|
||||
const result = cli('skins');
|
||||
it('prints classic skin of every primitive as code that typechecks against the SDK types', () => {
|
||||
const listed = cli('skins');
|
||||
const primitives = listed.stdout.trim().split('\n');
|
||||
|
||||
expect(result.status).toBe(0);
|
||||
expect(result.stdout.trim()).toMatch(/^(Classic defines no skins yet\.|\w+(\n\w+)*)$/);
|
||||
});
|
||||
expect(listed.status).toBe(0);
|
||||
expect(primitives).toEqual(expect.arrayContaining(['Button', 'Card', 'Dialog', 'Select']));
|
||||
for (const primitive of primitives) {
|
||||
write(`skins/${primitive}.ts`, cli('skins', primitive.toLowerCase()).stdout);
|
||||
}
|
||||
|
||||
expect(cli('skins', 'Buton').stderr).toContain('Classic has no skin for "Buton". It skins Alert, Avatar');
|
||||
|
||||
const program = ts.createProgram(
|
||||
primitives.map((primitive) => resolve(directory, `skins/${primitive}.ts`)),
|
||||
{
|
||||
strict: true,
|
||||
noEmit: true,
|
||||
skipLibCheck: true,
|
||||
target: ts.ScriptTarget.ES2022,
|
||||
module: ts.ModuleKind.ESNext,
|
||||
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
||||
types: [],
|
||||
typeRoots: [resolve(root, 'node_modules/@types')],
|
||||
paths: { '@pterodactyl/sdk/theme': [resolve(__dirname, 'types/theme.d.ts')] },
|
||||
}
|
||||
);
|
||||
|
||||
expect(
|
||||
ts.formatDiagnostics(ts.getPreEmitDiagnostics(program), {
|
||||
getCanonicalFileName: (file) => file,
|
||||
getCurrentDirectory: () => directory,
|
||||
getNewLine: () => '\n',
|
||||
})
|
||||
).toBe('');
|
||||
}, 60_000);
|
||||
});
|
||||
|
||||
it('ships the bin and classic sources in the package', () => {
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
import { useEffect, useRef, useState, type ReactNode } from 'react';
|
||||
import { createPortal } from 'react-dom';
|
||||
import { PortalContainerContext } from '@/components/elements/Portal';
|
||||
import { onThemeChange } from '@/lib/theme';
|
||||
import type { ThemeScheme } from '@/views/theme';
|
||||
import { registerInspectableFrame } from '@/views/inspector/frames';
|
||||
import { isElement } from '@/views/inspector/geometry';
|
||||
|
||||
const FRAME_DOCUMENT =
|
||||
'<!doctype html><html><head><meta charset="utf-8"><style>body{margin:0}#root{display:flow-root}</style></head><body><div id="root"></div></body></html>';
|
||||
'<!doctype html><html><head><meta charset="utf-8"><style>body{margin:0}#root{display:flow-root}</style></head><body><div id="root"></div><div id="overlays"></div></body></html>';
|
||||
const MAX_HEIGHT = 4000;
|
||||
/** The least height of a frame while a dialog is open in it, so the dialog is not cut off. */
|
||||
const DIALOG_HEIGHT = 640;
|
||||
|
||||
const isStylesheet = (node: Element): node is HTMLLinkElement | HTMLStyleElement =>
|
||||
node instanceof HTMLStyleElement || (node instanceof HTMLLinkElement && node.relList.contains('stylesheet'));
|
||||
@@ -75,11 +78,13 @@ export interface PreviewFrameProps {
|
||||
|
||||
/**
|
||||
* Renders its children in a same-origin frame, so media queries see the preset viewport width and the
|
||||
* scheme applies to the preview alone. The children stay in this React tree and keep its context.
|
||||
* scheme applies to the preview alone. The children stay in this React tree and keep its context, and
|
||||
* their dialogs, menus and tooltips portal into the frame too.
|
||||
*/
|
||||
export default function PreviewFrame({ label, width, scale, scheme, children }: PreviewFrameProps) {
|
||||
const [frame, setFrame] = useState<HTMLIFrameElement | null>(null);
|
||||
const [root, setRoot] = useState<HTMLElement | null>(null);
|
||||
const [overlays, setOverlays] = useState<HTMLElement | null>(null);
|
||||
const [height, setHeight] = useState(0);
|
||||
const schemeRef = useRef(scheme);
|
||||
|
||||
@@ -93,8 +98,9 @@ export default function PreviewFrame({ label, width, scale, scheme, children }:
|
||||
const ready = () => {
|
||||
const target = frame.contentDocument;
|
||||
const mount = target?.getElementById('root');
|
||||
const layer = target?.getElementById('overlays');
|
||||
|
||||
if (!target || !mount) {
|
||||
if (!target || !mount || !layer) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -102,7 +108,12 @@ export default function PreviewFrame({ label, width, scale, scheme, children }:
|
||||
|
||||
const clones = new Map<Element, Element>();
|
||||
const sync = () => mirrorDocument(target, schemeRef.current, clones);
|
||||
const measure = () => setHeight(Math.min(Math.ceil(mount.getBoundingClientRect().height), MAX_HEIGHT));
|
||||
const measure = () => {
|
||||
const content = Math.ceil(mount.getBoundingClientRect().height);
|
||||
const dialog = layer.querySelector('[role="dialog"], [role="alertdialog"]') !== null;
|
||||
|
||||
setHeight(Math.min(dialog ? Math.max(content, DIALOG_HEIGHT) : content, MAX_HEIGHT));
|
||||
};
|
||||
const observer = new ResizeObserver(measure);
|
||||
// Resize observations wait for rendering, which a hidden tab skips; mutations do not.
|
||||
const mutations = new MutationObserver(measure);
|
||||
@@ -110,6 +121,7 @@ export default function PreviewFrame({ label, width, scale, scheme, children }:
|
||||
sync();
|
||||
observer.observe(mount);
|
||||
mutations.observe(mount, { childList: true, subtree: true, attributes: true, characterData: true });
|
||||
mutations.observe(layer, { childList: true, subtree: true });
|
||||
target.addEventListener('click', holdNavigation, true);
|
||||
target.addEventListener('submit', holdNavigation, true);
|
||||
|
||||
@@ -126,6 +138,7 @@ export default function PreviewFrame({ label, width, scale, scheme, children }:
|
||||
};
|
||||
|
||||
setRoot(mount);
|
||||
setOverlays(layer);
|
||||
};
|
||||
|
||||
frame.addEventListener('load', ready);
|
||||
@@ -161,7 +174,11 @@ export default function PreviewFrame({ label, width, scale, scheme, children }:
|
||||
transformOrigin: '0 0',
|
||||
}}
|
||||
/>
|
||||
{root && createPortal(children, root)}
|
||||
{root &&
|
||||
createPortal(
|
||||
<PortalContainerContext.Provider value={overlays}>{children}</PortalContainerContext.Provider>,
|
||||
root
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
import { act, cleanup, fireEvent, render, screen, within } from '@testing-library/react';
|
||||
import type { ReactNode } from 'react';
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import PageContentBlock from '@/components/elements/PageContentBlock';
|
||||
import { PortalContainerContext } from '@/components/elements/Portal';
|
||||
import { Dialog } from '@/components/elements/dialog';
|
||||
import { parseWorkbenchSearch } from '@/router/search';
|
||||
import { createExtensionTestHost, type ExtensionTestHost } from '@/sdk/testing';
|
||||
import '@/views/catalog';
|
||||
@@ -176,6 +179,30 @@ describe('preview frames', () => {
|
||||
expect(target.documentElement.className).toBe('dark');
|
||||
settings.remove();
|
||||
});
|
||||
|
||||
it('portal dialogs into the frame and title the frame instead of the workbench', async () => {
|
||||
const frame = document.implementation.createHTMLDocument('frame');
|
||||
const overlays = frame.body.appendChild(frame.createElement('div'));
|
||||
|
||||
document.title = 'Admin · Theme workbench';
|
||||
await act(async () => {
|
||||
render(
|
||||
<PortalContainerContext.Provider value={overlays}>
|
||||
<PageContentBlock title='Servers'>
|
||||
<Dialog open onClose={() => {}} title='Rename server'>
|
||||
Choose a name.
|
||||
</Dialog>
|
||||
</PageContentBlock>
|
||||
</PortalContainerContext.Provider>
|
||||
);
|
||||
});
|
||||
|
||||
// A document without a window, which the DOM matchers cannot read.
|
||||
expect(overlays.querySelector('[role="dialog"]')?.textContent).toContain('Choose a name.');
|
||||
expect(screen.queryByRole('dialog')).toBeNull();
|
||||
expect(frame.title).toBe('Servers');
|
||||
expect(document.title).toBe('Admin · Theme workbench');
|
||||
});
|
||||
});
|
||||
|
||||
describe('view preview', () => {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import React, { useEffect } from 'react';
|
||||
import ContentContainer from '@/components/elements/ContentContainer';
|
||||
import { useOwnerDocument } from '@/components/elements/Portal';
|
||||
import { cn } from '@/lib/cn';
|
||||
|
||||
export interface PageContentBlockProps {
|
||||
@@ -9,9 +10,12 @@ export interface PageContentBlockProps {
|
||||
}
|
||||
|
||||
const PageContentBlock = ({ title, className, children }: PageContentBlockProps) => {
|
||||
// A page previewed in the theme workbench titles its frame, not the workbench.
|
||||
const owner = useOwnerDocument();
|
||||
|
||||
useEffect(() => {
|
||||
document.title = title || document.title;
|
||||
}, [title]);
|
||||
owner.title = title || owner.title;
|
||||
}, [owner, title]);
|
||||
|
||||
return (
|
||||
<div>
|
||||
|
||||
@@ -1,6 +1,21 @@
|
||||
import type React from 'react';
|
||||
import React, { createContext, useContext } from 'react';
|
||||
import { createPortal } from 'react-dom';
|
||||
|
||||
export default function Portal({ children }: { children: React.ReactNode }) {
|
||||
return createPortal(children, document.getElementById('modal-portal')!);
|
||||
/** Where overlays render instead of the page's own portal; a workbench preview sets the body of its frame. */
|
||||
export const PortalContainerContext = createContext<HTMLElement | null>(null);
|
||||
|
||||
/** The element overlays portal into, or undefined for the default (the document body). */
|
||||
export function usePortalContainer(): HTMLElement | undefined {
|
||||
return useContext(PortalContainerContext) ?? undefined;
|
||||
}
|
||||
|
||||
/** The document the content renders into: a preview frame's, or the page's. */
|
||||
export function useOwnerDocument(): Document {
|
||||
return usePortalContainer()?.ownerDocument ?? document;
|
||||
}
|
||||
|
||||
export default function Portal({ children }: { children: React.ReactNode }) {
|
||||
const container = usePortalContainer();
|
||||
|
||||
return createPortal(children, container ?? document.getElementById('modal-portal')!);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import React, { useMemo, useState } from 'react';
|
||||
import { Dialog as BaseDialog } from '@base-ui/react/dialog';
|
||||
import Button from '@/components/elements/Button';
|
||||
import { usePortalContainer } from '@/components/elements/Portal';
|
||||
import { Check, Info, ShieldAlert, TriangleAlert, X } from 'lucide-react';
|
||||
import { useSkin, type SkinBinding } from '@/themes/skins';
|
||||
import { DialogContext } from './context';
|
||||
@@ -41,6 +42,7 @@ export default function DialogComponent({
|
||||
const popupRef = React.useRef<HTMLDivElement>(null);
|
||||
const described = !!description;
|
||||
const ui = useSkin('Dialog', { described });
|
||||
const container = usePortalContainer();
|
||||
|
||||
const initialFocus = (interactionType: string) => {
|
||||
if (interactionType === 'touch') {
|
||||
@@ -73,7 +75,7 @@ export default function DialogComponent({
|
||||
<DialogContext.Provider value={context}>
|
||||
{/* Base UI unmounts the popup after its data-ending-style transition finishes. */}
|
||||
<BaseDialog.Root open={open} onOpenChange={onOpenChange}>
|
||||
<BaseDialog.Portal>
|
||||
<BaseDialog.Portal container={container}>
|
||||
<BaseDialog.Backdrop {...ui('backdrop')} />
|
||||
<div {...ui('viewport')}>
|
||||
<div {...ui('container')}>
|
||||
|
||||
@@ -3,6 +3,7 @@ import { Menu } from '@base-ui/react/menu';
|
||||
import { ContextMenu } from '@base-ui/react/context-menu';
|
||||
import type { LucideIcon } from 'lucide-react';
|
||||
import Icon from '@/components/elements/Icon';
|
||||
import { usePortalContainer } from '@/components/elements/Portal';
|
||||
import { useSkin } from '@/themes/skins';
|
||||
|
||||
type MenuItemComponent = React.ComponentType<React.ComponentProps<typeof Menu.Item>>;
|
||||
@@ -20,6 +21,7 @@ export interface DropdownMenuProps {
|
||||
|
||||
function DropdownMenu({ triggerContent, triggerClassName, openOnHover, children, className }: DropdownMenuProps) {
|
||||
const ui = useSkin('DropdownMenu', { context: false });
|
||||
const container = usePortalContainer();
|
||||
|
||||
return (
|
||||
<Menu.Root>
|
||||
@@ -30,7 +32,7 @@ function DropdownMenu({ triggerContent, triggerClassName, openOnHover, children,
|
||||
>
|
||||
{triggerContent}
|
||||
</Menu.Trigger>
|
||||
<Menu.Portal>
|
||||
<Menu.Portal container={container}>
|
||||
<Menu.Positioner {...ui('positioner')} sideOffset={4} align='end'>
|
||||
<Menu.Popup {...ui('root', className)}>
|
||||
<MenuItemContext.Provider value={Menu.Item as MenuItemComponent}>
|
||||
@@ -53,11 +55,12 @@ export interface ContextDropdownMenuProps {
|
||||
/** Opens `items` at the cursor on right-click or long-press over `children`. */
|
||||
export function ContextDropdownMenu({ className, menuClassName, children, items }: ContextDropdownMenuProps) {
|
||||
const ui = useSkin('DropdownMenu', { context: true });
|
||||
const container = usePortalContainer();
|
||||
|
||||
return (
|
||||
<ContextMenu.Root>
|
||||
<ContextMenu.Trigger {...ui('trigger', className)}>{children}</ContextMenu.Trigger>
|
||||
<ContextMenu.Portal>
|
||||
<ContextMenu.Portal container={container}>
|
||||
<ContextMenu.Positioner {...ui('positioner')}>
|
||||
<ContextMenu.Popup {...ui('root', menuClassName)}>
|
||||
<MenuItemContext.Provider value={ContextMenuItem}>{items}</MenuItemContext.Provider>
|
||||
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
useMergeRefs,
|
||||
useTransitionStyles,
|
||||
} from '@floating-ui/react';
|
||||
import { usePortalContainer } from '@/components/elements/Portal';
|
||||
import { useSkin, type SkinBinding } from '@/themes/skins';
|
||||
|
||||
type Interaction = 'hover' | 'click' | 'focus';
|
||||
@@ -107,12 +108,13 @@ export default function Tooltip({ children, ...props }: TooltipProps) {
|
||||
|
||||
const referenceRef = useMergeRefs([refs.setReference, children.props.ref]);
|
||||
const ui = useSkin('Tooltip', { side: placement.split('-')[0] as Side, arrow: !!props.arrow });
|
||||
const container = usePortalContainer();
|
||||
|
||||
return (
|
||||
<>
|
||||
{cloneElement(children, getReferenceProps({ ...children.props, ref: referenceRef }))}
|
||||
{isMounted && (
|
||||
<FloatingPortal>
|
||||
<FloatingPortal root={container}>
|
||||
<div
|
||||
{...getFloatingProps({
|
||||
ref: refs.setFloating,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import React from 'react';
|
||||
import { Combobox } from '@base-ui/react/combobox';
|
||||
import { Check, ChevronDown } from 'lucide-react';
|
||||
import { usePortalContainer } from '@/components/elements/Portal';
|
||||
import { isNumber, isString } from '@/lib/objects';
|
||||
import { useSkin, type SkinBinding } from '@/themes/skins';
|
||||
|
||||
@@ -174,16 +175,20 @@ const ComboboxPopupContent = ({
|
||||
groupedItems: ComboboxGroupItem[] | undefined;
|
||||
emptyMessage: string;
|
||||
showIndicator: boolean;
|
||||
}) => (
|
||||
<Combobox.Portal>
|
||||
<Combobox.Positioner {...ui('positioner')} sideOffset={4}>
|
||||
<Combobox.Popup {...ui('popup')}>
|
||||
<Combobox.Empty {...ui('empty')}>{emptyMessage}</Combobox.Empty>
|
||||
<ComboboxOptionsList ui={ui} groups={groupedItems} showIndicator={showIndicator} />
|
||||
</Combobox.Popup>
|
||||
</Combobox.Positioner>
|
||||
</Combobox.Portal>
|
||||
);
|
||||
}) => {
|
||||
const container = usePortalContainer();
|
||||
|
||||
return (
|
||||
<Combobox.Portal container={container}>
|
||||
<Combobox.Positioner {...ui('positioner')} sideOffset={4}>
|
||||
<Combobox.Popup {...ui('popup')}>
|
||||
<Combobox.Empty {...ui('empty')}>{emptyMessage}</Combobox.Empty>
|
||||
<ComboboxOptionsList ui={ui} groups={groupedItems} showIndicator={showIndicator} />
|
||||
</Combobox.Popup>
|
||||
</Combobox.Positioner>
|
||||
</Combobox.Portal>
|
||||
);
|
||||
};
|
||||
|
||||
const singleSelectedValues = (value: SelectValue | null | undefined): SelectValue[] =>
|
||||
value === null || value === undefined ? [] : [value];
|
||||
|
||||
@@ -1,26 +1,36 @@
|
||||
import type { ComponentProps, JSXElementConstructor, ReactElement } from 'react';
|
||||
import { Copy, Pencil, Server, Trash2 } from 'lucide-react';
|
||||
import { useState, type ComponentProps, type JSXElementConstructor, type ReactElement } from 'react';
|
||||
import { Archive, Copy, Cpu, Pencil, RefreshCw, Server, Trash2, Upload } from 'lucide-react';
|
||||
import {
|
||||
Alert,
|
||||
Avatar,
|
||||
Badge,
|
||||
Button,
|
||||
Card,
|
||||
Checkbox,
|
||||
Code,
|
||||
ContentBox,
|
||||
CopyOnClick,
|
||||
Dialog,
|
||||
DropdownMenu,
|
||||
DropdownMenuItem,
|
||||
Empty,
|
||||
EmptyContent,
|
||||
EmptyDescription,
|
||||
EmptyHeader,
|
||||
EmptyMedia,
|
||||
EmptyTitle,
|
||||
FileInput,
|
||||
Input,
|
||||
Label,
|
||||
ListRow,
|
||||
NewButton,
|
||||
NumberInput,
|
||||
PageHeading,
|
||||
Pagination,
|
||||
ProgressBar,
|
||||
Select,
|
||||
Spinner,
|
||||
SpinnerOverlay,
|
||||
Switch,
|
||||
Table,
|
||||
TextArea,
|
||||
@@ -37,29 +47,81 @@ export interface UiPrimitive<C extends JSXElementConstructor<never> = JSXElement
|
||||
/** The component of each UI kit primitive by name; a new primitive adds itself here and to `uiPrimitives`. */
|
||||
export interface UiPrimitiveComponents {
|
||||
Button: typeof Button;
|
||||
NewButton: typeof NewButton;
|
||||
Input: typeof Input;
|
||||
TextArea: typeof TextArea;
|
||||
NumberInput: typeof NumberInput;
|
||||
FileInput: typeof FileInput;
|
||||
Select: typeof Select;
|
||||
Checkbox: typeof Checkbox;
|
||||
Switch: typeof Switch;
|
||||
Label: typeof Label;
|
||||
Card: typeof Card;
|
||||
ListRow: typeof ListRow;
|
||||
PageHeading: typeof PageHeading;
|
||||
Badge: typeof Badge;
|
||||
Alert: typeof Alert;
|
||||
ProgressBar: typeof ProgressBar;
|
||||
Dialog: typeof Dialog;
|
||||
Tooltip: typeof Tooltip;
|
||||
DropdownMenu: typeof DropdownMenu;
|
||||
Table: typeof Table;
|
||||
Pagination: typeof Pagination;
|
||||
Empty: typeof Empty;
|
||||
Spinner: typeof Spinner;
|
||||
SpinnerOverlay: typeof SpinnerOverlay;
|
||||
Avatar: typeof Avatar;
|
||||
Code: typeof Code;
|
||||
CopyOnClick: typeof CopyOnClick;
|
||||
ContentBox: typeof ContentBox;
|
||||
TitledGreyBox: typeof TitledGreyBox;
|
||||
CopyOnClick: typeof CopyOnClick;
|
||||
PageHeading: typeof PageHeading;
|
||||
}
|
||||
|
||||
const noop = () => {};
|
||||
|
||||
/** A dialog the gallery can close and reopen; `open` samples start open, so the frame shows them at once. */
|
||||
function DialogSample({
|
||||
open: initiallyOpen,
|
||||
danger,
|
||||
}: {
|
||||
open: boolean;
|
||||
danger?: boolean;
|
||||
}): ReactElement {
|
||||
const [open, setOpen] = useState(initiallyOpen);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Button color={danger ? 'red' : 'primary'} onClick={() => setOpen(true)}>
|
||||
{danger ? 'Delete server' : 'Rename server'}
|
||||
</Button>
|
||||
{danger ? (
|
||||
<Dialog.Confirm
|
||||
open={open}
|
||||
onClose={() => setOpen(false)}
|
||||
title='Delete this server?'
|
||||
confirm='Delete'
|
||||
onConfirmed={() => setOpen(false)}
|
||||
>
|
||||
Survival and its files are removed for good.
|
||||
</Dialog.Confirm>
|
||||
) : (
|
||||
<Dialog
|
||||
open={open}
|
||||
onClose={() => setOpen(false)}
|
||||
title='Rename server'
|
||||
description='The new name shows on the dashboard and in the console.'
|
||||
>
|
||||
<Input defaultValue='Survival' aria-label='Server name' />
|
||||
<Dialog.Footer>
|
||||
<Button.Text onClick={() => setOpen(false)}>Cancel</Button.Text>
|
||||
<Button onClick={() => setOpen(false)}>Save</Button>
|
||||
</Dialog.Footer>
|
||||
</Dialog>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
const rows = [
|
||||
{ id: 'survival', name: 'Survival', memory: '4 GiB' },
|
||||
{ id: 'creative', name: 'Creative', memory: '2 GiB' },
|
||||
@@ -90,17 +152,36 @@ export const uiPrimitives: UiPrimitives = {
|
||||
primary: <Button>Save changes</Button>,
|
||||
secondary: <Button isSecondary>Cancel</Button>,
|
||||
grey: <Button color='grey'>Details</Button>,
|
||||
green: <Button color='green'>Start</Button>,
|
||||
orange: <Button color='orange'>Restart</Button>,
|
||||
danger: <Button color='red'>Delete</Button>,
|
||||
small: <Button size='xsmall'>Small</Button>,
|
||||
secondaryDanger: (
|
||||
<Button color='red' isSecondary>
|
||||
Kill
|
||||
</Button>
|
||||
),
|
||||
text: <Button.Text>Restart</Button.Text>,
|
||||
xsmall: <Button size='xsmall'>Extra small</Button>,
|
||||
small: <Button size='small'>Small</Button>,
|
||||
large: <Button size='large'>Large</Button>,
|
||||
xlarge: <Button size='xlarge'>Full width</Button>,
|
||||
loading: <Button isLoading>Saving</Button>,
|
||||
disabled: <Button disabled>Unavailable</Button>,
|
||||
},
|
||||
},
|
||||
NewButton: {
|
||||
component: NewButton,
|
||||
samples: {
|
||||
default: <NewButton>New database</NewButton>,
|
||||
icon: <NewButton icon={Upload}>Upload</NewButton>,
|
||||
},
|
||||
},
|
||||
Input: {
|
||||
component: Input,
|
||||
samples: {
|
||||
default: <Input placeholder='Server name' />,
|
||||
filled: <Input defaultValue='Survival' />,
|
||||
light: <Input $isLight defaultValue='On a card' />,
|
||||
error: <Input $hasError defaultValue='?' aria-invalid />,
|
||||
disabled: <Input disabled defaultValue='Locked' />,
|
||||
},
|
||||
@@ -119,6 +200,13 @@ export const uiPrimitives: UiPrimitives = {
|
||||
disabled: <NumberInput value={0} onValueChange={noop} disabled aria-label='Swap' />,
|
||||
},
|
||||
},
|
||||
FileInput: {
|
||||
component: FileInput,
|
||||
samples: {
|
||||
default: <FileInput aria-label='Server icon' />,
|
||||
disabled: <FileInput disabled aria-label='Server icon' />,
|
||||
},
|
||||
},
|
||||
Select: {
|
||||
component: Select,
|
||||
samples: {
|
||||
@@ -152,7 +240,89 @@ export const uiPrimitives: UiPrimitives = {
|
||||
disabled: <Switch checked={false} disabled onChange={noop} label='Unavailable' />,
|
||||
},
|
||||
},
|
||||
Label: { component: Label, samples: { default: <Label>Server name</Label> } },
|
||||
Label: {
|
||||
component: Label,
|
||||
samples: { default: <Label>Server name</Label>, light: <Label isLight>Server name</Label> },
|
||||
},
|
||||
Card: {
|
||||
component: Card,
|
||||
samples: {
|
||||
plain: <Card>Memory, disk and CPU limits.</Card>,
|
||||
titled: <Card title='Resources'>Memory, disk and CPU limits.</Card>,
|
||||
icon: (
|
||||
<Card title='CPU' icon={Cpu}>
|
||||
37.52% of 100%
|
||||
</Card>
|
||||
),
|
||||
actions: (
|
||||
<Card
|
||||
title='Backups'
|
||||
actions={
|
||||
<Button size='xsmall' color='grey'>
|
||||
Refresh
|
||||
</Button>
|
||||
}
|
||||
>
|
||||
2 of 5 backups used.
|
||||
</Card>
|
||||
),
|
||||
loading: (
|
||||
<Card title='Resources' loading>
|
||||
Memory, disk and CPU limits.
|
||||
</Card>
|
||||
),
|
||||
},
|
||||
},
|
||||
ListRow: {
|
||||
component: ListRow,
|
||||
samples: {
|
||||
default: <ListRow>Survival · 203.0.113.10:25565</ListRow>,
|
||||
interactive: (
|
||||
<ListRow interactive onClick={noop}>
|
||||
Creative · 203.0.113.10:25566
|
||||
</ListRow>
|
||||
),
|
||||
link: <ListRow destination={{ to: '/' }}>Dashboard</ListRow>,
|
||||
list: (
|
||||
<ul className='space-y-2'>
|
||||
<ListRow as='li'>world</ListRow>
|
||||
<ListRow as='li'>world_nether</ListRow>
|
||||
</ul>
|
||||
),
|
||||
},
|
||||
},
|
||||
PageHeading: {
|
||||
component: PageHeading,
|
||||
samples: {
|
||||
default: <PageHeading title='Servers' description='Every server you own or are invited to.' />,
|
||||
actions: <PageHeading title='Backups' actions={<Button>Create backup</Button>} />,
|
||||
},
|
||||
},
|
||||
Badge: {
|
||||
component: Badge,
|
||||
samples: {
|
||||
neutral: <Badge>Installing</Badge>,
|
||||
success: <Badge tone='success'>Running</Badge>,
|
||||
warning: <Badge tone='warning'>Starting</Badge>,
|
||||
danger: <Badge tone='danger'>Suspended</Badge>,
|
||||
info: <Badge tone='info'>Update</Badge>,
|
||||
accent: <Badge tone='accent'>New</Badge>,
|
||||
soft: (
|
||||
<span className='flex flex-wrap gap-2'>
|
||||
{(['neutral', 'success', 'warning', 'danger', 'info', 'accent'] as const).map((tone) => (
|
||||
<Badge key={tone} tone={tone} variant='soft'>
|
||||
{tone}
|
||||
</Badge>
|
||||
))}
|
||||
</span>
|
||||
),
|
||||
small: (
|
||||
<Badge tone='accent' size='sm'>
|
||||
Beta
|
||||
</Badge>
|
||||
),
|
||||
},
|
||||
},
|
||||
Alert: {
|
||||
component: Alert,
|
||||
samples: {
|
||||
@@ -163,7 +333,30 @@ export const uiPrimitives: UiPrimitives = {
|
||||
</Alert>
|
||||
),
|
||||
warning: <Alert type='warning'>This server is near its disk limit.</Alert>,
|
||||
danger: <Alert type='danger'>The node is unreachable.</Alert>,
|
||||
danger: (
|
||||
<Alert type='danger' title='Node offline'>
|
||||
The node is unreachable.
|
||||
</Alert>
|
||||
),
|
||||
},
|
||||
},
|
||||
ProgressBar: {
|
||||
component: ProgressBar,
|
||||
samples: {
|
||||
neutral: <ProgressBar value={40} label='Disk' />,
|
||||
success: <ProgressBar value={25} tone='success' label='Memory' />,
|
||||
warning: <ProgressBar value={85} tone='warning' label='Disk' />,
|
||||
danger: <ProgressBar value={96} tone='danger' label='CPU' />,
|
||||
accent: <ProgressBar value={60} tone='accent' label='Upload' />,
|
||||
empty: <ProgressBar value={null} label='Unlimited' />,
|
||||
page: <ProgressBar value={70} variant='page' />,
|
||||
},
|
||||
},
|
||||
Dialog: {
|
||||
component: Dialog,
|
||||
samples: {
|
||||
open: <DialogSample open />,
|
||||
confirm: <DialogSample open={false} danger />,
|
||||
},
|
||||
},
|
||||
Tooltip: {
|
||||
@@ -188,6 +381,19 @@ export const uiPrimitives: UiPrimitives = {
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenu>
|
||||
),
|
||||
described: (
|
||||
<DropdownMenu triggerContent='Backup'>
|
||||
<DropdownMenuItem icon={RefreshCw} description='Replaces the files on the server.'>
|
||||
Restore
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem icon={Archive} description='Keeps it through rotation.'>
|
||||
Lock
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem icon={Trash2} danger description='This cannot be undone.'>
|
||||
Delete
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenu>
|
||||
),
|
||||
},
|
||||
},
|
||||
Table: {
|
||||
@@ -226,6 +432,24 @@ export const uiPrimitives: UiPrimitives = {
|
||||
</EmptyHeader>
|
||||
</Empty>
|
||||
),
|
||||
content: (
|
||||
<Empty className='border'>
|
||||
<EmptyHeader>
|
||||
<EmptyTitle>No databases</EmptyTitle>
|
||||
<EmptyDescription>This server has none yet.</EmptyDescription>
|
||||
</EmptyHeader>
|
||||
<EmptyContent>
|
||||
<NewButton>New database</NewButton>
|
||||
</EmptyContent>
|
||||
</Empty>
|
||||
),
|
||||
compact: (
|
||||
<Empty size='compact' className='border'>
|
||||
<EmptyHeader>
|
||||
<EmptyTitle>No backups</EmptyTitle>
|
||||
</EmptyHeader>
|
||||
</Empty>
|
||||
),
|
||||
},
|
||||
},
|
||||
Spinner: {
|
||||
@@ -234,6 +458,18 @@ export const uiPrimitives: UiPrimitives = {
|
||||
base: <Spinner />,
|
||||
small: <Spinner size='small' />,
|
||||
large: <Spinner size='large' />,
|
||||
blue: <Spinner isBlue />,
|
||||
centered: <Spinner centered />,
|
||||
},
|
||||
},
|
||||
SpinnerOverlay: {
|
||||
component: SpinnerOverlay,
|
||||
samples: {
|
||||
default: (
|
||||
<div className='relative h-32 rounded-sm border border-border'>
|
||||
<SpinnerOverlay visible>Saving</SpinnerOverlay>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
},
|
||||
Avatar: {
|
||||
@@ -241,6 +477,15 @@ export const uiPrimitives: UiPrimitives = {
|
||||
samples: {
|
||||
default: <Avatar name='11111111-1111-4111-8111-111111111111' size={40} />,
|
||||
square: <Avatar name='22222222-2222-4222-8222-222222222222' size={40} square />,
|
||||
marble: <Avatar name='33333333-3333-4333-8333-333333333333' size={40} variant='marble' />,
|
||||
pixel: <Avatar name='44444444-4444-4444-8444-444444444444' size={40} variant='pixel' />,
|
||||
},
|
||||
},
|
||||
Code: {
|
||||
component: Code,
|
||||
samples: {
|
||||
default: <Code>server.properties</Code>,
|
||||
dark: <Code dark>java -Xms128M -jar server.jar</Code>,
|
||||
},
|
||||
},
|
||||
ContentBox: {
|
||||
@@ -270,13 +515,6 @@ export const uiPrimitives: UiPrimitives = {
|
||||
),
|
||||
},
|
||||
},
|
||||
PageHeading: {
|
||||
component: PageHeading,
|
||||
samples: {
|
||||
default: <PageHeading title='Servers' description='Every server you own or are invited to.' />,
|
||||
actions: <PageHeading title='Backups' actions={<Button>Create backup</Button>} />,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export type UiPrimitiveName = keyof UiPrimitiveComponents;
|
||||
|
||||
@@ -11,8 +11,33 @@ const inspection: ViewInspection = { wrap: true };
|
||||
export const isInspectorShortcut = (event: KeyboardEvent): boolean =>
|
||||
event.altKey && event.shiftKey && !event.ctrlKey && !event.metaKey && event.code === 'KeyI';
|
||||
|
||||
/** Keeps the inspector on across reloads of this tab, such as the reloads `p:extension:dev --watch` triggers. */
|
||||
export const INSPECTOR_STORAGE_KEY = 'pterodactyl:inspector';
|
||||
|
||||
function storedInspector(): boolean {
|
||||
try {
|
||||
return sessionStorage.getItem(INSPECTOR_STORAGE_KEY) === 'on';
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function storeInspector(on: boolean): void {
|
||||
try {
|
||||
if (on) {
|
||||
sessionStorage.setItem(INSPECTOR_STORAGE_KEY, 'on');
|
||||
} else {
|
||||
sessionStorage.removeItem(INSPECTOR_STORAGE_KEY);
|
||||
}
|
||||
} catch {
|
||||
// Storage can be unavailable; the inspector then starts off on the next load.
|
||||
}
|
||||
}
|
||||
|
||||
function InspectorRoot({ children }: { children?: ReactNode }) {
|
||||
const [on, setOn] = useState(false);
|
||||
const [on, setOn] = useState(storedInspector);
|
||||
|
||||
useEffect(() => storeInspector(on), [on]);
|
||||
|
||||
useEffect(() => {
|
||||
const onKey = (event: KeyboardEvent) => {
|
||||
|
||||
@@ -65,6 +65,7 @@ afterEach(() => {
|
||||
cleanup();
|
||||
vi.restoreAllMocks();
|
||||
open.mockReset();
|
||||
sessionStorage.clear();
|
||||
Object.assign(window, { SiteConfiguration: undefined });
|
||||
});
|
||||
|
||||
@@ -108,6 +109,24 @@ describe('ViewInspector', () => {
|
||||
expect(screen.queryByText(/Inspecting views/)).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('stays on across reloads of the tab until turned off', async () => {
|
||||
page();
|
||||
await toggle();
|
||||
await screen.findByText(/Inspecting views/);
|
||||
cleanup();
|
||||
|
||||
const { container } = page();
|
||||
|
||||
expect(await screen.findByText(/Inspecting views/)).toBeInTheDocument();
|
||||
expect(container.querySelector('[data-view]')).not.toBeNull();
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Inspect views' }));
|
||||
cleanup();
|
||||
page();
|
||||
|
||||
expect(screen.getByRole('button', { name: 'Inspect views' })).toHaveAttribute('aria-pressed', 'false');
|
||||
});
|
||||
|
||||
it('outlines the view under the pointer and pins it on click instead of clicking the page', async () => {
|
||||
page();
|
||||
await toggle();
|
||||
|
||||
@@ -37,7 +37,7 @@ afterEach(function (): void {
|
||||
* @param array<string, mixed> $theme
|
||||
* @param array<string, mixed> $build
|
||||
*/
|
||||
function installTheme(string $id, array $theme = [], array $build = ['core' => CORE, 'sdk' => '2.0.0-beta.4']): void
|
||||
function installTheme(string $id, array $theme = [], array $build = ['core' => CORE, 'sdk' => '2.0.0-beta.5']): void
|
||||
{
|
||||
(function () use ($id, $theme, $build): void {
|
||||
$directory = $this->baseDirectory.'/extensions/'.$id;
|
||||
@@ -136,7 +136,7 @@ test('a theme stylesheet built against other core classes is laid over the panel
|
||||
expect(mb_strpos($html, 'stylesheet.test.css'))->toBeLessThan(mb_strpos($html, '/assets/extensions/aurora/theme.css'));
|
||||
expect(themePayload($this->get('/auth/login'))['stylesheetFallback'])->toBeTrue();
|
||||
})->with([
|
||||
'another hash' => [['core' => 'another0000hash0', 'sdk' => '2.0.0-beta.4']],
|
||||
'another hash' => [['core' => 'another0000hash0', 'sdk' => '2.0.0-beta.5']],
|
||||
'no build info' => [[]],
|
||||
]);
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ function themePackage(string $id, array $theme = [], array $files = [], array $m
|
||||
'theme' => ['stylesheet' => 'dist/theme.css', ...$theme],
|
||||
...$manifest,
|
||||
], JSON_THROW_ON_ERROR));
|
||||
foreach (['theme.css' => ':root{--accent:red}', 'theme.json' => '{"core":"f1x7ure0c0re0000","sdk":"2.0.0-beta.4"}', ...$files] as $name => $contents) {
|
||||
foreach (['theme.css' => ':root{--accent:red}', 'theme.json' => '{"core":"f1x7ure0c0re0000","sdk":"2.0.0-beta.5"}', ...$files] as $name => $contents) {
|
||||
File::put($path.'/dist/'.$name, $contents);
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ test('doctor and enable refuse theme builds that load remote files, outgrow thei
|
||||
]);
|
||||
|
||||
test('doctor warns when a theme stylesheet was built against other core classes', function (): void {
|
||||
$path = themePackage('aurora', files: ['theme.json' => '{"core":"0ther0000000hash","sdk":"2.0.0-beta.4"}']);
|
||||
$path = themePackage('aurora', files: ['theme.json' => '{"core":"0ther0000000hash","sdk":"2.0.0-beta.5"}']);
|
||||
|
||||
$this->artisan('p:extension:doctor', ['path' => $path])
|
||||
->expectsOutputToContain('built against core classes "0ther0000000hash", but this panel has "f1x7ure0c0re0000"')
|
||||
|
||||
Reference in New Issue
Block a user