sourcegraph/cmd
Quinn Slack 0021f95d6c
remove Cody "upsells"—and all Cody links if Cody is disabled (#63430)
At a high level, we don't want to show annoying ads/upsells for Cody
that are not useful. And if Cody is disabled, we don't want to show
*any* links to Cody.

### Detailed desired behavior

- Dotcom
  - Navbar
    - Unauthed: "Cody" single link to /cody (marketing page)
- Authed: "Cody" dropdown with "Dashboard" (/cody/manage) and "Chat"
(/cody/chat)
  - Routes
    - /cody: always the marketing page
- /cody/manage: requires sign-in, shows Cody PLG subscription status for
the user (Free plan is auto-opted-into by default)
    - /cody/chat: requires sign-in
- Enterprise with Cody enabled on instance
  - Navbar
- Cody NOT enabled for current user: "Cody" single link to
/cody/dashboard
- Cody enabled for current user: "Cody" dropdown with "Dashboard"
(/cody/manage) and "Chat" (/cody/chat)
  - Routes
- /cody: this link should not be present anywhere, but redirect to
/cody/dashboard
- /cody/manage: informational page, with editor/web links for
Cody-enabled users and a "contact admin to get access" message for
Cody-disabled users
- /cody/chat: chat for Cody-enabled users, redirect to /cody/manage for
Cody-disabled users
- Enterprise with Cody NOT enabled on instance (`"cody.enabled": false`
in site config)
  - Navbar: no Cody link or dropdown
  - Routes: all Cody routes 404
- All
  - Do not show a Cody upsell on the /search page

This is an example of what we will KEEP for users on instances with Cody
enabled but who do not themselves yet have access to Cody. This is
useful because it informs users how to get access to Cody, and
presumably their site admin wants people to request it who want to use
it.


![image](https://github.com/sourcegraph/sourcegraph/assets/1976/c2adb086-44ec-4240-ad44-95981763fb72)


Fixes
https://linear.app/sourcegraph/issue/SRCH-529/hide-cody-ai-tab-and-cody-upsell-if-cody-is-not-enabled

### Unexpected code changes needed

This ended up being a much bigger change than I expected because I found
error-prone code that needed cleaning up:
    
- Improve how we determine if Cody is enabled in the frontend code.
Previously, we checked the license features in some places,
`cody.enabled` site config in others, and the user's current RBAC
permissions for Cody in yet others. The most error-prone was checking
the license features, since a license may entitle the instance to Cody
but the site admin may still choose to disable it. There were no places
in the frontend code where checking the license's entitlements was
actually correct, so I changed everything to checking either
`window.context.codyEnabledOnInstance` or
`window.context.codyEnabledForCurrentUser`.
- Did the same for `window.context.codeSearchEnabledOnInstance` for
symmetry.
- Removed "helper" functions that just checked 1 or 2 boolean values on
`window.context` related to this, in favor of accessing `window.context`
directly. Globals aren't great, and we should use React context or
something similar, but now that the JSContext has the right fields
(i.e., enabled instead of licensed), it's simpler and there is no need
for helper functions.
- Removed prop drilling of the `licenseFeatures` that was unnecessary
since these values are available in globals and were being set from
globals at some arbitrary point in the React component hierarchy anyway.
- Updated the GlobalNavbar test snapshots.

## Test plan

Run in 3 modes: (1) dotcom mode, (2) `"cody.enabled": false` in site
config, (3) normal `sg start`.

## Changelog

- When Cody is disabled in site config (with `"cody.enabled": false`),
all links and UI elements about Cody are hidden from all users.
Previously, when Cody was disabled, users would see some links informing
them about Cody.
2024-06-27 05:29:54 +00:00
..
appliance support fast, simple sg start single-program-experimental-blame-sqs for local dev (#63435) 2024-06-24 21:12:47 +00:00
batcheshelper bazel: transcribe test ownership to bazel tags (#62664) 2024-05-16 15:51:16 +01:00
blobstore bazel: transcribe test ownership to bazel tags (#62664) 2024-05-16 15:51:16 +01:00
bundled-executor bazel: transcribe test ownership to bazel tags (#62664) 2024-05-16 15:51:16 +01:00
cody-gateway Gateway: forward X-Fireworks-Genie header from client (#63460) 2024-06-25 02:49:26 +00:00
cody-gateway-config config(cody): Various fixes and updating the naming rules for ModelConfig resource IDs (#63436) 2024-06-24 10:37:49 -07:00
embeddings lib/background: upgrade Routine interface with context and errors (#62136) 2024-05-24 10:04:55 -04:00
enterprise-portal feat/enterpriseportal: initialize subscriptions tables (#63453) 2024-06-26 17:13:02 -07:00
executor chore/deps: upgrade grpc, prometheus/common (#63328) 2024-06-19 09:55:44 -04:00
executor-kubernetes bazel: transcribe test ownership to bazel tags (#62664) 2024-05-16 15:51:16 +01:00
frontend remove Cody "upsells"—and all Cody links if Cody is disabled (#63430) 2024-06-27 05:29:54 +00:00
gitserver dotcom: Remove on-demand cloning of repositories (#63321) 2024-06-26 14:53:14 -07:00
loadtest chore(bazel): update ownership tags to increase coverage (#63001) 2024-05-31 14:10:29 +00:00
migrator chore(ci): conditionally stamp genrules (#63204) 2024-06-12 15:04:43 +02:00
msp-example msp/runtime: split contract into JobContract and ServiceContract (#63494) 2024-06-26 19:46:10 +00:00
pings msp/runtime: split contract into JobContract and ServiceContract (#63494) 2024-06-26 19:46:10 +00:00
precise-code-intel-worker chore: Change errors.HasType to respect multi-errors (#63024) 2024-06-06 13:02:14 +00:00
repo-updater dotcom: Remove on-demand cloning of repositories (#63321) 2024-06-26 14:53:14 -07:00
searcher bazel: transcribe test ownership to bazel tags (#62664) 2024-05-16 15:51:16 +01:00
server feat/bazel: //cmd/{frontend,server} targets that don't include client bundle for backend integration tests (#62877) 2024-05-28 14:32:48 +01:00
sourcegraph support fast, simple sg start single-program-experimental-blame-sqs for local dev (#63435) 2024-06-24 21:12:47 +00:00
symbols gitserver: Framework to support integration testing against gitserver (#62801) 2024-06-07 17:01:12 +02:00
syntactic-code-intel-worker Syntactic indexing: enqueuer and scheduler (#62485) 2024-05-31 10:25:30 +01:00
telemetry-gateway msp/runtime: split contract into JobContract and ServiceContract (#63494) 2024-06-26 19:46:10 +00:00
worker dotcom: Remove on-demand cloning of repositories (#63321) 2024-06-26 14:53:14 -07:00
README.md Reminder to keep architecture diagram in-sync (#36869) 2022-06-08 19:40:36 -07:00

This directory contains Sourcegraph services and binaries.

When a services is added, removed, or when a service's dependencies change, update our architecture diagram.