Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bookmarks type crash #7282

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions pkg/webui/console/store/middleware/logics/user-preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ const getBookmarksThroughPagination = async userId => {
while ((page - 1) * limit < totalCount) {
// Get the next page of bookmarks.
// eslint-disable-next-line no-await-in-loop
const response = await tts.Users.getBookmarks(userId, { page, limit, order: '-created_at' })
const response = await tts.Users.getBookmarks(userId, {
page,
limit,
order: '-created_at',
})
response.bookmarks.forEach(element => {
const entityIds = element.entity_ids
const entity = Object.keys(entityIds)[0].replace('_ids', '')
Expand Down Expand Up @@ -93,7 +97,12 @@ const getBookmarksPerEntityThroughPagination = async (

while (result.perEntityBookmarks[requestedEntity].length < totalCount) {
// eslint-disable-next-line no-await-in-loop
const response = await tts.Users.getBookmarks(userId, { page, limit, order: '-created_at' })
const response = await tts.Users.getBookmarks(userId, {
page,
limit,
order: '-created_at',
entity_types: requestedEntity,
})
if (totalCount > response.totalCount) {
totalCount = response.totalCount
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/webui/console/store/selectors/top-entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ export const selectTopEntities = createSelector(
const items = entityTypes.reduce((acc, entityType) => {
const entityRelevantBookmarks =
entityType === ALL
? bookmarks
? // If bookmarks were added through the CLI, there might be organizations, clients or users in the bookmarks, so we need to filter them out.
bookmarks.filter(bookmark => entityTypes.includes(getBookmarkType(bookmark)))
: bookmarks.filter(bookmark => getBookmarkType(bookmark) === entityType)

// Always put the bookmarks first.
Expand Down
Loading