Limit Run target platforms to plugin declarations
This commit is contained in:
@@ -6,7 +6,7 @@ import { MaintenancePage } from "./MaintenancePage";
|
|||||||
import { PluginsPage } from "./PluginsPage";
|
import { PluginsPage } from "./PluginsPage";
|
||||||
import { ProfileSettingsPage } from "./ProfileSettingsPage";
|
import { ProfileSettingsPage } from "./ProfileSettingsPage";
|
||||||
import { ServerDetailPage } from "./ServerDetailPage";
|
import { ServerDetailPage } from "./ServerDetailPage";
|
||||||
import { ServersPage } from "./ServersPage";
|
import { runPlatformOptions, ServersPage } from "./ServersPage";
|
||||||
import { UsersPage } from "./UsersPage";
|
import { UsersPage } from "./UsersPage";
|
||||||
import runtimeTaskProgressSource from "../components/RuntimeTaskProgress.tsx?raw";
|
import runtimeTaskProgressSource from "../components/RuntimeTaskProgress.tsx?raw";
|
||||||
import serverDeploymentWorkflowSource from "../components/ServerDeploymentWorkflow.tsx?raw";
|
import serverDeploymentWorkflowSource from "../components/ServerDeploymentWorkflow.tsx?raw";
|
||||||
@@ -17,7 +17,7 @@ import serverDetailPageSource from "./ServerDetailPage.tsx?raw";
|
|||||||
import type { PageComponentProps } from "../contracts/page";
|
import type { PageComponentProps } from "../contracts/page";
|
||||||
import { capabilitiesForRoles, type CurrentUserView } from "../contracts/workspace";
|
import { capabilitiesForRoles, type CurrentUserView } from "../contracts/workspace";
|
||||||
import type { OperationTracker } from "../stores/operations";
|
import type { OperationTracker } from "../stores/operations";
|
||||||
import type { UserResponse } from "../api/types";
|
import type { GamePluginResponse, UserResponse } from "../api/types";
|
||||||
|
|
||||||
const adminUser: CurrentUserView = {
|
const adminUser: CurrentUserView = {
|
||||||
id: "user-admin",
|
id: "user-admin",
|
||||||
@@ -62,6 +62,13 @@ function pageProps(params: PageComponentProps["params"] = {}): PageComponentProp
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe("first-party console pages", () => {
|
describe("first-party console pages", () => {
|
||||||
|
it("only offers plugin-declared run platforms", () => {
|
||||||
|
const plugin = { supportedOs: ["windows", "linux"] } as GamePluginResponse;
|
||||||
|
|
||||||
|
expect(runPlatformOptions(plugin, "darwin")).toEqual(["windows", "linux"]);
|
||||||
|
expect(runPlatformOptions(undefined, "windows")).toEqual(["windows"]);
|
||||||
|
});
|
||||||
|
|
||||||
it("renders the platform overview with first-screen health modules", () => {
|
it("renders the platform overview with first-screen health modules", () => {
|
||||||
const html = renderToStaticMarkup(<HomePage {...pageProps()} />);
|
const html = renderToStaticMarkup(<HomePage {...pageProps()} />);
|
||||||
|
|
||||||
|
|||||||
@@ -981,7 +981,7 @@ function quickRuntimeDefaultsForPlugin(pluginId: string) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function runPlatformOptions(plugin: GamePluginResponse | undefined, fallback: string): string[] {
|
export function runPlatformOptions(plugin: GamePluginResponse | undefined, fallback: string): string[] {
|
||||||
const options = new Set<string>();
|
const options = new Set<string>();
|
||||||
const add = (value: string | undefined) => {
|
const add = (value: string | undefined) => {
|
||||||
const normalized = value?.trim().toLowerCase();
|
const normalized = value?.trim().toLowerCase();
|
||||||
@@ -989,10 +989,13 @@ function runPlatformOptions(plugin: GamePluginResponse | undefined, fallback: st
|
|||||||
options.add(normalized);
|
options.add(normalized);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
add(fallback);
|
|
||||||
plugin?.supportedOs?.forEach(add);
|
plugin?.supportedOs?.forEach(add);
|
||||||
|
if (options.size === 0) {
|
||||||
plugin?.runtimeProfiles?.lifecycleProfiles?.forEach((profile) => profile.platforms?.forEach(add));
|
plugin?.runtimeProfiles?.lifecycleProfiles?.forEach((profile) => profile.platforms?.forEach(add));
|
||||||
["linux", "windows", "darwin"].forEach(add);
|
}
|
||||||
|
if (options.size === 0) {
|
||||||
|
add(fallback);
|
||||||
|
}
|
||||||
return [...options];
|
return [...options];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user