@griddo/ax 11.16.0-rc.1 → 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 +2 -2
- package/src/components/PageFinder/index.tsx +7 -1
- 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.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": "
|
|
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) => ({
|
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>
|