From da262c68b6eac1f0a45d3a466b5135eccd560501 Mon Sep 17 00:00:00 2001 From: Erik Seliger Date: Fri, 16 Jun 2023 03:35:58 +0200 Subject: [PATCH] Add enterprise UIs for cody enablement (#53360) This PR implements https://www.figma.com/file/ZpFPw0zZhVkCjrp68hPmA6/Enterprise-Cody-web-onboarding?type=design&node-id=0-1&t=sHIWi49gJ0ionqkp-0 for Cody enablement and simplifies the feature flags used to determine when which of these should show. We now simply look at if cody is enabled instead of multiple feature flags. Closes https://github.com/sourcegraph/sourcegraph/issues/53023 Closes https://github.com/sourcegraph/sourcegraph/issues/52546 ## Test plan Manually verified. --------- Co-authored-by: Rob Rhyne --- client/cody-ui/src/Chat.tsx | 16 +- client/cody-web/src/App.tsx | 1 + client/cody-web/src/Chat.tsx | 1 + client/cody/webviews/Chat.tsx | 4 + client/web/BUILD.bazel | 2 +- .../src/cody/chat/CodyChatPage.module.scss | 5 + client/web/src/cody/chat/CodyChatPage.tsx | 95 +++++-- .../cody/components/ChatUI/ChatUi.module.scss | 4 + .../web/src/cody/components/ChatUI/ChatUi.tsx | 58 +++- .../CodyMarketingPage.module.scss | 3 + .../CodyMarketingPage.story.tsx | 7 +- .../CodyMarketingPage/CodyMarketingPage.tsx | 266 ++++++++++++------ client/web/src/cody/isCodyEnabled.tsx | 14 + client/web/src/cody/search/CodySearchPage.tsx | 12 +- client/web/src/cody/sidebar/CodySidebar.tsx | 3 +- client/web/src/cody/sidebar/Provider.tsx | 2 +- client/web/src/cody/useCodyChat.tsx | 13 +- client/web/src/cody/useIsCodyEnabled.tsx | 73 ----- client/web/src/featureFlags/featureFlags.ts | 6 +- client/web/src/global/Notices.tsx | 6 +- client/web/src/integration/repository.test.ts | 3 +- .../src/marketing/toast/CodySurveyToast.tsx | 5 +- client/web/src/nav/GlobalNavbar.tsx | 19 +- .../__snapshots__/GlobalNavbar.test.tsx.snap | 41 +++ client/web/src/repo/RepoContainer.tsx | 64 ++--- client/web/src/repo/blob/BlobPage.tsx | 4 +- client/web/src/repo/blob/CodeMirrorBlob.tsx | 5 +- .../TryCodyWidget/TryCodyWidget.module.scss | 3 +- .../TryCodyWidget/TryCodyWidget.tsx | 55 +++- client/web/src/repo/tree/TreePage.test.tsx | 3 + client/web/src/repo/tree/TreePage.tsx | 4 +- client/web/src/site-admin/flags.ts | 2 - .../pages/SearchPage/SearchPageContent.tsx | 19 +- .../SearchPage/TryCodyCtaSection.module.scss | 12 +- .../pages/SearchPage/TryCodyCtaSection.tsx | 177 ++++++++---- client/web/src/util/constants.ts | 1 + 36 files changed, 651 insertions(+), 357 deletions(-) create mode 100644 client/web/src/cody/isCodyEnabled.tsx delete mode 100644 client/web/src/cody/useIsCodyEnabled.tsx diff --git a/client/cody-ui/src/Chat.tsx b/client/cody-ui/src/Chat.tsx index 2f850a2ac2f..90ec98bf78d 100644 --- a/client/cody-ui/src/Chat.tsx +++ b/client/cody-ui/src/Chat.tsx @@ -41,8 +41,10 @@ interface ChatProps extends ChatClassNames { setSuggestions?: (suggestions: undefined | []) => void needsEmailVerification?: boolean needsEmailVerificationNotice?: React.FunctionComponent + codyNotEnabledNotice?: React.FunctionComponent abortMessageInProgressComponent?: React.FunctionComponent<{ onAbortMessageInProgress: () => void }> onAbortMessageInProgress?: () => void + isCodyEnabled: boolean } interface ChatClassNames extends TranscriptItemClassNames { @@ -127,11 +129,13 @@ export const Chat: React.FunctionComponent = ({ suggestions, setSuggestions, needsEmailVerification = false, + codyNotEnabledNotice: CodyNotEnabledNotice, needsEmailVerificationNotice: NeedsEmailVerificationNotice, contextStatusComponent: ContextStatusComponent, contextStatusComponentProps = {}, abortMessageInProgressComponent, onAbortMessageInProgress, + isCodyEnabled, }) => { const [inputRows, setInputRows] = useState(5) const [historyIndex, setHistoryIndex] = useState(inputHistory.length) @@ -232,7 +236,11 @@ export const Chat: React.FunctionComponent = ({ return (
- {needsEmailVerification && NeedsEmailVerificationNotice ? ( + {!isCodyEnabled && CodyNotEnabledNotice ? ( +
+ +
+ ) : needsEmailVerification && NeedsEmailVerificationNotice ? (
@@ -281,17 +289,17 @@ export const Chat: React.FunctionComponent = ({