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/pci private registry fix restriction tapc xxx #14916

Open
wants to merge 9 commits into
base: feat/pci-private-registry_create-restriction_tapc-584
Choose a base branch
from

Conversation

ppprevost
Copy link
Contributor

Question Answer
Branch?
Bug fix? yes
New feature? no
Breaking change? no
Tickets Fix #...
License BSD 3-Clause
  • Try to keep pull requests small so they can be easily reviewed.
  • Commits are signed-off
  • Only FR translations have been updated
  • Branch is up-to-date with target branch
  • Lint has passed locally
  • Standalone app was ran and tested locally
  • Ticket reference is mentioned in linked commits (internal only)
  • Breaking change is mentioned in relevant commits

Description

Related

@ppprevost ppprevost requested review from a team as code owners January 14, 2025 16:43
@ppprevost ppprevost requested review from acavalloni, MaximeBajeux, sidlynx, kqesar and anooparveti and removed request for a team January 14, 2025 16:43
@github-actions github-actions bot added the bug Something isn't working label Jan 14, 2025
@@ -88,7 +89,7 @@ export const useDatagridColumn = () => {
) : (
<div>{capitalizeAndJoin(props.authorization)}</div>
),
label: t('private_registry_cidr_authorization'),
label: ((<AuthorizationLabel />) as unknown) as string,
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add a comment to explain why you need this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hacky but do not have choice to implement a Popover next to label

Copy link
Contributor

Choose a reason for hiding this comment

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

I understand, maybe you could add a typescript comment above this line to explain

});
const { t } = useTranslation(['ip-restrictions']);

const uniqueValue = generateUniqueString(dataCIDR.rows);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be in a useMemo

columnFilters={columnFilters}
key={dataCIDR.totalRows}
key={uniqueValue}
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand why is this required

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes agree with you for me no Need of this key here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I need this key to refresh context, the behavior in other app is to manage pagination inside
if i do not use this key i need to refactor again inside the context to use.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do you know which variable isn't refreshed ? The context and the components using it should be updated, there might be a useMemo or useCallback not correctly configured

const { t } = useTranslation(['ip-restrictions']);
return (
<Controller
name="authorization"
control={control}
render={({ field: { onChange, value } }) => (
render={({ field: { onChange, value }, fieldState: { isDirty } }) => (
Copy link
Contributor

Choose a reason for hiding this comment

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

What does isDirty mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

isDirty means value touched and fill

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry but I can't make the relation ...
isDirty sounds like code smell to me ;)

* @returns {string} - A unique Base64-encoded string representing the filtered objects.
* @template T - The generic type of the objects in the array.
*/
export function generateUniqueString<T>(array: T[]): string {
Copy link
Contributor

Choose a reason for hiding this comment

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

I can't see the purpose of using a custom function to generate a unique key in base64 that is never decoded.

If the goal is to only generate a unique string, why not just using an uuid ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nope the main goal is to refresh the id of the key when data change

.sort()
.join('|');

return btoa(uniqueString); // Encode en base64 pour une chaîne compacte
Copy link
Contributor

Choose a reason for hiding this comment

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

french comment

@@ -88,7 +89,7 @@ export const useDatagridColumn = () => {
) : (
<div>{capitalizeAndJoin(props.authorization)}</div>
),
label: t('private_registry_cidr_authorization'),
label: ((<AuthorizationLabel />) as unknown) as string,
Copy link
Contributor

Choose a reason for hiding this comment

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

I can't understand clearly why you use here a React Component and cast it as a string?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the DataGrid only accepts string as type but in reality can accept ReactNode so this is a tweak because of wrong typing

Copy link
Contributor

@tibs245 tibs245 Jan 16, 2025

Choose a reason for hiding this comment

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

It's better change the type of DatagridColumn.label in packages/manager-react-components/src/components/datagrid/datagrid.component.tsxfor the next I think

@fredericvilcot
Copy link
Contributor

@ppprevost
Could you please reword your commits to follow conventional commit principles? (or squash them)
Thanks :)

Pierre-Philippe added 7 commits January 15, 2025 17:03
ref: TAPC-2591
Signed-off-by: Pierre-Philippe <[email protected]>
ref: TAPC-2589
Signed-off-by: Pierre-Philippe <[email protected]>
ref: TAPC-2589
Signed-off-by: Pierre-Philippe <[email protected]>
ref: TAPC-2585
Signed-off-by: Pierre-Philippe <[email protected]>
ref: TAPC-2583
Signed-off-by: Pierre-Philippe <[email protected]>
ref: TAPC-2581
Signed-off-by: Pierre-Philippe <[email protected]>
ref: TAPC-2591
Signed-off-by: Pierre-Philippe <[email protected]>
@ppprevost ppprevost force-pushed the fix/pci-private-registry_fix-restriction_tapc-xxx branch from 7f10638 to fdacddd Compare January 15, 2025 16:07
Pierre-Philippe added 2 commits January 16, 2025 11:55
Copy link

Comment on lines +43 to +64
<Trans ns="ip-restrictions">
<OsdsText
color={ODS_THEME_COLOR_INTENT.text}
level={ODS_TEXT_LEVEL.body}
>
{t('private_registry_cidr_help_authorized_component')}
</OsdsText>
<br />
<OsdsText
color={ODS_THEME_COLOR_INTENT.text}
level={ODS_TEXT_LEVEL.body}
>
{t('private_registry_cidr_help_authorized_component_part2')}
</OsdsText>
<br />
<OsdsText
color={ODS_THEME_COLOR_INTENT.text}
level={ODS_TEXT_LEVEL.body}
>
{t('private_registry_cidr_help_authorized_component_part3')}
</OsdsText>
</Trans>
Copy link
Contributor

Choose a reason for hiding this comment

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

If we just want add spacing between element. Maybe use container with gap (flex flex-col gap-2) ?

Allow to have better control ?

Comment on lines +120 to +122
dataGrid={{
...dataGrid,
}}
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe better copy value on provider and not on the usage ?

We can have case we just want send the reference of datagrid ?

};

const DatagridProvider = <TData extends DatagridAction[]>({
children,
data,
dataGrid,
columnFilters,
totalRows,
Copy link
Contributor

Choose a reason for hiding this comment

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

It's not just const totalRows = useMemo(() => data.length, [data]) ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants