29 lines
1.8 KiB
TypeScript
29 lines
1.8 KiB
TypeScript
// Real owning Files module with fixture-only authentication; tests intercept every API call.
|
|
import { useLocation } from "react-router";
|
|
import { useState } from "react";
|
|
import FilesPage from "../../../govoplan-files/webui/src/features/files/FilesPage";
|
|
import { generatedTranslations } from "../../../govoplan-files/webui/src/i18n/generatedTranslations";
|
|
import "../../../govoplan-files/webui/src/styles/file-manager.css";
|
|
import { PlatformLanguageProvider } from "../src/i18n/LanguageContext";
|
|
import type { AuthInfo } from "../src/types";
|
|
|
|
const fullAuth: AuthInfo = {
|
|
user: { id: "fixture-user", account_id: "fixture-account", email: "fixture@example.test" },
|
|
tenant: { id: "fixture-tenant", name: "Fixture", slug: "fixture" },
|
|
scopes: ["files:file:read", "files:file:download", "files:file:upload", "files:file:organize", "files:file:delete", "files:file:share", "access:role:read"],
|
|
roles: [], groups: [], profile_loaded: true, roles_loaded: true, groups_loaded: true
|
|
};
|
|
const readOnlyAuth = { ...fullAuth, scopes: ["files:file:read"] };
|
|
const settings = { apiBaseUrl: "", apiKey: "", accessToken: "" };
|
|
|
|
export default function FilesToolbarScenario() {
|
|
const parameters = new URLSearchParams(useLocation().search);
|
|
const [nextSession, setNextSession] = useState(false);
|
|
const auth = parameters.has("read-only") ? readOnlyAuth : fullAuth;
|
|
return <PlatformLanguageProvider preferredLanguageCode={parameters.get("language") ?? "en"} moduleTranslations={[generatedTranslations]}>
|
|
{parameters.has("session-switch") && <button type="button" onClick={() => setNextSession(true)}>Switch fixture session</button>}
|
|
<FilesPage settings={nextSession ? { ...settings, accessToken: "fixture-next-session" } : settings}
|
|
auth={nextSession ? { ...auth, user: { ...auth.user, id: "fixture-next-user" } } : auth} />
|
|
</PlatformLanguageProvider>;
|
|
}
|