@griddo/ax 11.16.0-rc.1 → 11.16.0-rc.3
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 +2 -2
- package/src/components/ConfigPanel/GlobalPageForm/index.tsx +2 -6
- package/src/components/PageFinder/index.tsx +12 -6
- package/src/containers/PageEditor/actions.tsx +1 -1
- package/src/containers/Users/actions.tsx +14 -8
- package/src/hooks/users.tsx +24 -10
- package/src/modules/Content/PageItem/index.tsx +1 -0
- package/src/modules/GlobalEditor/index.tsx +1 -1
- package/src/modules/PageEditor/index.tsx +1 -0
- package/src/modules/Users/UserForm/index.tsx +2 -1
- package/src/types/index.tsx +1 -1
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.
|
|
4
|
+
"version": "11.16.0-rc.3",
|
|
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": "
|
|
222
|
+
"gitHead": "f673c2a5efb5cd37858b5e6477aedbc44370271e"
|
|
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
|
|
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) {
|
|
@@ -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() }));
|
|
@@ -34,7 +35,7 @@ const PageFinder = (props: IPageFinderProps): JSX.Element => {
|
|
|
34
35
|
const initialState: IState = {
|
|
35
36
|
site: globalContent ? null : currentSiteID || allSites[0].id,
|
|
36
37
|
lang: defaultLang || lang.id,
|
|
37
|
-
type: "all",
|
|
38
|
+
type: onlyLocal ? "local" : "all",
|
|
38
39
|
items: [],
|
|
39
40
|
page: 1,
|
|
40
41
|
totalItems: 0,
|
|
@@ -49,12 +50,12 @@ const PageFinder = (props: IPageFinderProps): JSX.Element => {
|
|
|
49
50
|
|
|
50
51
|
const defultTypeOptions = !globalContent
|
|
51
52
|
? [
|
|
52
|
-
{ label: "All content", value: "all" },
|
|
53
|
+
{ label: "All content", value: onlyLocal ? "local" : "all" },
|
|
53
54
|
{ label: "Base templates", value: "basic" },
|
|
54
55
|
{ label: "List pages", value: "list" },
|
|
55
56
|
{ label: "Static pages", value: "static" },
|
|
56
57
|
]
|
|
57
|
-
: [{ label: "All content", value: "all" }];
|
|
58
|
+
: [{ label: "All content", value: onlyLocal ? "local" : "all" }];
|
|
58
59
|
|
|
59
60
|
const [contentTypeOptions, setContentTypeOptions] = useState<{ label: string; value: string }[]>(defultTypeOptions);
|
|
60
61
|
|
|
@@ -120,7 +121,7 @@ const PageFinder = (props: IPageFinderProps): JSX.Element => {
|
|
|
120
121
|
itemsPerPage,
|
|
121
122
|
query: searchQuery,
|
|
122
123
|
lang: state.lang,
|
|
123
|
-
filterStructuredData: isTypeFilter(state.type) ? "all" : state.type,
|
|
124
|
+
filterStructuredData: isTypeFilter(state.type) ? (onlyLocal ? "local" : "all") : state.type,
|
|
124
125
|
format: "list",
|
|
125
126
|
};
|
|
126
127
|
|
|
@@ -152,15 +153,19 @@ 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
|
}
|
|
161
166
|
|
|
162
167
|
changeContentTypeOptions(contentTypes);
|
|
163
|
-
changeState("type", "all");
|
|
168
|
+
changeState("type", onlyLocal ? "local" : "all");
|
|
164
169
|
};
|
|
165
170
|
|
|
166
171
|
// biome-ignore lint/correctness/useExhaustiveDependencies: TODO: fix this
|
|
@@ -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) => ({
|
|
@@ -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(
|
|
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 =
|
|
327
|
-
|
|
328
|
-
|
|
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 =
|
|
336
|
-
|
|
337
|
-
|
|
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
|
};
|
package/src/hooks/users.tsx
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
254
|
+
if (pageHasAccessGrants) {
|
|
255
|
+
const hasAccessGrantsAccess =
|
|
256
|
+
accessGrants.users?.includes(currentUser.id || -1) ||
|
|
257
|
+
userRoles?.some((roleId) => accessGrants.roles?.includes(roleId));
|
|
245
258
|
|
|
246
|
-
|
|
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 {
|
|
@@ -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") };
|
|
@@ -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
|
|
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>
|