-
Notifications
You must be signed in to change notification settings - Fork 0
[LOCKLITE-73] Display the list of vaults #57
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
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
e773370
refactor: Rename Home to HomePage
vbetsch b573c4b
refactor: Create SharedChildrenProps & SharedLayoutProps
vbetsch 148cb79
feat: Create workspace page
vbetsch 630b33f
refactor: Use a base API URL in request service
vbetsch 819237e
feat: Create VaultsGateway
vbetsch f28ab4e
feat: Implement WorkspacePage
vbetsch 520f2da
chore(linter): Add arrow parens rule
vbetsch e3f6c94
style(formatter): Format files by Prettier
vbetsch 348499e
fix: list display
vbetsch 41643e0
feat: New vaults display
vbetsch 4bbfa56
feat: New vaults display
vbetsch b0c368c
feat: Improve vaults grid
vbetsch bedeffa
feat: Improve vaults grid
vbetsch c4d6ea5
fix: padding
vbetsch 272b0c0
fix: scrollable list
vbetsch 93f0786
fix: scrollable secret
vbetsch a88e34f
fix: list height
vbetsch ab4ed2e
Revert "refactor: Use a base API URL in request service"
vbetsch bb817ea
refactor: Transform request service to abstract class and create Lock…
vbetsch 24852f2
fix: eslint
vbetsch 3824c02
fix: redirect home page to workspace page
vbetsch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| /node_modules/ | ||
| /dist/ | ||
| /.github/release_template.md | ||
| README.md |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| import React from 'react'; | ||
| import type { JSX } from 'react'; | ||
| import { redirect } from 'next/navigation'; | ||
|
|
||
| export default function Home(): JSX.Element { | ||
| return <></>; | ||
| export default function HomePage(): JSX.Element { | ||
| redirect('/ui/workspace'); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import React from 'react'; | ||
| import type { JSX } from 'react'; | ||
| import type { SharedLayoutProps } from '@shared/types/props/SharedLayoutProps'; | ||
|
|
||
| export default function WorkspaceLayout(props: SharedLayoutProps): JSX.Element { | ||
| return <>{props.children}</>; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| 'use client'; | ||
|
|
||
| import 'reflect-metadata'; | ||
| import React, { useState } from 'react'; | ||
| import type { JSX } from 'react'; | ||
| import type { VaultModelDto } from '@shared/dto/models/vault.model.dto'; | ||
| import ErrorMessage from '@ui/components/common/ErrorMessage'; | ||
| import CircularLoader from '@ui/components/common/CircularLoader'; | ||
| import { VaultsGateway } from '@ui/gateways/vaults.gateway'; | ||
| import { container } from 'tsyringe'; | ||
| import type { GetMyVaultsResponseDto } from '@shared/dto/responses/get-my-vaults.response.dto'; | ||
| import { useApi } from '@ui/hooks/useApi'; | ||
| import { | ||
| Box, | ||
| Card, | ||
| CardContent, | ||
| CardHeader, | ||
| Container, | ||
| Grid, | ||
| Typography, | ||
| } from '@mui/material'; | ||
|
|
||
| export default function WorkspacePage(): JSX.Element { | ||
| const [vaults, setVaults] = useState<VaultModelDto[]>([]); | ||
| const [error, setError] = useState<Error | null>(null); | ||
| const vaultsGateway: VaultsGateway = container.resolve(VaultsGateway); | ||
|
|
||
| const { loading } = useApi<GetMyVaultsResponseDto>({ | ||
| request: () => vaultsGateway.getMyVaults(), | ||
| onSuccess: data => setVaults(data.myVaults), | ||
| onError: error => setError(error), | ||
| deps: [], | ||
| }); | ||
|
|
||
| return ( | ||
| <Container | ||
| sx={{ | ||
| padding: '2rem', | ||
| display: 'flex', | ||
| flexDirection: 'column', | ||
| gap: '3rem', | ||
| }} | ||
| > | ||
| <Typography variant={'h3'} textAlign={'left'}> | ||
| My vaults | ||
| </Typography> | ||
| <ErrorMessage error={error} /> | ||
| <CircularLoader loading={loading} /> | ||
| {!loading && vaults.length === 0 && ( | ||
| <Typography>No results found</Typography> | ||
| )} | ||
| {vaults.length > 0 && ( | ||
| <Grid | ||
| container | ||
| spacing={{ xs: 2, md: 3, lg: 3, xl: 4 }} | ||
| columns={{ xs: 1, md: 2, lg: 3, xl: 3 }} | ||
| overflow={'auto'} | ||
| height={'70vh'} | ||
| > | ||
| {vaults.map(vault => ( | ||
| <Grid key={vault.id} size={1}> | ||
| <Card | ||
| sx={{ | ||
| bgcolor: 'background.paper', | ||
| }} | ||
| > | ||
| <CardHeader title={vault.label} /> | ||
| <CardContent> | ||
| <Box | ||
| sx={{ | ||
| display: 'flex', | ||
| alignItems: 'center', | ||
| justifyContent: 'space-between', | ||
| gap: '1rem', | ||
| }} | ||
| > | ||
| <Typography variant="body2" color="text.secondary"> | ||
| Secret: | ||
| </Typography> | ||
| <Typography | ||
| variant="body2" | ||
| color="text.secondary" | ||
| fontFamily={'monospace'} | ||
| overflow={'scroll'} | ||
| textOverflow={'ellipsis'} | ||
| > | ||
| {vault.secret} | ||
| </Typography> | ||
vbetsch marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| </Box> | ||
| </CardContent> | ||
| </Card> | ||
| </Grid> | ||
| ))} | ||
| </Grid> | ||
| )} | ||
| </Container> | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| export abstract class RequestService { | ||
| protected constructor(private readonly _baseApiUrl: string = '') {} | ||
|
|
||
| private async _fetch<T>(uri: string, options: RequestInit): Promise<T> { | ||
| const response: Response = await fetch(`${this._baseApiUrl}${uri}`, { | ||
| ...options, | ||
| headers: { | ||
| 'Content-Type': 'application/json', | ||
| ...(options.headers ?? {}), | ||
| }, | ||
| }); | ||
|
|
||
| if (!response.ok) { | ||
| let message: string = 'Unexpected error'; | ||
| try { | ||
| // eslint-disable-next-line @typescript-eslint/typedef | ||
| const errorJson = await response.json(); | ||
| // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access | ||
| message = errorJson?.error ?? message; | ||
| } catch { | ||
| message = await response.text(); | ||
| } | ||
| throw new Error(message); | ||
| } | ||
|
|
||
| return response.json(); | ||
| } | ||
|
|
||
| public async get<T>(uri: string): Promise<T> { | ||
| return await this._fetch<T>(uri, { method: 'GET' }); | ||
| } | ||
|
|
||
| public async post<T>(uri: string, body: unknown): Promise<T> { | ||
| return await this._fetch<T>(uri, { | ||
| method: 'POST', | ||
| body: JSON.stringify(body), | ||
| }); | ||
| } | ||
|
|
||
| public async put<T>(uri: string, body: unknown): Promise<T> { | ||
| return await this._fetch<T>(uri, { | ||
| method: 'PUT', | ||
| body: JSON.stringify(body), | ||
| }); | ||
| } | ||
|
|
||
| public async delete<T>(uri: string): Promise<T> { | ||
| return await this._fetch<T>(uri, { method: 'DELETE' }); | ||
| } | ||
| } |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import type React from 'react'; | ||
|
|
||
| export type SharedChildrenProps = { | ||
| children: React.ReactNode; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| import type { SharedChildrenProps } from '@shared/types/props/SharedChildrenProps'; | ||
|
|
||
| export type SharedLayoutProps = SharedChildrenProps; | ||
vbetsch marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.