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

UI: Use changelist ID in URL for browsing changelists#53253

Merged
indradhanush merged 17 commits into
mainfrom
ig/changelists-ui
Jun 15, 2023
Merged

UI: Use changelist ID in URL for browsing changelists#53253
indradhanush merged 17 commits into
mainfrom
ig/changelists-ui

Conversation

@indradhanush

@indradhanush indradhanush commented Jun 9, 2023

Copy link
Copy Markdown
Contributor

🎥 Check out the Loom recording: https://www.loom.com/share/f16f976175614c43ba1d77366b24f756

Blocked by #52937. Part of #40330.

Test plan

  • Tested manually
  • Existing storybooks should cover for UI regressions since this is a URL change

@cla-bot cla-bot Bot added the cla-signed label Jun 9, 2023
@indradhanush indradhanush marked this pull request as ready for review June 9, 2023 16:03
@indradhanush indradhanush requested a review from a team June 9, 2023 16:03
@indradhanush indradhanush self-assigned this Jun 9, 2023
@indradhanush indradhanush added the perforce-changelists Issues around Changelist Ids for Perforce depots label Jun 9, 2023
@sourcegraph-bot

sourcegraph-bot commented Jun 9, 2023

Copy link
Copy Markdown
Contributor

📖 Storybook live preview

@pjlast pjlast left a comment

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.

Some cleanup required :D

Comment thread client/web/src/repo/commit/RepositoryCommitPage.tsx Outdated
Comment thread client/web/src/repo/commit/RepositoryCommitPage.tsx Outdated
Comment thread client/web/src/repo/commits/GitCommitNode.tsx Outdated
Comment thread client/web/src/repo/commits/GitCommitNode.tsx Outdated
Comment thread client/web/src/repo/commits/RepositoryCommitsPage.tsx Outdated
Comment thread client/web/src/repo/commits/RepositoryCommitsPage.tsx Outdated
Comment thread client/web/src/repo/repoRevisionContainerRoutes.tsx Outdated
Comment thread client/web/src/util/url.ts Outdated
Comment thread client/web/src/util/url.ts Outdated
@indradhanush indradhanush force-pushed the ig/repo-commits-changelists-gql-api branch from 74ccd94 to 232cf3f Compare June 13, 2023 13:18
Base automatically changed from ig/repo-commits-changelists-gql-api to main June 13, 2023 13:56

@sashaostrikov sashaostrikov left a comment

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.

Man, great work! 🎉🎉🎉
Some cleanups are needed indeed, but nothing critical.

Btw, I haven't found the PetriJS dependency, but it obviously works and prints the console logs in PR comments! :mindblown:

Comment thread client/web/src/repo/commit/RepositoryCommitPage.tsx Outdated
Comment thread client/web/src/repo/commit/RepositoryCommitPage.tsx Outdated
Comment thread client/web/src/repo/commit/RepositoryCommitPage.tsx 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.

Do you need to support both undefined and null? TBH, I doubt it, I think one of them should be enough, right?

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.

Nope, the editor complains with only one. My understanding is because its slightly different queries which lead to slightly different data structures that make use of this component.

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.

Did you try removing null?
I believe having commit?: GitCommitFields is enough, I took a look at usages and we don't pass null anywhere. It's either an object or undefined.

Can you try it?

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.

Yep. RepositoryCommitPage complains when I remove null and RepositoryChangelistPage complains when I remove undefined.

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.

and that's valid :) because commit can be null in RepositoryCommitPage.

What you can do, is ensure that your commit constant is only either an object or undefined, but never null:

    const commit = useMemo(
        () => (data?.node?.__typename === 'Repository' ? data?.node?.commit || undefined : undefined),
        [data]
    )

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.

Suggested change
onDidUpdateExternalLinks: (externalLinks: ExternalLinkFields[] | undefined) => void
onDidUpdateExternalLinks: (externalLinks?: ExternalLinkFields[]) => void

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.

onDidUpdateExternalLinks is called with undefined which makes this necessary.

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.

yeah, I just changed the code so that ?: is used which is the same thing as | undefined, but more concise

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.

Ah. I missed the ?: in your suggestion. I will test it locally and apply the fix.

Comment thread client/web/src/repo/commit/backend.ts Outdated
Comment thread client/web/src/util/url.ts Outdated
Comment thread cmd/frontend/graphqlbackend/perforce_changelist.go 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.

hmm, did you come across the case when Commit was called more than once for a given query. i.e. do we really need once here? 🤔

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.

Not yet for this API endpoint, but because this is an expensive operation it is a good idea to make sure we don't repeat this. The RepositoryResolver does the same currently.

Sidenote: The backend changes were introduced in #52937 and I didn't do the PR stacking correctly I think which is why it showed up here once that PR was merged. I've fixed it now in this PR by dropping those redundant commits and rebasing off main.

Comment thread internal/database/repo_commits_changelists.go Outdated
@indradhanush indradhanush force-pushed the ig/changelists-ui branch 2 times, most recently from 199246f to f5eb3b4 Compare June 13, 2023 15:38

@sashaostrikov sashaostrikov left a comment

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.

LGTM, thanks for addressing the comments 👍🏻

@indradhanush indradhanush enabled auto-merge (squash) June 15, 2023 08:52
@indradhanush indradhanush requested a review from pjlast June 15, 2023 08:53

@pjlast pjlast left a comment

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!

Comment on lines +155 to +159
const pageTitle = commit
? commit.subject
: repo.sourceType === RepositoryType.PERFORCE_DEPOT
? `Changelist ${props.changelistID}`
: `Commit ${props.revspec}`

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 am not a fan of nested ternaries like this, would prefer some boomer if-statements, but I also know this is just what React looks like so feel free to ignore.

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.

Will fix in a follow up.

@indradhanush indradhanush merged commit 2131cb0 into main Jun 15, 2023
@indradhanush indradhanush deleted the ig/changelists-ui branch June 15, 2023 09:06
ErikaRS pushed a commit that referenced this pull request Jun 22, 2023
Co-authored-by: Peter Guy <peter.guy@sourcegraph.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla-signed perforce-changelists Issues around Changelist Ids for Perforce depots

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants