-
Notifications
You must be signed in to change notification settings - Fork 3k
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
refactor(ui): refactor capitalization of platform name and sub types #7099
refactor(ui): refactor capitalization of platform name and sub types #7099
Conversation
a039529
to
f1092ef
Compare
@@ -197,9 +198,9 @@ export class ChartEntity implements Entity<Chart> { | |||
getLineageVizConfig = (entity: Chart) => { | |||
return { | |||
urn: entity.urn, | |||
name: entity.properties?.name || '', | |||
name: entity.properties?.name || entity.urn, |
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.
Thank you!
@@ -62,7 +61,6 @@ export const ChartPreview = ({ | |||
snippet?: React.ReactNode | null; | |||
}): JSX.Element => { | |||
const entityRegistry = useEntityRegistry(); | |||
const capitalizedPlatform = capitalizeFirstLetter(platform); |
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.
Thank you
@@ -62,7 +63,7 @@ export const Preview = ({ | |||
externalUrl?: string | null; | |||
}): JSX.Element => { | |||
const entityRegistry = useEntityRegistry(); | |||
const typeName = (subTypes?.typeNames?.length && subTypes?.typeNames[0]) || 'Container'; | |||
const typeName = capitalizeFirstLetterOnly(subTypes?.typeNames?.[0]) || 'Container'; |
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.
Minor: Will this work when
subTypes?.typeNames is an empty array?. If not, seems a bit worrisome to remove the first check.
const externalUrl = entityData?.externalUrl || undefined; | ||
const entityCount = entityData?.entityCount; | ||
const isCompact = React.useContext(CompactContext); | ||
|
||
const entityName = entityData?.name; | ||
const subType = | ||
(entityData?.subTypes?.typeNames?.length || 0) > 0 ? entityData?.subTypes?.typeNames![0] : undefined; | ||
const subType = capitalizeFirstLetterOnly(entityData?.subTypes?.typeNames?.[0]) || undefined; |
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.
Is it safe to remove this check? entityData?.subTypes?.typeNames?.length
return entityData?.entityTypeOverride || entityTypeCased || ''; | ||
return ( | ||
entityData?.entityTypeOverride || | ||
capitalizeFirstLetterOnly(entityData?.subTypes?.typeNames?.[0]) || |
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.
is it safe to remove the check entityData?.subTypes?.typeNames?.length
What if type names does not exist?
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 see that the method can deal with undefined), but I think the other case is when the array exists, but is empty (technically a possible state)
)) || ( | ||
<Typography.Text> | ||
{record.platform.properties?.displayName || | ||
capitalizeFirstLetterOnly(record.platform.name)} |
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.
Thank you for adding this!
@@ -71,7 +72,7 @@ export const singularizeCollectionName = (collectionName: string): string => { | |||
}; | |||
|
|||
export function getPlatformName(entityData: GenericEntityProperties | null) { | |||
return entityData?.platform?.properties?.displayName || entityData?.platform?.name; | |||
return entityData?.platform?.properties?.displayName || capitalizeFirstLetterOnly(entityData?.platform?.name); |
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.
Thank you!!
@@ -266,7 +266,7 @@ export const IngestionSourceList = () => { | |||
message.success({ content: 'Removed ingestion source.', duration: 2 }); | |||
const newRemovedUrns = [...removedUrns, urn]; | |||
setRemovedUrns(newRemovedUrns); | |||
setTimeout(function () { | |||
setTimeout(() => { |
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.
Not sure why these changes are strictly necessary, but we will leave them
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.
Oh, I forgot to mention it: ESLint reported it as an unexpected unnamed function...everywhere else in the code an arrow function was used, so I changed it.
if (node.data.siblingPlatforms && !isHideSiblingMode) { | ||
platformDisplayText = node.data.siblingPlatforms | ||
.map((platform) => platform.properties?.displayName || platform.name) | ||
.map((platform) => platform.properties?.displayName || capitalizeFirstLetterOnly(platform.name)) |
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.
Thank you!
@@ -32,7 +32,7 @@ describe('LineageEntityView', () => { | |||
it('should not render a divider if there is no platform name', () => { | |||
const datasetNoPlatformName = { | |||
...dataset1, | |||
platform: { ...dataset1.platform, properties: { displayName: '' } }, | |||
platform: { ...dataset1.platform, name: '', properties: { displayName: '' } }, |
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.
Why empty string ?
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.
Before the changes in LinageEntityView.tsx only the displayName of the platform was used, therefore the name of the platform must also be set to an empty string (or undefined) for this test to be successful. If I think about it again, in theory we could also remove this test completely, because the platform name should never be empty, however as the platform in GenericEntityProperties is optional it is possible that getPlatformName returns undefined...in this case the test has somehow the right to exist...
const platformName = | ||
genericProps?.platform?.properties?.displayName || | ||
capitalizeFirstLetter(genericProps?.platform?.name); | ||
const platformName = getPlatformName(genericProps); |
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.
Amazing!
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.
So firstly, I in large part agree with your assessment.
- Platform Name should only be capitalized (first letter) if there is not display name set.
- Sub Type name should only be capitalized for the first letter (in all cases)
It seems that this PR covers it!
I think there's just one case that was sometimes previously covered but now has been removed in some places: checking for the presence of the subTypes array itself.
Other than this, I think this PR is largely ready go. I am very grateful you took the time to do this!
The length-check for the typeNames array is not neccessary, because it is fine to access an index of an array which does not exist (in JavaScript/TypeScript), the resulting value is then undefined and the right-hand value - the entity type - of the OR will be used. The case that typeNames array does not exist at all is covered using the optional chaining (then the resulting value is also undefined) and besides that I think it is safe to assume that typeNames is an array if it is not undefined, because that's how it is defined in the schema. |
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.
LGTM - Thank you for adding!
One more thing! Looks like this has caused a smoke test to fail.. Can you change |
Once we have that small change, we are good to merge. Thanks |
a10aa7e
to
fd9c0bf
Compare
fd9c0bf
to
e573d22
Compare
I was really surprised and actually can't believe that no one else has noticed it yet and asked about it on Slack, but the capitalization of the platform names (and the sub types) is currently inconsistent: When you navigate through the entities, lineage, etc. sometimes the platform names are correctly capitalized and sometimes not. Therefore, I have took the time and checked all occurrences of capitalizeFirstLetter and capitalizeFirstLetterOnly in relation to the platform name and the sub types:
P.S.: The removal of the meta-favicon.ico has nothing to do with the capitalization, but I think it was added by mistake, because it is not used anywhere, therefore I have removed it.
Checklist