fix sharetoken permissions on mixed boards
This commit is contained in:
1 parent
5e6f88f123
commit
a87d899e17
6 files changed
+44
-13
No files matched your search
+32
-8
@@ -164,18 +164,34 @@ export function getFirstBoardComponentEntity(
|
||||
return {};
|
||||
}
|
||||
|
||||
export function getBoardWebsiteIds(
|
||||
board?: Pick<Board, 'type' | 'parameters'> | Partial<Board>,
|
||||
): string[] {
|
||||
const ids = new Set<string>();
|
||||
export function getBoardEntityIds(board?: Pick<Board, 'type' | 'parameters'> | Partial<Board>): {
|
||||
websiteIds: string[];
|
||||
pixelIds: string[];
|
||||
linkIds: string[];
|
||||
} {
|
||||
const websiteIds = new Set<string>();
|
||||
const pixelIds = new Set<string>();
|
||||
const linkIds = new Set<string>();
|
||||
const boardEntity = getBoardEntity(board);
|
||||
|
||||
if (boardEntity.entityType === BOARD_ENTITY_TYPES.website && boardEntity.entityId) {
|
||||
ids.add(boardEntity.entityId);
|
||||
websiteIds.add(boardEntity.entityId);
|
||||
} else if (boardEntity.entityType === BOARD_ENTITY_TYPES.pixel && boardEntity.entityId) {
|
||||
pixelIds.add(boardEntity.entityId);
|
||||
} else if (boardEntity.entityType === BOARD_ENTITY_TYPES.link && boardEntity.entityId) {
|
||||
linkIds.add(boardEntity.entityId);
|
||||
}
|
||||
|
||||
if (board?.parameters?.websiteId) {
|
||||
ids.add(board.parameters.websiteId);
|
||||
websiteIds.add(board.parameters.websiteId);
|
||||
}
|
||||
|
||||
if (board?.parameters?.pixelId) {
|
||||
pixelIds.add(board.parameters.pixelId);
|
||||
}
|
||||
|
||||
if (board?.parameters?.linkId) {
|
||||
linkIds.add(board.parameters.linkId);
|
||||
}
|
||||
|
||||
for (const row of board?.parameters?.rows ?? []) {
|
||||
@@ -183,12 +199,20 @@ export function getBoardWebsiteIds(
|
||||
const entity = getComponentEntity(column.component);
|
||||
|
||||
if (entity.entityType === BOARD_ENTITY_TYPES.website && entity.entityId) {
|
||||
ids.add(entity.entityId);
|
||||
websiteIds.add(entity.entityId);
|
||||
} else if (entity.entityType === BOARD_ENTITY_TYPES.pixel && entity.entityId) {
|
||||
pixelIds.add(entity.entityId);
|
||||
} else if (entity.entityType === BOARD_ENTITY_TYPES.link && entity.entityId) {
|
||||
linkIds.add(entity.entityId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [...ids];
|
||||
return {
|
||||
websiteIds: [...websiteIds],
|
||||
pixelIds: [...pixelIds],
|
||||
linkIds: [...linkIds],
|
||||
};
|
||||
}
|
||||
|
||||
export function clearBoardEntity(parameters: BoardParameters = {}): BoardParameters {
|
||||
|
||||
@@ -24,7 +24,9 @@ export interface Auth {
|
||||
websiteIds?: string[];
|
||||
boardId?: string;
|
||||
pixelId?: string;
|
||||
pixelIds?: string[];
|
||||
linkId?: string;
|
||||
linkIds?: string[];
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user