@griddo/ax 11.16.0-rc.2 → 11.16.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/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.2",
4
+ "version": "11.16.0",
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": "7c8f537bfce679622c5430c4e016627e26e2297b"
222
+ "gitHead": "8e8d3b302199787e7e6bc798d147718d0ea416de"
223
223
  }
@@ -31,17 +31,13 @@ const GlobalPageForm = (props: IGlobalPageFormProps): JSX.Element => {
31
31
 
32
32
  const isAllowedToEditGlobalData = useGlobalPermission("global.globalData.editAllGlobalData");
33
33
 
34
- const handleGetGlobalPage = async () => {
35
- actions.saveCurrentSiteInfoAction();
36
- await actions.getGlobalFromLocalPageAction();
37
- };
38
-
39
34
  const handleClick = async () => {
40
35
  if (isAllowedToEditGlobalData) {
41
36
  const navigate = async () => {
42
- await handleGetGlobalPage();
37
+ await actions.getGlobalFromLocalPageAction();
43
38
  const path = "/data/pages/editor";
44
39
  setHistoryPush?.(path, true);
40
+ actions.saveCurrentSiteInfoAction();
45
41
  };
46
42
 
47
43
  if (isDirty && onNavigateWithDirty) {
@@ -35,7 +35,7 @@ const PageFinder = (props: IPageFinderProps): JSX.Element => {
35
35
  const initialState: IState = {
36
36
  site: globalContent ? null : currentSiteID || allSites[0].id,
37
37
  lang: defaultLang || lang.id,
38
- type: "all",
38
+ type: onlyLocal ? "local" : "all",
39
39
  items: [],
40
40
  page: 1,
41
41
  totalItems: 0,
@@ -50,12 +50,12 @@ const PageFinder = (props: IPageFinderProps): JSX.Element => {
50
50
 
51
51
  const defultTypeOptions = !globalContent
52
52
  ? [
53
- { label: "All content", value: "all" },
53
+ { label: "All content", value: onlyLocal ? "local" : "all" },
54
54
  { label: "Base templates", value: "basic" },
55
55
  { label: "List pages", value: "list" },
56
56
  { label: "Static pages", value: "static" },
57
57
  ]
58
- : [{ label: "All content", value: "all" }];
58
+ : [{ label: "All content", value: onlyLocal ? "local" : "all" }];
59
59
 
60
60
  const [contentTypeOptions, setContentTypeOptions] = useState<{ label: string; value: string }[]>(defultTypeOptions);
61
61
 
@@ -121,7 +121,7 @@ const PageFinder = (props: IPageFinderProps): JSX.Element => {
121
121
  itemsPerPage,
122
122
  query: searchQuery,
123
123
  lang: state.lang,
124
- filterStructuredData: isTypeFilter(state.type) ? "all" : state.type,
124
+ filterStructuredData: isTypeFilter(state.type) ? (onlyLocal ? "local" : "all") : state.type,
125
125
  format: "list",
126
126
  };
127
127
 
@@ -165,7 +165,7 @@ const PageFinder = (props: IPageFinderProps): JSX.Element => {
165
165
  }
166
166
 
167
167
  changeContentTypeOptions(contentTypes);
168
- changeState("type", "all");
168
+ changeState("type", onlyLocal ? "local" : "all");
169
169
  };
170
170
 
171
171
  // biome-ignore lint/correctness/useExhaustiveDependencies: TODO: fix this
@@ -1461,7 +1461,7 @@ function getGlobalFromLocalPage(): (dispatch: Dispatch, getState: any) => Promis
1461
1461
  dispatch(setSitePageID(currentPageID));
1462
1462
  dispatch(setCurrentPageID(originalGlobalPage));
1463
1463
  structuredDataActions.setSelectedStructuredData(structuredData, "global")(dispatch, getState);
1464
- usersActions.getUserCurrentPermissions()(dispatch, getState);
1464
+ usersActions.getUserCurrentPermissions("global")(dispatch, getState);
1465
1465
  dispatch(setIsLoading(false));
1466
1466
  } catch (e) {
1467
1467
  console.log(e);
@@ -312,7 +312,9 @@ function activateRoles(params: IActivateRole): (dispatch: Dispatch) => Promise<b
312
312
  };
313
313
  }
314
314
 
315
- function getUserCurrentPermissions(): (dispatch: Dispatch, getState: () => IRootState) => Promise<void> {
315
+ function getUserCurrentPermissions(
316
+ scope?: "global" | "site",
317
+ ): (dispatch: Dispatch, getState: () => IRootState) => Promise<void> {
316
318
  return async (dispatch, getState) => {
317
319
  const {
318
320
  users: { roles, currentUser },
@@ -323,18 +325,22 @@ function getUserCurrentPermissions(): (dispatch: Dispatch, getState: () => IRoot
323
325
  return;
324
326
  }
325
327
 
326
- const userRoles = currentSiteInfo
327
- ? currentUser.roles.find((roleSite) => roleSite.siteId === currentSiteInfo.id || roleSite.siteId === "all")?.roles
328
- : currentUser.roles.find((roleSite) => roleSite.siteId === "global")?.roles;
328
+ const userRoles =
329
+ !currentSiteInfo || scope === "global"
330
+ ? currentUser.roles.find((roleSite) => roleSite.siteId === "global")?.roles
331
+ : currentUser.roles.find((roleSite) => roleSite.siteId === currentSiteInfo.id || roleSite.siteId === "all")
332
+ ?.roles;
329
333
 
330
334
  let permissions: string[] = [];
331
335
  if (userRoles?.length) {
332
336
  userRoles.forEach((roleID: number) => {
333
337
  const rolePerms = roles?.reduce((acc: string[], curr: IRole) => {
334
338
  if (curr.id === roleID) {
335
- const permissions = currentSiteInfo
336
- ? curr.permissions.sitePermissions
337
- : [...curr.permissions.globalPermissions, ...curr.permissions.sitePermissions];
339
+ const permissions =
340
+ !currentSiteInfo || scope === "global"
341
+ ? [...curr.permissions.globalPermissions, ...curr.permissions.sitePermissions]
342
+ : curr.permissions.sitePermissions;
343
+
338
344
  const keys = permissions.map((perm) => perm.key);
339
345
  acc.push(...keys);
340
346
  }
@@ -344,7 +350,7 @@ function getUserCurrentPermissions(): (dispatch: Dispatch, getState: () => IRoot
344
350
  });
345
351
  }
346
352
  dispatch(setCurrentPermissions(permissions));
347
- if (!currentSiteInfo) {
353
+ if (!currentSiteInfo || scope === "global") {
348
354
  dispatch(setGlobalPermissions(permissions));
349
355
  }
350
356
  };