@sevenfold/setto-client 0.43.0 → 0.44.0

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/chrome.d.ts CHANGED
@@ -71,6 +71,8 @@ export interface SettoChromeHandshake {
71
71
  } | null;
72
72
  sitesLoaded: boolean;
73
73
  editMode: boolean;
74
+ /** May edit, whether or not editing now (0.44). The chrome loads the editor for it. */
75
+ canEdit?: boolean;
74
76
  /** A signed-out visitor trying the editor on setto.no. */
75
77
  guestEdit: boolean;
76
78
  authLoading: boolean;
@@ -0,0 +1,12 @@
1
+ import type { Session } from '@supabase/supabase-js';
2
+ /**
3
+ * Whether this session is the site's support account: the member a Setto admin
4
+ * signs in as with «Rediger» in the admin. setto-server makes the account and
5
+ * names its one site in `app_metadata.setto_support_site`, which only the
6
+ * service role can write (`src/lib/support-account.ts` there).
7
+ *
8
+ * Read from the session rather than asked of the server, so the editor is
9
+ * there on the first render. It only opens the editor's furniture; every
10
+ * write is still the server's to allow or refuse.
11
+ */
12
+ export declare function isSupportSession(session: Session | null, siteId: string): boolean;
@@ -20,7 +20,7 @@ export interface SettoContextValue {
20
20
  editMode: boolean;
21
21
  /**
22
22
  * True when this person may edit this site: signed in, a member, the site is
23
- * paid for, and this is not `/setto`. The Setto menu is drawn whenever this
23
+ * paid for (or this is the site's support account), and this is not `/setto`. The Setto menu is drawn whenever this
24
24
  * is; outside `editMode` it shows the site as a visitor sees it.
25
25
  * Absent on a client older than 0.33, where `editMode` meant this.
26
26
  */
@@ -22014,6 +22014,10 @@ function useSiteAccess(supabase, session, siteId) {
22014
22014
  }, [supabase, session, siteId]);
22015
22015
  return state;
22016
22016
  }
22017
+ function isSupportSession(session, siteId) {
22018
+ const site = session?.user?.app_metadata?.setto_support_site;
22019
+ return typeof site === "string" && site === siteId;
22020
+ }
22017
22021
  const CHROME_CONTRACT = 1;
22018
22022
  function chromeUrl(apiUrl) {
22019
22023
  return `${apiUrl.replace(/\/$/, "")}/chrome/v${CHROME_CONTRACT}.js`;
@@ -22081,6 +22085,7 @@ function SettoChrome() {
22081
22085
  currentSite: null,
22082
22086
  sitesLoaded: false,
22083
22087
  editMode: false,
22088
+ canEdit: false,
22084
22089
  guestEdit: false,
22085
22090
  authLoading: true
22086
22091
  }));
@@ -22094,6 +22099,7 @@ function SettoChrome() {
22094
22099
  } : null,
22095
22100
  sitesLoaded: setto.sites !== null,
22096
22101
  editMode: setto.editMode,
22102
+ canEdit: setto.canEdit,
22097
22103
  guestEdit: setto.guestEdit,
22098
22104
  authLoading: setto.authLoading
22099
22105
  });
@@ -37239,7 +37245,7 @@ function SettoProvider({ config, children }) {
37239
37245
  pageStoreRef.current = new PageStore(bundledManifest(config.pages));
37240
37246
  setStoreReady(true);
37241
37247
  }, [i18n, config.theme, config.pages]);
37242
- const canEdit = !!session && access.currentSite?.status === "live" && !onAdminRoute && !authLoading && !access.loading;
37248
+ const canEdit = !!session && (access.currentSite?.status === "live" || !!access.currentSite && isSupportSession(session, config.siteId)) && !onAdminRoute && !authLoading && !access.loading;
37243
37249
  const [editing, setEditingState] = useState(() => readEditing(config.siteId));
37244
37250
  const setEditing = useCallback(
37245
37251
  (on) => {