Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

(feat) add repo metadata to repo root page#50607

Merged
erzhtor merged 7 commits into
mainfrom
erzhtor/add-repo-metadata-to-repo-root-page
Apr 18, 2023
Merged

(feat) add repo metadata to repo root page#50607
erzhtor merged 7 commits into
mainfrom
erzhtor/add-repo-metadata-to-repo-root-page

Conversation

@erzhtor

@erzhtor erzhtor commented Apr 13, 2023

Copy link
Copy Markdown
Contributor

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 start
  • Enable repository-metadata feature flag
  • Add some key value pairs through API (currently no UI for adding) GQL mutation addRepoKeyValuePair API
  • Open repo root page

Screenshots

Description Screenshot
Root page image
Root page with isFork=true image

App preview:

Check out the client app preview documentation to learn more.

@erzhtor erzhtor requested review from a team, camdencheek, limitedmage and rrhyne April 13, 2023 17:45
@erzhtor erzhtor self-assigned this Apr 13, 2023
@cla-bot cla-bot Bot added the cla-signed label Apr 13, 2023
@sourcegraph-bot

sourcegraph-bot commented Apr 13, 2023

Copy link
Copy Markdown
Contributor

Codenotify: Notifying subscribers in CODENOTIFY files for diff 6595172...fe7eb42.

Notify File(s)
@fkling client/branded/src/search-ui/components/RepoMetadata.module.scss
client/branded/src/search-ui/components/RepoMetadata.story.tsx
client/branded/src/search-ui/components/RepoMetadata.tsx
client/branded/src/search-ui/components/RepoSearchResult.tsx
client/branded/src/search-ui/components/SearchResult.module.scss
client/branded/src/search-ui/components/index.ts
@limitedmage client/branded/src/search-ui/components/RepoMetadata.module.scss
client/branded/src/search-ui/components/RepoMetadata.story.tsx
client/branded/src/search-ui/components/RepoMetadata.tsx
client/branded/src/search-ui/components/RepoSearchResult.tsx
client/branded/src/search-ui/components/SearchResult.module.scss
client/branded/src/search-ui/components/index.ts

@sourcegraph-bot

sourcegraph-bot commented Apr 13, 2023

Copy link
Copy Markdown
Contributor

Codenotify: Notifying subscribers in OWNERS files for diff 6595172...fe7eb42.

No notifications.

@sg-e2e-regression-test-bob

sg-e2e-regression-test-bob commented Apr 13, 2023

Copy link
Copy Markdown

Bundle size report 📦

Initial size Total size Async size Modules
0.00% (0.00 kb) 0.05% (+6.65 kb) 0.06% (+6.65 kb) 0.13% (+1) 🔺

Look at the Statoscope report for a full comparison between the commits fe7eb42 and 6595172 or learn more.

Open explanation
  • Initial size is the size of the initial bundle (the one that is loaded when you open the page)
  • Total size is the size of the initial bundle + all the async loaded chunks
  • Async size is the size of all the async loaded chunks
  • Modules is the number of modules in the initial bundle

@camdencheek camdencheek left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Two small comments:

  1. 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.
  2. How does this handle many pieces of metadata?

Leaving the code review to someone more qualified 🙂

@kopancek

Copy link
Copy Markdown
Contributor

Two small comments:

  1. 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.
  2. 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.

Comment on lines 20 to 35

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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:

Suggested change
<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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point, I've updated to use description list HTML tags, as well as added aria attributes. Would appreciate the feedback.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Awesome solution, love this!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I changed it for easier handling of the GQL response of keyValuePairs, which is {key: 'key', value: 'value'}[] format. So with the previous structure,

    1. we had to convert it to props format like Object.fromEntries(repo.keyValuePairs.map(({ key, value }) => [key, value]))}
    1. and then inside RepoMetadata convert back to tuples as Object.entries(keyValuePairs)

But let me know if you think previous type/version is better, we can revert back to it.

@erzhtor erzhtor requested a review from kopancek April 14, 2023 06:46
Comment thread client/web/src/repo/backend.ts Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I suggest to rename this at graphql API level in a separate PR to something more meaningful like metadata.

keyValuePairs explains nothing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Comment thread client/wildcard/src/components/PageHeader/PageHeader.tsx Outdated
@erzhtor erzhtor force-pushed the erzhtor/add-repo-metadata-to-repo-root-page branch from ea4ab01 to f972c65 Compare April 17, 2023 16:19
Comment thread client/wildcard/src/components/PageHeader/PageHeader.tsx Outdated
@erzhtor erzhtor force-pushed the erzhtor/add-repo-metadata-to-repo-root-page branch from 198e572 to 2e4709f Compare April 18, 2023 07:24
…eyValuePairs array to Repository type object
@erzhtor erzhtor merged commit 2967c96 into main Apr 18, 2023
@erzhtor erzhtor deleted the erzhtor/add-repo-metadata-to-repo-root-page branch April 18, 2023 09:12
@erzhtor erzhtor mentioned this pull request Apr 18, 2023
6 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants