Skip to content

Commit

Permalink
add scope
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey-weber committed Nov 16, 2023
1 parent 51e0bda commit e9210c2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
26 changes: 13 additions & 13 deletions src/services/entry/actions/create-in-workbook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,12 @@ export async function createEntryInWorkbook(

const {accessServiceEnabled} = ctx.config;

let permissions: Optional<UsPermission>;
const workbook = await getWorkbook(
{ctx, skipCheckPermissions: isPrivateRoute},
{workbookId, includePermissionsInfo},
);

const createdEntry = await transaction(Entry.primary, async (trx) => {
const workbook = await getWorkbook(
{ctx, trx, skipCheckPermissions: isPrivateRoute},
{workbookId, includePermissionsInfo},
);

if (accessServiceEnabled && !isPrivateRoute) {
await checkWorkbookPermission({
ctx,
Expand All @@ -118,13 +116,6 @@ export async function createEntryInWorkbook(
});
}

if (includePermissionsInfo) {
permissions = getEntryPermissionsByWorkbook({
ctx,
workbook,
});
}

const [entryId, revId] = await Promise.all([getId(), getId()]);

// TODO: DLS.addEntity / iam registrate entry
Expand Down Expand Up @@ -173,6 +164,15 @@ export async function createEntryInWorkbook(
});

const resultEntry: Entry & {permissions?: UsPermission} = createdEntry!;
let permissions: Optional<UsPermission>;

if (includePermissionsInfo) {
permissions = getEntryPermissionsByWorkbook({
ctx,
workbook,
scope: resultEntry.scope,
});
}

if (includePermissionsInfo) {
resultEntry.permissions = permissions;
Expand Down
2 changes: 1 addition & 1 deletion src/services/new/workbook/get-workbook-content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export const getWorkbookContent = async (
{ctx, trx, skipValidation: true, skipCheckPermissions},
{
workbookId,
includePermissionsInfo,
includePermissionsInfo: true,
},
);

Expand Down

0 comments on commit e9210c2

Please sign in to comment.