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

feat(boards): visual overhaul #1532

Closed
wants to merge 14 commits into from
Closed

feat(boards): visual overhaul #1532

wants to merge 14 commits into from

Conversation

emilielr
Copy link
Collaborator

@emilielr emilielr commented May 30, 2024

image

@lindtvedtsebastian lindtvedtsebastian changed the title feat(boards): new bords view and org. name as column feat(boards): visual overhaul May 31, 2024
@emilielr emilielr marked this pull request as ready for review June 3, 2024 13:28
@emilielr emilielr requested review from oyvindgrutle and purusott June 3, 2024 13:31
@purusott
Copy link
Collaborator

purusott commented Jun 4, 2024

Jeg opprettet en ny bruker og gikk inn på tavlesiden. Der får jeg opp mange tavler, selv om jeg ikke har laget noen enda. Mistenker det er tavler til de andre brukerne i db 🤔 Skjer det bare hos meg?

Copy link
Collaborator

@purusott purusott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jeg tror det er et problem i tavlesiden hvor man kan få inn tavlene til andre brukere. Jeg opprettet en ny bruker og hadde mange tavler på min tavleside da jeg sjekket det ut lokalt 🤔 💭

next-tavla/app/(admin)/boards/components/Column/Name.tsx Outdated Show resolved Hide resolved
next-tavla/app/(admin)/actions.ts Outdated Show resolved Hide resolved
@emilielr emilielr requested a review from purusott June 5, 2024 12:22
@emilielr
Copy link
Collaborator Author

emilielr commented Jun 5, 2024

Her har det gått fort i svingene 😅 Har fikset det nå!

next-tavla/app/(admin)/boards/components/Column/Name.tsx Outdated Show resolved Hide resolved
@@ -75,7 +75,7 @@ export async function getBoardsForOrganization(oid: TOrganizationID) {
.flat()
}

export async function getBoardsForUser() {
export async function getPrivateBoardsForUser() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Brukes denne funksjonen til noe nå eller kan den fjernes?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nei, men jeg lurer på om det er greit at den bare ligger hvis vi skal vise alle private tavler til en person en gang? Det har vært litt snakk om å kanskje filterer på organisasjoner uansett på tavler-siden, og da skal vi også kunne filtrere på private tavler

next-tavla/app/(admin)/actions.ts Outdated Show resolved Hide resolved
Comment on lines +44 to +59
async function getBoardsWithOrganization(boards: TBoard[]) {
const organizations = await getOrganizationsForUser()

const boardsWithOrganization = boards.map((board: TBoard) => {
const org = organizations.find((org) =>
org.boards?.includes(board.id ?? ''),
)

return {
board: { ...board },
organization: { ...org },
} as TBoardWithOrganization
})

return boardsWithOrganization
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Denne funksjonen trenger vi ikke hvis vi skriver om getAllBoardsForUser til å inkludere org direkte. Nå kjører vi getOrganizationsForUser to ganger nesten rett etter hverandre (første i getAllBoardsForUser på linje 26 og deretter i denne funksjonen)

Comment on lines +26 to +29
<Table {...getSortableTableProps}>
<TableHeader getSortableHeaderProps={getSortableHeaderProps} />
<TableRows boardsWithOrgs={sortedData} />
</Table>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jeg får opp flere problemer i node, virker som det skjer noe greier i Table komponenten som krasjer serveren. Prøv å import den uten ssr (lazy) og se om det funker da

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Denne filen sin path burde endres, vi trenger ikke lenger organization id som param

Comment on lines 108 to 139
export async function getAllBoardsForUser() {
const user = await getUser()
if (!user)
throw new TavlaError({
code: 'NOT_FOUND',
message: `Found no user`,
})

const privateBoardIDs = concat(user.owner ?? [], user.editor ?? [])

const organizations = await getOrganizationsForUser()
const organizationBoardIDs = organizations.map((o) => o.boards)

const boardIDs = concat(privateBoardIDs, organizationBoardIDs.flat())

const batchedBoardIDs = chunk(boardIDs, 20)

const boardQueries = batchedBoardIDs.map((batch) =>
firestore()
.collection('boards')
.where(firestore.FieldPath.documentId(), 'in', batch)
.get(),
)

const boardRefs = await Promise.all(boardQueries)

return boardRefs
.map((ref) =>
ref.docs.map((doc) => ({ id: doc.id, ...doc.data() } as TBoard)),
)
.flat()
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Foreslår å hente ut all informasjonen vi trenger direkte her.

En mulig måte å gjøre dette på:

export async function getBoards(ids?: TBoardID[]) {
    if (!ids) return []
    const batches = chunk(ids, 20)
    const queries = batches.map((batch) =>
        firestore()
            .collection('boards')
            .where(firestore.FieldPath.documentId(), 'in', batch)
            .get(),
    )
    const refs = await Promise.all(queries)
    return refs
        .map((ref) =>
            ref.docs.map((doc) => ({ id: doc.id, ...doc.data() } as TBoard)),
        )
        .flat()
}

export async function getAllBoardsForUser(): Promise<
    { board: TBoard; organization?: TOrganization }[]
> {
    const user = await getUser()
    if (!user) return redirect('/')

    const privateBoardIDs = concat(user.owner ?? [], user.editor ?? [])

    const privateBoards = (await getBoards(privateBoardIDs)).map((board) => ({
        board,
    }))

    const organizations = await getOrganizationsForUser()

    const organizationsBoards = flattenDeep(
        await Promise.all(
            organizations.map(async (organization) =>
                (
                    await getBoards(organization.boards)
                ).map((board) => ({
                    board,
                    organization,
                })),
            ),
        ),
    )
    return [...organizationsBoards, ...privateBoards]
}

@emilielr emilielr closed this Jun 14, 2024
@emilielr emilielr deleted the new-boards-view branch July 12, 2024 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants