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

fix(plg): Cody Pro routes conditions & add links to the user nav dropdown #63378

Merged
merged 9 commits into from
Jun 20, 2024

Conversation

taras-yemets
Copy link
Contributor

@taras-yemets taras-yemets commented Jun 20, 2024

Closes https://github.com/sourcegraph/sourcegraph/issues/63264

  1. Adds Cody Pro section to the user nav dropdown on dotcom:
    • team admins have links to "cody/subscription/manage" and "cody/team/manage" pages
    • team members have only link only to the "cody/team/manage" page
  2. Makes subscription management page only available for team admins. If team members try to navigate this page by changing the URL, they will be redirected to the "/cody/manage" page.
    • Makes "Manage subscription" link on the "/cody/manage" available only for the team admins (previously - any Pro user)
  3. Lifts QueryClientProvider (wrapper around react-query ClientProvider higher in the component tree so that Cody Pro API query and mutations can be used not only on the Cody Pro routes.

Design

Role Screenshot
Admin Screenshot 2024-06-20 at 12 57 13Screenshot 2024-06-20 at 13 10 28
Member Screenshot 2024-06-20 at 12 56 50Screenshot 2024-06-20 at 13 09 51

Test plan

  • Start Sourcegraph instance in dotcom mode
    • sign in as a Cody Pro team admin
      • ensure that "Manage subscription" and "Manage team" links are present in the user nav dropdown
      • ensure "/cody/manage" page has "Manage subscription" link
    • sign in as a Cody Pro team member (not admin)
      • ensure "Manage team" link is present in the user nav dropdown
      • navigate to "/cody/subscription/manage/ page by changing the URL
      • ensure you've been redirected to the "/cody/manage" page
      • ensure "/cody/manage" page doesn't have "Manage subscription" link
  • start Sourcegraph in the enterprise mode
    • ensure the mentioned links are not rendered

Changelog

@cla-bot cla-bot bot added the cla-signed label Jun 20, 2024
@taras-yemets taras-yemets requested a review from a team June 20, 2024 09:40
@taras-yemets taras-yemets requested a review from rrhyne June 20, 2024 10:13
Copy link
Contributor

@vdavid vdavid left a comment

Choose a reason for hiding this comment

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

Nice, it looks completely right to me.

@taras-yemets taras-yemets changed the title feat(plg): add Cody Pro links to the user nav fix(plg): Cody Pro routes conditions & add links to the user nav dropdown Jun 20, 2024
@taras-yemets taras-yemets enabled auto-merge (squash) June 20, 2024 10:15
@taras-yemets taras-yemets merged commit 5cf81e0 into main Jun 20, 2024
11 checks passed
@taras-yemets taras-yemets deleted the ty/add-cody-pro-links-to-user-nav branch June 20, 2024 11:12
taras-yemets added a commit that referenced this pull request Jun 21, 2024
taras-yemets added a commit that referenced this pull request Jun 21, 2024
…nav dropdown (#63378) (#63424)

This reverts commit 5cf81e0
(https://github.com/sourcegraph/sourcegraph/pull/63378).

This PR intorduced a call to the SSC backend via proxy on the
Sourcegraph backend (see `cmd/frontend/internal/ssc/ssc_proxy.go`). It
appeared that proxy is not properly configured on dotcom, causing
requests to fail with 503 "proxy not configured" errors.
Reverting this PR until we fix the configuration.

<!-- 💡 To write a useful PR description, make sure that your description
covers:
- WHAT this PR is changing:
    - How was it PREVIOUSLY.
    - How it will be from NOW on.
- WHY this PR is needed.
- CONTEXT, i.e. to which initiative, project or RFC it belongs.

The structure of the description doesn't matter as much as covering
these points, so use
your best judgement based on your context.
Learn how to write good pull request description:
https://www.notion.so/sourcegraph/Write-a-good-pull-request-description-610a7fd3e613496eb76f450db5a49b6e?pvs=4
-->


## Test plan
- CI
<!-- All pull requests REQUIRE a test plan:
https://docs-legacy.sourcegraph.com/dev/background-information/testing_principles
-->


## Changelog

<!--
1. Ensure your pull request title is formatted as: $type($domain): $what
2. Add bullet list items for each additional detail you want to cover
(see example below)
3. You can edit this after the pull request was merged, as long as
release shipping it hasn't been promoted to the public.
4. For more information, please see this how-to
https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c?

Audience: TS/CSE > Customers > Teammates (in that order).

Cheat sheet: $type = chore|fix|feat $domain:
source|search|ci|release|plg|cody|local|...
-->

<!--
Example:

Title: fix(search): parse quotes with the appropriate context
Changelog section:

## Changelog

- When a quote is used with regexp pattern type, then ...
- Refactored underlying code.
-->
taras-yemets added a commit that referenced this pull request Jun 25, 2024
…down (#63378)

Closes https://github.com/sourcegraph/sourcegraph/issues/63264

1. Adds Cody Pro section to the user nav dropdown on dotcom:
- team admins have links to "cody/subscription/manage" and
"cody/team/manage" pages
   - team members have only link only to the "cody/team/manage" page
2. Makes subscription management page only available for team admins. If
team members try to navigate this page by changing the URL, they will be
redirected to the "/cody/manage" page.
- Makes "Manage subscription" link on the "/cody/manage" available only
for the team admins (previously - any Pro user)
3. Lifts `QueryClientProvider` (wrapper around react-query
`ClientProvider` higher in the component tree so that Cody Pro API query
and mutations can be used not only on the Cody Pro routes.


[Design](https://www.figma.com/design/FMSdn1oKccJRHQPgf7053o/Cody-PLG-GA?node-id=5351-19126&t=LfNQR7vUCJhlNvyT-4)

| Role | Screenshot |
|--|--|
|Admin|<img width="1605" alt="Screenshot 2024-06-20 at 12 57 13"
src="https://github.com/sourcegraph/sourcegraph/assets/25318659/e7b995fd-4322-4f7f-86bb-c7027cacd644"><img
width="1605" alt="Screenshot 2024-06-20 at 13 10 28"
src="https://github.com/sourcegraph/sourcegraph/assets/25318659/84be111c-76e2-4b14-9b73-ebdd5f8cbb9a">|
|Member|<img width="1605" alt="Screenshot 2024-06-20 at 12 56 50"
src="https://github.com/sourcegraph/sourcegraph/assets/25318659/aefd8b3b-29fe-4957-87ee-b493eb489922"><img
width="1605" alt="Screenshot 2024-06-20 at 13 09 51"
src="https://github.com/sourcegraph/sourcegraph/assets/25318659/8209e7a0-4deb-4681-9f6b-3cfde8110842">|




<!-- 💡 To write a useful PR description, make sure that your description
covers:
- WHAT this PR is changing:
    - How was it PREVIOUSLY.
    - How it will be from NOW on.
- WHY this PR is needed.
- CONTEXT, i.e. to which initiative, project or RFC it belongs.

The structure of the description doesn't matter as much as covering
these points, so use
your best judgement based on your context.
Learn how to write good pull request description:
https://www.notion.so/sourcegraph/Write-a-good-pull-request-description-610a7fd3e613496eb76f450db5a49b6e?pvs=4
-->


## Test plan
- Start Sourcegraph instance in dotcom mode
  - sign in as a Cody Pro team admin 
- ensure that "Manage subscription" and "Manage team" links are present
in the user nav dropdown
    - ensure "/cody/manage" page has "Manage subscription" link
  - sign in as a Cody Pro team member (not admin)
    - ensure "Manage team" link is present in the user nav dropdown
    - navigate to "/cody/subscription/manage/ page by changing the URL
    - ensure you've been redirected to the "/cody/manage" page
    - ensure "/cody/manage" page doesn't have "Manage subscription" link
- start Sourcegraph in the enterprise mode
  - ensure the mentioned links are not rendered
<!-- All pull requests REQUIRE a test plan:
https://docs-legacy.sourcegraph.com/dev/background-information/testing_principles
-->


## Changelog

<!--
1. Ensure your pull request title is formatted as: $type($domain): $what
2. Add bullet list items for each additional detail you want to cover
(see example below)
3. You can edit this after the pull request was merged, as long as
release shipping it hasn't been promoted to the public.
4. For more information, please see this how-to
https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c?

Audience: TS/CSE > Customers > Teammates (in that order).

Cheat sheet: $type = chore|fix|feat $domain:
source|search|ci|release|plg|cody|local|...
-->

<!--
Example:

Title: fix(search): parse quotes with the appropriate context
Changelog section:

## Changelog

- When a quote is used with regexp pattern type, then ...
- Refactored underlying code.
-->
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.

Put "Manage subscription" and "Manage team" links to the submenu on the right
2 participants