-
Notifications
You must be signed in to change notification settings - Fork 103
feat(kms): secrets listing page #17705
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
base: project/secret-management-service-b1
Are you sure you want to change the base?
feat(kms): secrets listing page #17705
Conversation
811678e
to
d80407d
Compare
d80407d
to
09c2d31
Compare
"secret_manager": "Secret Manager", | ||
"path": "Path", | ||
"version": "Version", | ||
"creation_date": "Date de création" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can replace it with creation_date
from @ovh-ux/manager-common-translations
export const getSecretList = async (okmsId: string) => { | ||
const response = await apiClient.v2.get<Secret[]>( | ||
`okms/resource/${okmsId}/secret`, | ||
); | ||
return response.data; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export const getSecretList = async (okmsId: string) => { | |
const response = await apiClient.v2.get<Secret[]>( | |
`okms/resource/${okmsId}/secret`, | |
); | |
return response.data; | |
}; | |
export const getSecretList = async (okmsId: string) => { | |
const { data } = await apiClient.v2.get<Secret[]>( | |
`okms/resource/${okmsId}/secret`, | |
); | |
return data; | |
}; |
for the sake of consistency, what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me is "bonnet blanc" / "blanc bonnet".
It does the same and is colocated in the function scope.
So you prefer it like this I can do it this way.
My main concern is to avoid returning the full axios response and manage the "data" properties in the components as it is done in kms code, this makes my eyes bleed with a lot of pain :)
it.skip('should display the secrets listing page', async () => { | ||
await renderPage(); | ||
}); | ||
|
||
it.skip('should display the listing table with all columns', async () => { | ||
await renderPage(); | ||
|
||
const tableHeaders = [ | ||
labels.secretManager.common.path, | ||
labels.secretManager.common.version, | ||
labels.secretManager.common.creation_date, | ||
]; | ||
|
||
tableHeaders.forEach((header) => { | ||
expect(screen.queryAllByText(header)).toHaveLength(1); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it.skip('should display the secrets listing page', async () => { | |
await renderPage(); | |
}); | |
it.skip('should display the listing table with all columns', async () => { | |
await renderPage(); | |
const tableHeaders = [ | |
labels.secretManager.common.path, | |
labels.secretManager.common.version, | |
labels.secretManager.common.creation_date, | |
]; | |
tableHeaders.forEach((header) => { | |
expect(screen.queryAllByText(header)).toHaveLength(1); | |
}); | |
}); | |
it('should display the secrets listing page', async () => { | |
await renderPage(); | |
}); | |
it('should display the listing table with all columns', async () => { | |
await renderPage(); | |
const tableHeaders = [ | |
labels.secretManager.common.path, | |
labels.secretManager.common.version, | |
labels.secretManager.common.creation_date, | |
]; | |
tableHeaders.forEach((header) => { | |
expect(screen.queryAllByText(header)).toHaveLength(1); | |
}); | |
}); |
forgot to unskip?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like to skip things to go faster
export type DatagridItem = { | ||
okmsId: string; | ||
secret: Secret; | ||
}; | ||
|
||
export const DatagridCellPath = (item: DatagridItem) => { | ||
const url = SECRET_MANAGER_ROUTES_URLS.secretDashboard( | ||
item.okmsId, | ||
item.secret.path, | ||
); | ||
|
||
return <Link href={url} label={item.secret.path} useRouter />; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably better to use useParams
to get the domainId instead of augmenting the secret data.
export type DatagridItem = { | |
okmsId: string; | |
secret: Secret; | |
}; | |
export const DatagridCellPath = (item: DatagridItem) => { | |
const url = SECRET_MANAGER_ROUTES_URLS.secretDashboard( | |
item.okmsId, | |
item.secret.path, | |
); | |
return <Link href={url} label={item.secret.path} useRouter />; | |
}; | |
export const DatagridCellPath = (item: Secret) => { | |
const { okmsId } = useParams(); | |
const url = SECRET_MANAGER_ROUTES_URLS.secretDashboard( | |
okmsId, | |
item.secret.path, | |
); | |
return <Link href={url} label={item.secret.path} useRouter />; | |
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess your solution wins because it simplier.
But I am a bit bothered with those useParams that are implying a "context" where the component is used.
So I think I will add a .type file with the SecretListingPageParams
that explicitly write the dependency.
This then opens the question about common
components that would use useParams hook, and I think we just should avoid doing that.
const items: DatagridItem[] = | ||
secrets?.map((secret) => ({ | ||
okmsId: domainId, | ||
secret, | ||
})) || []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can get rid of this with useParams in the cell components
<div className="flex flex-col gap-6"> | ||
<Datagrid | ||
columns={columns} | ||
items={items} | ||
totalItems={items.length} | ||
isLoading={isPending} | ||
contentAlignLeft | ||
/> | ||
</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with only one child, this div with flex rules is not necessary.
<div className="flex flex-col gap-6"> | |
<Datagrid | |
columns={columns} | |
items={items} | |
totalItems={items.length} | |
isLoading={isPending} | |
contentAlignLeft | |
/> | |
</div> | |
<Datagrid | |
columns={columns} | |
items={items} | |
totalItems={items.length} | |
isLoading={isPending} | |
contentAlignLeft | |
/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup, that was copy pasta I should have re-read
import apiClient from '@ovh-ux/manager-core-api'; | ||
import { Secret } from '@secret-manager/types/secret.type'; | ||
|
||
export const secretListQueryKey = (okmsId: string) => ['secrets/list', okmsId]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export const secretListQueryKey = (okmsId: string) => ['secrets/list', okmsId]; | |
export const secretListQueryKey = (okmsId: string) => ['secrets', 'list', okmsId]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe, I took the "/" thing from other code but it already felt weird to me.
I'll think a bit about how we should manage those keys
ref: #MANAGER-18246 Signed-off-by: Mathieu Mousnier <mathieu.mousnier.ext@ovhcloud.com>
09c2d31
to
1cd82a0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be Listing.page.spec.tsx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be Listing.page.tsx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be listing.type.ts
@@ -0,0 +1,3 @@ | |||
export type SecretListingPageParams = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm not sure why this type is necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll talk about this, we'll remove it if we consider it useless.
It feels crazy to me that there is nothing to type what to expect from the router params
Description
Ticket Reference: #MANAGER-18246
Additional Information