fix(webui): show all channels when only WebUI is enabled
This commit is contained in:
1 parent
ea9d13cbeb
commit
78cdf53ac3
2 files changed
+27
-3
No files matched your search
@@ -49,13 +49,14 @@ export function ChannelsSettings({
|
||||
.filter((feature) => feature.type === "channel" && feature.settings_visible !== false)
|
||||
.sort((left, right) => Number(!left.ready) - Number(!right.ready)
|
||||
|| localizedChannelDisplayName(left, t).localeCompare(localizedChannelDisplayName(right, t)));
|
||||
const hasEnabledChannels = channels.some((feature) => feature.enabled);
|
||||
const hasEnabledConfigurableChannels = channels.some((feature) =>
|
||||
feature.enabled && !feature.capabilities?.includes("always_enabled"));
|
||||
const restartRequired = requiresRestartPending || Boolean(nanobotFeatures?.requires_restart);
|
||||
useLayoutEffect(() => {
|
||||
if (!nanobotFeatures || filterInitializedRef.current) return;
|
||||
filterInitializedRef.current = true;
|
||||
setFilter(hasEnabledChannels ? "enabled" : "all");
|
||||
}, [hasEnabledChannels, nanobotFeatures]);
|
||||
setFilter(hasEnabledConfigurableChannels ? "enabled" : "all");
|
||||
}, [hasEnabledConfigurableChannels, nanobotFeatures]);
|
||||
const visibleChannels = channels.filter((feature) =>
|
||||
(filter === "all" || feature.enabled)
|
||||
&& `${feature.name} ${localizedChannelDisplayName(feature, t)}`.toLocaleLowerCase()
|
||||
|
||||
@@ -369,6 +369,29 @@ describe("Settings channels", () => {
|
||||
expect(screen.getByRole("button", { name: "All" })).toHaveAttribute("aria-pressed", "true");
|
||||
});
|
||||
|
||||
it("shows all channels by default when only the always-enabled WebUI is enabled", async () => {
|
||||
const websocket = {
|
||||
...catalogFeature("websocket", true),
|
||||
display_name: "nanobot WebUI",
|
||||
capabilities: ["always_enabled"],
|
||||
};
|
||||
const disabled = catalogFeature("Disabled channel", false);
|
||||
vi.stubGlobal("fetch", vi.fn(async (input: RequestInfo | URL) => {
|
||||
const url = String(input);
|
||||
if (url === "/api/settings") return jsonResponse(settingsPayload());
|
||||
if (url === "/api/settings/nanobot-features") {
|
||||
return jsonResponse({ features: [websocket, disabled], enabled_count: 1 });
|
||||
}
|
||||
return jsonResponse({});
|
||||
}));
|
||||
|
||||
renderSettingsView({ initialSection: "channels" });
|
||||
|
||||
expect(await screen.findByText("nanobot WebUI")).toBeInTheDocument();
|
||||
expect(screen.getByRole("button", { name: "View Disabled channel settings" })).toBeInTheDocument();
|
||||
expect(screen.getByRole("button", { name: "All" })).toHaveAttribute("aria-pressed", "true");
|
||||
});
|
||||
|
||||
it("requires a restart before enabling newly installed channel support", async () => {
|
||||
const whatsappFeature = {
|
||||
name: "whatsapp",
|
||||
|
||||
Reference in new issue
Block a user