Skip to content

Commit

Permalink
Remove the assist popup (#36329)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanclark committed Jan 8, 2024
1 parent 5da2066 commit c4ca7dd
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 218 deletions.
97 changes: 0 additions & 97 deletions web/packages/teleport/src/Assist/Popup/Popup.ts

This file was deleted.

17 changes: 0 additions & 17 deletions web/packages/teleport/src/Assist/Popup/index.ts

This file was deleted.

2 changes: 1 addition & 1 deletion web/packages/teleport/src/Main/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export function Main(props: MainProps) {
<HorizontalSplit>
<ContentMinWidth>
<Suspense fallback={null}>
<TopBar hidePopup={displayOnboardDiscover} />
<TopBar />
<FeatureRoutes lockedFeatures={ctx.lockedFeatures} />
</Suspense>
</ContentMinWidth>
Expand Down
35 changes: 4 additions & 31 deletions web/packages/teleport/src/TopBar/TopBar.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,37 +55,10 @@ function setup(): void {
mockUserContextProviderWith(makeTestUserContext());
}

test('does not show assist popup if hidePopup is true', async () => {
setup();

render(getTopBar({ hidePopup: true }));
await screen.findByTestId('cluster-selector');

expect(screen.queryByTestId('assistPopup')).not.toBeInTheDocument();
});

test('shows assist popup if hidePopup is absent', async () => {
setup();

render(getTopBar({}));
await screen.findByTestId('cluster-selector');

expect(screen.getByTestId('assistPopup')).toBeInTheDocument();
});

test('shows assist popup if hidePopup is false', async () => {
setup();

render(getTopBar({ hidePopup: false }));
await screen.findByTestId('cluster-selector');

expect(screen.getByTestId('assistPopup')).toBeInTheDocument();
});

test('notification bell without notification', async () => {
setup();

render(getTopBar({}));
render(getTopBar());
await screen.findByTestId('cluster-selector');

expect(screen.getByTestId('tb-note')).toBeInTheDocument();
Expand All @@ -108,7 +81,7 @@ test('notification bell with notification', async () => {
],
};

render(getTopBar({}));
render(getTopBar());
await screen.findByTestId('cluster-selector');

expect(screen.getByTestId('tb-note')).toBeInTheDocument();
Expand All @@ -121,13 +94,13 @@ test('notification bell with notification', async () => {
expect(screen.getByTestId('tb-note-dropdown')).toBeVisible();
});

const getTopBar = ({ hidePopup = null }: { hidePopup?: boolean }) => {
const getTopBar = () => {
return (
<Router history={createMemoryHistory()}>
<LayoutContextProvider>
<TeleportContextProvider ctx={ctx}>
<FeaturesContextProvider value={getOSSFeatures()}>
<TopBar hidePopup={hidePopup} />
<TopBar />
</FeaturesContextProvider>
</TeleportContextProvider>
</LayoutContextProvider>
Expand Down
78 changes: 6 additions & 72 deletions web/packages/teleport/src/TopBar/TopBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@ limitations under the License.
*/

import React, { lazy, Suspense, useState } from 'react';
import styled, { useTheme } from 'styled-components';
import styled from 'styled-components';
import { Flex, Text, TopNav } from 'design';

import { matchPath, useHistory } from 'react-router';

import { BrainIcon, OpenAIIcon } from 'design/SVGIcon';

import { useLocalStorage } from 'shared/hooks/useLocalStorage';
import { BrainIcon } from 'design/SVGIcon';

import { ArrowLeft } from 'design/Icon';

Expand All @@ -37,58 +35,19 @@ import { useLayout } from 'teleport/Main/LayoutContext';
import { KeysEnum } from 'teleport/services/storageService';
import { getFirstRouteForCategory } from 'teleport/Navigation/Navigation';

import {
Popup,
PopupButton,
PopupFooter,
PopupLogos,
PopupLogosSpacer,
PopupTitle,
PopupTitleBackground,
TeleportIcon,
} from 'teleport/Assist/Popup/Popup';

import ClusterSelector from './ClusterSelector';
import { Notifications } from './Notifications';
import { ButtonIconContainer } from './Shared';

const Assist = lazy(() => import('teleport/Assist'));

const AssistButtonContainer = styled.div`
position: relative;
`;

const Background = styled.div`
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 98;
background: rgba(0, 0, 0, 0.6);
`;

type TopBarProps = {
// hidePopup indicates if the popup should be hidden based on parent component states.
// if true, another modal is present; and we do not want to display the assist popup.
// if false or absent, display as pre normal logical rules.
hidePopup?: boolean;
};

export function TopBar({ hidePopup = false }: TopBarProps) {
const theme = useTheme();

export function TopBar() {
const ctx = useTeleport();
const history = useHistory();
const features = useFeatures();

const assistEnabled = ctx.getFeatureFlags().assist && ctx.assistEnabled;

const [showAssistPopup, setShowAssistPopup] = useLocalStorage(
KeysEnum.SHOW_ASSIST_POPUP,
assistEnabled
);

const [showAssist, setShowAssist] = useState(false);

const { clusterId, hasClusterUrl } = useStickyClusterId();
Expand Down Expand Up @@ -193,34 +152,9 @@ export function TopBar({ hidePopup = false }: TopBarProps) {
/>
<Flex ml="auto" height="100%" alignItems="center">
{!hasDockedElement && assistEnabled && (
<AssistButtonContainer>
<ButtonIconContainer onClick={() => setShowAssist(true)}>
<BrainIcon />
</ButtonIconContainer>
{showAssistPopup && !hidePopup && (
<>
<Background />
<Popup data-testid="assistPopup">
<PopupTitle>
<PopupTitleBackground>New!</PopupTitleBackground>
</PopupTitle>{' '}
Try out Teleport Assist, a GPT-4-powered AI assistant that
leverages your infrastructure
<PopupFooter>
<PopupLogos>
<OpenAIIcon size={30} />
<PopupLogosSpacer>+</PopupLogosSpacer>
<TeleportIcon light={theme.type === 'light'} />
</PopupLogos>

<PopupButton onClick={() => setShowAssistPopup(false)}>
Close
</PopupButton>
</PopupFooter>
</Popup>
</>
)}
</AssistButtonContainer>
<ButtonIconContainer onClick={() => setShowAssist(true)}>
<BrainIcon />
</ButtonIconContainer>
)}
<Notifications />
<UserMenuNav username={ctx.storeUser.state.username} />
Expand Down

0 comments on commit c4ca7dd

Please sign in to comment.