@sevenfold/setto-client 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin/App.d.ts +4 -5
- package/dist/lib/urls.d.ts +6 -0
- package/dist/setto-client.js +52 -4
- package/dist/setto-client.js.map +1 -1
- package/package.json +1 -1
package/dist/admin/App.d.ts
CHANGED
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
* Drop-in admin SPA. Mount under a route like `<Route path="/admin/*" .../>`.
|
|
3
3
|
*
|
|
4
4
|
* Behaviour after login:
|
|
5
|
-
* -
|
|
6
|
-
* -
|
|
7
|
-
*
|
|
5
|
+
* - Redirects to `/?setto=edit` on the site home (edit mode active).
|
|
6
|
+
* - Shows the dashboard only when the user lacks access to this site, or on
|
|
7
|
+
* `/admin?deployment=…` for publish progress / history.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
* Editing happens on the public site at `/?setto=edit` via "Begynn å redigere".
|
|
9
|
+
* Editing happens on the public site at `/?setto=edit`.
|
|
11
10
|
*/
|
|
12
11
|
export declare function SettoAdminApp(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Site home with inline edit mode active. */
|
|
2
|
+
export declare function editModeUrl(pathname?: string): string;
|
|
3
|
+
export declare function isAdminRoute(): boolean;
|
|
4
|
+
/** Admin deployment progress panel (`/admin?deployment=…`). */
|
|
5
|
+
export declare function isAdminDeploymentView(): boolean;
|
|
6
|
+
export declare function adminRedirectUrl(): string;
|
package/dist/setto-client.js
CHANGED
|
@@ -22643,6 +22643,19 @@ const SettoBlock = forwardRef(
|
|
|
22643
22643
|
);
|
|
22644
22644
|
}
|
|
22645
22645
|
);
|
|
22646
|
+
function editModeUrl(pathname = "/") {
|
|
22647
|
+
const u = new URL(window.location.href);
|
|
22648
|
+
u.pathname = pathname;
|
|
22649
|
+
u.search = "";
|
|
22650
|
+
u.searchParams.set("setto", "edit");
|
|
22651
|
+
return u.toString();
|
|
22652
|
+
}
|
|
22653
|
+
function isAdminRoute() {
|
|
22654
|
+
return window.location.pathname.startsWith("/admin");
|
|
22655
|
+
}
|
|
22656
|
+
function isAdminDeploymentView() {
|
|
22657
|
+
return isAdminRoute() && new URLSearchParams(window.location.search).has("deployment");
|
|
22658
|
+
}
|
|
22646
22659
|
function adminRedirectUrl() {
|
|
22647
22660
|
return `${window.location.origin}/admin`;
|
|
22648
22661
|
}
|
|
@@ -22731,6 +22744,11 @@ function AuthGate({ children }) {
|
|
|
22731
22744
|
const { error: updateError } = await supabase.auth.updateUser({ password });
|
|
22732
22745
|
if (updateError) throw updateError;
|
|
22733
22746
|
clearAuthHashFromUrl();
|
|
22747
|
+
const { data: sessionData } = await supabase.auth.getSession();
|
|
22748
|
+
if (sessionData.session) {
|
|
22749
|
+
window.location.replace(editModeUrl());
|
|
22750
|
+
return;
|
|
22751
|
+
}
|
|
22734
22752
|
setMode("signin");
|
|
22735
22753
|
setPassword("");
|
|
22736
22754
|
setConfirmPassword("");
|
|
@@ -22921,6 +22939,15 @@ function SiteList() {
|
|
|
22921
22939
|
const { supabase, session, config } = useSetto();
|
|
22922
22940
|
const [sites, setSites] = useState(null);
|
|
22923
22941
|
const [error, setError] = useState(null);
|
|
22942
|
+
const redirectAfterSignIn = useRef(false);
|
|
22943
|
+
useEffect(() => {
|
|
22944
|
+
const { data: sub } = supabase.auth.onAuthStateChange((event) => {
|
|
22945
|
+
if (event === "SIGNED_IN" && !isAdminDeploymentView()) {
|
|
22946
|
+
redirectAfterSignIn.current = true;
|
|
22947
|
+
}
|
|
22948
|
+
});
|
|
22949
|
+
return () => sub.subscription.unsubscribe();
|
|
22950
|
+
}, [supabase]);
|
|
22924
22951
|
useEffect(() => {
|
|
22925
22952
|
if (!session) return;
|
|
22926
22953
|
let cancelled = false;
|
|
@@ -22941,6 +22968,20 @@ function SiteList() {
|
|
|
22941
22968
|
() => sites?.find((s) => s.id === config.siteId) ?? null,
|
|
22942
22969
|
[sites, config.siteId]
|
|
22943
22970
|
);
|
|
22971
|
+
useEffect(() => {
|
|
22972
|
+
if (!redirectAfterSignIn.current || !session || sites === null || isAdminDeploymentView()) {
|
|
22973
|
+
return;
|
|
22974
|
+
}
|
|
22975
|
+
if (currentSite) {
|
|
22976
|
+
redirectAfterSignIn.current = false;
|
|
22977
|
+
window.location.replace(editModeUrl());
|
|
22978
|
+
return;
|
|
22979
|
+
}
|
|
22980
|
+
redirectAfterSignIn.current = false;
|
|
22981
|
+
}, [session, sites, currentSite]);
|
|
22982
|
+
if (redirectAfterSignIn.current && session && (sites === null || currentSite)) {
|
|
22983
|
+
return /* @__PURE__ */ jsx("div", { style: loadingRedirectStyle, children: "Åpner redigering …" });
|
|
22984
|
+
}
|
|
22944
22985
|
return /* @__PURE__ */ jsxs("div", { style: shellStyle, children: [
|
|
22945
22986
|
/* @__PURE__ */ jsxs("header", { style: headerStyle, children: [
|
|
22946
22987
|
/* @__PURE__ */ jsx("h1", { style: { margin: 0, fontSize: 22 }, children: "Setto" }),
|
|
@@ -23115,11 +23156,18 @@ function SignOutButton() {
|
|
|
23115
23156
|
return /* @__PURE__ */ jsx("button", { onClick: () => supabase.auth.signOut(), style: signOutBtnStyle, children: "Logg ut" });
|
|
23116
23157
|
}
|
|
23117
23158
|
function editUrl() {
|
|
23118
|
-
|
|
23119
|
-
u.pathname = "/";
|
|
23120
|
-
u.searchParams.set("setto", "edit");
|
|
23121
|
-
return u.toString();
|
|
23159
|
+
return editModeUrl("/");
|
|
23122
23160
|
}
|
|
23161
|
+
const loadingRedirectStyle = {
|
|
23162
|
+
minHeight: "100dvh",
|
|
23163
|
+
display: "flex",
|
|
23164
|
+
alignItems: "center",
|
|
23165
|
+
justifyContent: "center",
|
|
23166
|
+
background: "#0a0a0d",
|
|
23167
|
+
color: "#888",
|
|
23168
|
+
fontSize: 14,
|
|
23169
|
+
fontFamily: 'system-ui, -apple-system, "Segoe UI", sans-serif'
|
|
23170
|
+
};
|
|
23123
23171
|
const shellStyle = {
|
|
23124
23172
|
minHeight: "100dvh",
|
|
23125
23173
|
background: "#0a0a0d",
|