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: rework overview pane in schema browser #954

Merged
merged 7 commits into from
Jun 28, 2024
Merged

fix: rework overview pane in schema browser #954

merged 7 commits into from
Jun 28, 2024

Conversation

walborn
Copy link
Contributor

@walborn walborn commented Jun 27, 2024

I have deleted unnecessary components, because move this logic inside main component

@walborn walborn requested a review from Raubzeug June 27, 2024 13:19
/>
),
};
if (!currentSchemaData) return undefined;
Copy link
Contributor

Choose a reason for hiding this comment

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

please add curly braces

if (isNumeric(CreateStep) && Number(CreateStep)) {
overview.push({
label: 'Created',
value: dateTimeParse(Number(CreateStep))?.format('YYYY-MM-DD HH:mm'),
Copy link
Contributor

Choose a reason for hiding this comment

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

let's add helper in src/utils to format dates in one place. This helper will be used here and in formatDateTime function.


let component =
currentSchemaData?.PathType && pathTypeToComponent[currentSchemaData.PathType]?.();
// show SubType if it's not EPathSubTypeEmpty
Copy link
Contributor

Choose a reason for hiding this comment

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

lets remove obvious comments

const overview: InfoViewerItem[] = [];

// for any schema type
overview.push({label: 'Type', value: PathType?.replace(/^EPathType/, '')});
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add all labels with i18n

if (PathType === EPathType.EPathTypeExtSubDomain) {
overview.push({
label: 'Paths count',
value: PathDescription?.DomainDescription?.PathsInside?.length,
Copy link
Contributor

Choose a reason for hiding this comment

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

in the types PathsInside is a string, it seems that counting it's length is incorrect

});
overview.push({
label: 'Shards count',
value: PathDescription?.DomainDescription?.ShardsInside?.length,
Copy link
Contributor

Choose a reason for hiding this comment

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

in the types ShardsInside is a string, it seems that counting it's length is incorrect


const value = pqGroup?.PQTabletConfig?.PartitionConfig?.LifetimeSeconds;
if (value) {
const hours = (value / HOUR_IN_SECONDS).toFixed(2);
Copy link
Contributor

Choose a reason for hiding this comment

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

let's move this calculation to function


// verbose mapping to guarantee a correct render for new path types
// TS will error when a new type is added but not mapped here
const pathTypeToComponent: Record<EPathType, (() => React.ReactNode) | undefined> = {
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think about not to delete this mapping? I think it's rather useful when add a new type.
In the past it was a headache to remember all places where we need to add info about new type.

Copy link
Contributor Author

@walborn walborn Jun 27, 2024

Choose a reason for hiding this comment

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

For old version we are creating a new component for any type separately. But I've rewrote the logic to have common info and adding addition info for certain type.

May be it is possible to rewrite with pathTypeToInfo function with Record<>, but I don't understand the meaning of this

@walborn walborn linked an issue Jun 28, 2024 that may be closed by this pull request
@walborn walborn merged commit ed46a5f into main Jun 28, 2024
4 checks passed
@walborn walborn deleted the fix/overview-906 branch June 28, 2024 14:23
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.

rework overview pane in schema browser
2 participants