(feat) add repo metadata to repo root page#50607
Conversation
|
Codenotify: Notifying subscribers in CODENOTIFY files for diff 6595172...fe7eb42.
|
|
Codenotify: Notifying subscribers in OWNERS files for diff 6595172...fe7eb42. No notifications. |
Bundle size report 📦
Look at the Statoscope report for a full comparison between the commits fe7eb42 and 6595172 or learn more. Open explanation
|
camdencheek
left a comment
There was a problem hiding this comment.
Two small comments:
- Is that color actually used elsewhere in the app? It's a little bit jarring 😄 Also, because it stands out so much, I think it emphasizes those badges more than is probably desirable.
- How does this handle many pieces of metadata?
Leaving the code review to someone more qualified 🙂
Agreed that we probably need a proper design for this feature, but this looks like a good pre-alpha step forward. I'm not sure using the badges is the right approach. Also, I have no idea how to distinguish metadata related to ownership vs something else. Having just one layer of key-value pairs of strings might not cut it. |
There was a problem hiding this comment.
You can instead use one <Badge with 2 children and then style just the background of the one you need to change the colour of, so something like:
| <span className="d-flex align-items-center justify-content-center" key={`${key}:${value}`}> | |
| <Badge small={small} variant="info" className={classNames({ [styles.repoMetadataKey]: value })}> | |
| {key} | |
| </Badge> | |
| <Badge small={small} variant="secondary" className={styles.repoMetadataValue}> | |
| {value} | |
| </Badge> | |
| </span> | |
| <Badge small={small} variant="secondary" className={styles.repoMetadataKey} key={`${key}:${value}`}> | |
| <span className="key">{key}<span> | |
| <span className="value">{value}</span> | |
| </Badge> |
Looks cleaner and IMO is a better resulting HTML structure. You also do not need to touch border radius at all this way.
There was a problem hiding this comment.
I don't think this is better than current version, as it will require resetting padding of inner child and setting bg color of one of them. I think using badge with variants (info, secondary) is more explicit.
There was a problem hiding this comment.
I'm also not a fan of this markup, but mostly because I think this is confusing for accessibility. How is a screen reader user meant to know that one value is the key and the next one is the value? I think we need to rethink this; eg. adding some hidden text to add key/value labels.
There was a problem hiding this comment.
Good point, I've updated to use description list HTML tags, as well as added aria attributes. Would appreciate the feedback.
There was a problem hiding this comment.
Awesome solution, love this!
There was a problem hiding this comment.
Why don't we let the RepoMetadata deal with the structure of keyValuePairs like before? What is the benefit of doing Object.entries here vs in the RepoMetadata component?
There was a problem hiding this comment.
I changed it for easier handling of the GQL response of keyValuePairs, which is {key: 'key', value: 'value'}[] format. So with the previous structure,
-
- we had to convert it to props format like
Object.fromEntries(repo.keyValuePairs.map(({ key, value }) => [key, value]))}
- we had to convert it to props format like
-
- and then inside
RepoMetadataconvert back to tuples asObject.entries(keyValuePairs)
- and then inside
But let me know if you think previous type/version is better, we can revert back to it.
There was a problem hiding this comment.
I suggest to rename this at graphql API level in a separate PR to something more meaningful like metadata.
keyValuePairs explains nothing.
There was a problem hiding this comment.
Good point. Currently, it is being used by src cli and probably by customers. I will clarify how safe to rename this and, based on that follow-up.
ea4ab01 to
f972c65
Compare
…eePage test refactor(TreePage.tsx): extract repository metadata into a separate component and wrap it in a div to fix alignment issue refactor(PageHeader.tsx): remove unused rootClassName prop and its usage in the component
198e572 to
2e4709f
Compare
…eyValuePairs array to Repository type object
Part of https://github.com/sourcegraph/pr-faqs/issues/96. Follow-up https://github.com/sourcegraph/sourcegraph/pull/50567.
This PR adds repo metadata to repo root page
Test plan
sg startrepository-metadatafeature flagaddRepoKeyValuePairAPIScreenshots
isFork=trueApp preview:
Check out the client app preview documentation to learn more.