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

Convert ParametersList to TS #42822

Merged
merged 6 commits into from
May 28, 2024
Merged

Conversation

oisincoveney
Copy link
Contributor

Converts ParametersList and SyncedParametersList to TS. It also unifies the props so there's less redundancy in type declarations

@oisincoveney oisincoveney changed the base branch from master to refactor-dashboard-controls May 17, 2024 08:58
Copy link

replay-io bot commented May 17, 2024

Status Complete ↗︎
Commit d443e46
Results
⚠️ 1 Flaky
2571 Passed

@oisincoveney oisincoveney requested a review from a team May 20, 2024 08:57
@oisincoveney oisincoveney added the no-backport Do not backport this PR to any branch label May 20, 2024
@oisincoveney oisincoveney force-pushed the convert-parameters-list-to-ts branch from 360818f to 3b67391 Compare May 20, 2024 09:48
Copy link
Contributor

@heypoom heypoom left a comment

Choose a reason for hiding this comment

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

Looks good to me so far! Just a couple of nits and questions.

@@ -66,8 +72,7 @@ function ParametersList({
setEditingParameter={setEditingParameter}
setValue={
setParameterValue &&
(value =>
setParameterValue(valuePopulatedParameter.id, value, dashboard?.id))
((value: any) => setParameterValue(valuePopulatedParameter.id, value))
Copy link
Contributor

Choose a reason for hiding this comment

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

I suppose the value here can be of multiple types?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep, I'll actually change this to unknown since the setParameterValue action expects:

(parameterId: ParameterId, value: unknown)

Comment on lines 15 to 17
dashboard?: Dashboard | null;
editingParameter?: Parameter | null;
Copy link
Contributor

Choose a reason for hiding this comment

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

This makes these parameters accept both undefined and null. If we know that it only accepts null and not undefined we can also update the type here to be more strict (e.g. dashboard: Dashboard | null. Otherwise ok to leave as-is.

Comment on lines 25 to 27
} & Pick<DashboardFullscreenControls, "isFullscreen"> &
Pick<DashboardThemeControls, "isNightMode"> &
Pick<DashboardHideParametersControls, "hideParameters">
Copy link
Contributor

Choose a reason for hiding this comment

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

Since isFullscreen and isNightMode is a plain boolean, I think we can inline them.

However, I suppose the intent here is to be aware of a breaking change when isFullscreen disappears from the DashboardFullscreenControls, so we know that this type has to be updated? i.e. to communicate that the prop is passed down from those components. If so, we can leave this as-is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Exactly - since we're prop-drilling these all the way down to ParametersList, I think it would make more sense to ensure that the type remains the same all the way down the chain

@@ -32,7 +32,7 @@ export function buildHiddenParametersSlugSet(

export function getVisibleParameters(
parameters: UiParameter[],
hiddenParameterSlugs?: string,
hiddenParameterSlugs?: string | null,
Copy link
Contributor

Choose a reason for hiding this comment

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

This makes it accept both undefined and null. You can also do hiddenParameterSlugs: string | null = null if you only need null.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Much better 😄

@heypoom heypoom requested a review from a team May 20, 2024 11:09
@oisincoveney oisincoveney removed the request for review from camsaul May 20, 2024 11:38
@oisincoveney oisincoveney force-pushed the convert-parameters-list-to-ts branch from 331d42d to b02b40c Compare May 21, 2024 07:02
@oisincoveney oisincoveney changed the base branch from refactor-dashboard-controls to master May 21, 2024 07:03
@oisincoveney oisincoveney force-pushed the convert-parameters-list-to-ts branch from b02b40c to 30d0019 Compare May 21, 2024 07:04
@oisincoveney oisincoveney changed the base branch from master to refactor-dashboard-controls May 21, 2024 07:04
Base automatically changed from refactor-dashboard-controls to master May 24, 2024 18:58
@deniskaber
Copy link
Contributor

Please also address #42777 (comment) in scope of this PR.

@oisincoveney oisincoveney force-pushed the convert-parameters-list-to-ts branch from 08c7fe2 to f8dc4a0 Compare May 27, 2024 11:55
@oisincoveney oisincoveney force-pushed the convert-parameters-list-to-ts branch from 8860162 to 0795a99 Compare May 28, 2024 09:20
@oisincoveney
Copy link
Contributor Author

I'll do it in #43221 so we can separate the PRs and isolate the logic for a better review

@oisincoveney oisincoveney merged commit ed3cfb6 into master May 28, 2024
109 checks passed
@oisincoveney oisincoveney deleted the convert-parameters-list-to-ts branch May 28, 2024 12:20
Copy link

@oisincoveney Did you forget to add a milestone to the issue for this PR? When and where should I add a milestone?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-backport Do not backport this PR to any branch .Team/Embedding
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants