@griddo/ax 11.16.0-rc.0 → 11.16.0-rc.2

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@griddo/ax",
3
3
  "description": "Griddo Author Experience",
4
- "version": "11.16.0-rc.0",
4
+ "version": "11.16.0-rc.2",
5
5
  "authors": [
6
6
  "Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
7
7
  "Diego M. Béjar <diego.bejar@secuoyas.com>",
@@ -219,5 +219,5 @@
219
219
  "publishConfig": {
220
220
  "access": "public"
221
221
  },
222
- "gitHead": "27760c45b462bc1ce08230d4a3790b1002b073a0"
222
+ "gitHead": "7c8f537bfce679622c5430c4e016627e26e2297b"
223
223
  }
@@ -27,6 +27,7 @@ const PageFinder = (props: IPageFinderProps): JSX.Element => {
27
27
  fromPageOnly = true,
28
28
  defaultLang,
29
29
  disableTranslations = false,
30
+ onlyLocal,
30
31
  } = props;
31
32
 
32
33
  const langOptions = globalLangs.map((lang) => ({ label: lang.label, value: lang.id.toString() }));
@@ -152,9 +153,13 @@ const PageFinder = (props: IPageFinderProps): JSX.Element => {
152
153
  const { site, lang } = state;
153
154
  const { data }: { data: { items: IContentType[] } } = await structuredData.getData(null, site, lang);
154
155
  let contentTypes = data.items
155
- ? data.items.map((type) => ({ label: type.title, value: type.id, fromPage: type.fromPage }))
156
+ ? data.items.map((type) => ({ label: type.title, value: type.id, fromPage: type.fromPage, local: type.local }))
156
157
  : [];
157
158
 
159
+ if (onlyLocal) {
160
+ contentTypes = contentTypes.filter((type) => type.local === true);
161
+ }
162
+
158
163
  if (fromPageOnly) {
159
164
  contentTypes = contentTypes.filter((type) => type.fromPage === true);
160
165
  }
@@ -334,6 +339,7 @@ interface IPageFinderProps {
334
339
  fromPageOnly?: boolean;
335
340
  defaultLang?: number;
336
341
  disableTranslations?: boolean;
342
+ onlyLocal?: boolean;
337
343
  }
338
344
 
339
345
  const mapStateToProps = (state: IRootState) => ({
@@ -1662,7 +1662,7 @@ function updatePageAccessGrants(data: {
1662
1662
 
1663
1663
  const callback = async () => {
1664
1664
  if (data.pageID) {
1665
- await pages.setPageAccessGrants({ ...data, pageID: data.pageID });
1665
+ return await pages.setPageAccessGrants({ ...data, pageID: data.pageID });
1666
1666
  }
1667
1667
  };
1668
1668
 
@@ -152,6 +152,7 @@ const usePermissionsForPage = <T extends Record<string, string | string[]>>(
152
152
  permissions: T,
153
153
  accessGrants?: PageAccessGrantsSummary | null,
154
154
  pageLanguages?: (IDataLanguage | IPageLanguage)[],
155
+ originalGlobalPage?: number,
155
156
  ): Record<keyof T, boolean> => {
156
157
  const { currentUser, roles, isSuperAdmin } = useUserState();
157
158
 
@@ -234,20 +235,33 @@ const usePermissionsForPage = <T extends Record<string, string | string[]>>(
234
235
  : false;
235
236
 
236
237
  // User is restricted by pagePermissions and page is not in their list
237
- // But they can still access if in accessGrants
238
+ // But they can still access if in accessGrants or via originalGlobalPage inheritance
238
239
  if (isPagePermissionRestricted) {
239
- const pageHasAccessGrants = accessGrants?.users?.length || accessGrants?.roles?.length;
240
+ let hasPermissionBypass = false;
241
+
242
+ // Check if user has access via originalGlobalPage inheritance
243
+ if (originalGlobalPage !== undefined && currentUser.pagePermissions?.length) {
244
+ const globalSiteEntry = currentUser.pagePermissions.find(
245
+ (entry) => entry.siteId === "global",
246
+ );
247
+ hasPermissionBypass = globalSiteEntry?.pageIds.includes(originalGlobalPage) ?? false;
248
+ }
249
+
250
+ // Check accessGrants as fallback
251
+ if (!hasPermissionBypass) {
252
+ const pageHasAccessGrants = accessGrants?.users?.length || accessGrants?.roles?.length;
240
253
 
241
- if (pageHasAccessGrants) {
242
- const hasAccessGrantsAccess =
243
- accessGrants.users?.includes(currentUser.id || -1) ||
244
- userRoles?.some((roleId) => accessGrants.roles?.includes(roleId));
254
+ if (pageHasAccessGrants) {
255
+ const hasAccessGrantsAccess =
256
+ accessGrants.users?.includes(currentUser.id || -1) ||
257
+ userRoles?.some((roleId) => accessGrants.roles?.includes(roleId));
245
258
 
246
- if (!hasAccessGrantsAccess) {
259
+ if (!hasAccessGrantsAccess) {
260
+ return createPermissionResult(false);
261
+ }
262
+ } else {
247
263
  return createPermissionResult(false);
248
264
  }
249
- } else {
250
- return createPermissionResult(false);
251
265
  }
252
266
  }
253
267
 
@@ -275,7 +289,7 @@ const usePermissionsForPage = <T extends Record<string, string | string[]>>(
275
289
  result[key] = arrayPermission.some((perm: string) => sitePermissionsSet.has(perm));
276
290
  }
277
291
  return result as Record<keyof T, boolean>;
278
- }, [siteId, pageId, permissions, accessGrants, currentUser, roles, isSuperAdmin, pageLanguages]);
292
+ }, [siteId, pageId, permissions, accessGrants, currentUser, roles, isSuperAdmin, pageLanguages, originalGlobalPage]);
279
293
  };
280
294
 
281
295
  export {
@@ -110,6 +110,7 @@ const PageItem = (props: IPageItemProps): JSX.Element => {
110
110
  },
111
111
  accessGrants,
112
112
  pageLanguages,
113
+ page.originalGlobalPage,
113
114
  );
114
115
 
115
116
  const currentTemplateDataPacks = schemas.templates[templateId].dataPacks;
@@ -562,7 +562,7 @@ const GlobalEditor = (props: IProps) => {
562
562
  props.setHistoryPush(backLinkRoute, true);
563
563
  };
564
564
 
565
- const mainAction = { title: "Preview Page", onClick: toggleModal };
565
+ const mainAction = { title: "Preview Page", onClick: () => toggleModal("userEditing") };
566
566
  const secondaryAction = { title: "Ok, go back", onClick: handleGoBack };
567
567
 
568
568
  const mainUnpublishAction = { title: "Ok", onClick: () => toggleModal("unpublish") };
@@ -95,6 +95,7 @@ const PageEditor = (props: IProps) => {
95
95
  },
96
96
  accessGrants,
97
97
  pageLanguages,
98
+ editorContent?.originalGlobalPage,
98
99
  );
99
100
 
100
101
  const defaultTab = isAllowedTo.editContentPages ? "edit" : "view";
@@ -464,7 +464,7 @@ const UserForm = (props: IProps) => {
464
464
  <SettingsSection
465
465
  heading="Page permissions"
466
466
  description="You can give access only to a specific page/s to this user."
467
- actionLabel="Add Role"
467
+ actionLabel="Add Page"
468
468
  onActionClick={() => toggleModal("pagePermissions")}
469
469
  showAction={selectedPages.length === 0}
470
470
  />
@@ -596,6 +596,7 @@ const UserForm = (props: IProps) => {
596
596
  defaultLang={defaultLanguage?.id}
597
597
  alwaysShowButton
598
598
  disableTranslations
599
+ onlyLocal={isSiteView}
599
600
  />
600
601
  )}
601
602
  </S.PanelContent>
@@ -899,7 +899,7 @@ export interface IContentType {
899
899
  editable: boolean;
900
900
  fromPage: boolean;
901
901
  id: string;
902
- local: false;
902
+ local: boolean;
903
903
  schema: any;
904
904
  taxonomy: boolean;
905
905
  title: string;