Skip to content
This repository has been archived by the owner on Jan 2, 2025. It is now read-only.

Commit

Permalink
feedback fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
anastasiya1155 committed Jan 24, 2024
1 parent 1f05882 commit 5d5df07
Show file tree
Hide file tree
Showing 32 changed files with 309 additions and 125 deletions.
14 changes: 6 additions & 8 deletions client/src/CommandBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ import { CommandBarContext } from '../context/commandBarContext';
import { useGlobalShortcuts } from '../hooks/useGlobalShortcuts';
import { checkEventKeys } from '../utils/keyboardUtils';
import { EnvContext } from '../context/envContext';
import {
CMD_BAR_TUTORIAL_FINISHED_KEY,
getPlainFromStorage,
} from '../services/storage';
import { UIContext } from '../context/uiContext';
import Initial from './steps/Initial';
import PrivateRepos from './steps/PrivateRepos';
import PublicRepos from './steps/PublicRepos';
Expand All @@ -31,7 +28,8 @@ const CommandBar = ({}: Props) => {
const { setChosenStep, setIsVisible } = useContext(
CommandBarContext.Handlers,
);
const { setEnvConfig, envConfig } = useContext(EnvContext);
const { envConfig } = useContext(EnvContext);
const { onBoardingState } = useContext(UIContext.Onboarding);
const globalShortcuts = useGlobalShortcuts();

const handleClose = useCallback(() => {
Expand All @@ -44,9 +42,9 @@ const CommandBar = ({}: Props) => {
const shouldShowTutorial = useMemo(() => {
return (
!envConfig?.bloop_user_profile?.is_tutorial_finished &&
!getPlainFromStorage(CMD_BAR_TUTORIAL_FINISHED_KEY)
!onBoardingState.isCommandBarTutorialFinished
);
}, [envConfig?.bloop_user_profile, isVisible]);
}, [envConfig?.bloop_user_profile, onBoardingState]);

const handleKeyEvent = useCallback(
(e: KeyboardEvent) => {
Expand Down Expand Up @@ -89,7 +87,7 @@ const CommandBar = ({}: Props) => {
) : chosenStep.id === CommandBarStepEnum.CREATE_PROJECT ? (
<CreateProject />
) : chosenStep.id === CommandBarStepEnum.MANAGE_REPOS ? (
<ManageRepos />
<ManageRepos shouldShowTutorial={shouldShowTutorial} />
) : chosenStep.id === CommandBarStepEnum.ADD_NEW_REPO ? (
<AddNewRepo shouldShowTutorial={shouldShowTutorial} />
) : chosenStep.id === CommandBarStepEnum.TOGGLE_THEME ? (
Expand Down
9 changes: 2 additions & 7 deletions client/src/CommandBar/steps/AddNewRepo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,20 +135,15 @@ const AddNewRepo = ({ shouldShowTutorial }: Props) => {
stepNumber={2}
title={t(tutorialSteps[1].title)}
description={t(tutorialSteps[1].description)}
hint={
t(tutorialSteps[1].hint[0]) + t(tutorialSteps[1].hint[1]) + '.'
}
hint={t(tutorialSteps[1].hint[0])}
/>
}
wrapperClassName="absolute top-[5rem] left-0 right-0"
>
<div className="" />
</TutorialTooltip>
) : null}
<Body
sections={initialSections}
onlyOneClickable={shouldShowTutorial ? 'private' : undefined}
/>
<Body sections={initialSections} />
<Footer />
</div>
);
Expand Down
12 changes: 4 additions & 8 deletions client/src/CommandBar/steps/Initial.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import { TabsContext } from '../../context/tabsContext';
import TutorialBody from '../Tutorial/TutorialBody';
import TutorialTooltip from '../Tutorial/TutorialTooltip';
import { tutorialSteps } from '../../consts/tutorialSteps';
import { newChatTabShortcut } from '../../consts/shortcuts';

type Props = {
shouldShowTutorial?: boolean;
Expand Down Expand Up @@ -283,12 +284,12 @@ const InitialCommandBar = ({ shouldShowTutorial }: Props) => {
const newTabItems = project?.repos.length
? [
{
label: t('New chat'),
label: t('New conversation'),
Icon: ChatBubblesIcon,
id: 'new chat',
key: 'new_chat',
onClick: () => openNewTab({ type: TabTypesEnum.CHAT }),
shortcut: ['option', 'N'],
shortcut: newChatTabShortcut,
closeOnClick: true,
footerHint: '',
footerBtns: [
Expand Down Expand Up @@ -440,12 +441,7 @@ const InitialCommandBar = ({ shouldShowTutorial }: Props) => {
</TutorialTooltip>
) : null}
{!!sectionsToShow.length ? (
<Body
sections={sectionsToShow}
onlyOneClickable={
shouldShowTutorial ? CommandBarStepEnum.ADD_NEW_REPO : undefined
}
/>
<Body sections={sectionsToShow} />
) : (
<div className="flex-1 items-center justify-center text-label-muted text-center py-2">
<Trans>No commands found...</Trans>
Expand Down
70 changes: 66 additions & 4 deletions client/src/CommandBar/steps/ManageRepos/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import React, {
ChangeEvent,
memo,
useCallback,
Expand Down Expand Up @@ -26,9 +26,15 @@ import { mapReposBySections } from '../../../utils/mappers';
import { ProjectContext } from '../../../context/projectContext';
import { CommandBarContext } from '../../../context/commandBarContext';
import RepoItem from '../items/RepoItem';
import TutorialTooltip from '../../Tutorial/TutorialTooltip';
import TutorialBody from '../../Tutorial/TutorialBody';
import { tutorialSteps } from '../../../consts/tutorialSteps';
import { UIContext } from '../../../context/uiContext';
import ActionsDropdown from './ActionsDropdown';

type Props = {};
type Props = {
shouldShowTutorial?: boolean;
};

export enum Filter {
All = 'All',
Expand All @@ -43,10 +49,11 @@ export enum Provider {
Local = 'Local',
}

const ManageRepos = ({}: Props) => {
const ManageRepos = ({ shouldShowTutorial }: Props) => {
const { t } = useTranslation();
const { project } = useContext(ProjectContext.Current);
const { setChosenStep } = useContext(CommandBarContext.Handlers);
const { setOnBoardingState } = useContext(UIContext.Onboarding);
const [sections, setSections] = useState<CommandBarSectionType[]>([]);
const [sectionsToShow, setSectionsToShow] = useState<CommandBarSectionType[]>(
[],
Expand All @@ -55,6 +62,9 @@ const ManageRepos = ({}: Props) => {
const [filter, setFilter] = useState<Filter>(Filter.All);
const [repoType, setRepoType] = useState<Provider>(Provider.All);
const [inputValue, setInputValue] = useState('');
const [tutorialStep, setTutorialStep] = useState(0);
const [selectedRepo, setSelectedRepo] = useState('');
const [indexedRepo, setIndexedRepo] = useState('');

const handleInputChange = useCallback((e: ChangeEvent<HTMLInputElement>) => {
setInputValue(e.target.value);
Expand Down Expand Up @@ -88,7 +98,25 @@ const ManageRepos = ({}: Props) => {
const mapped = mapReposBySections(data.list).map((o) => ({
items: o.items.map((r) => ({
Component: RepoItem,
componentProps: { repo: r, refetchRepos },
componentProps: {
repo: r,
refetchRepos,
onSync: () => {
setSelectedRepo(r.shortName);
setTutorialStep(3);
},
onDone: () => {
setIndexedRepo(r.shortName);
setTutorialStep(4);
},
onAddToProject: () => {
setOnBoardingState((prev) => ({
...prev,
isCommandBarTutorialFinished: true,
}));
setTutorialStep(5);
},
},
key: r.ref,
})),
itemsOffset: o.offset + 1,
Expand Down Expand Up @@ -175,6 +203,17 @@ const ManageRepos = ({}: Props) => {
refetchRepos();
}, []);

useEffect(() => {
// if user started with non-private repo
if (shouldShowTutorial && tutorialStep === 0 && sections.length > 1) {
const firstRepo = (sections[1].items[0] as CommandBarItemCustomType)
.componentProps.repo;
setTutorialStep(firstRepo.isSyncing ? 3 : 4);
setSelectedRepo(firstRepo.shortName);
setIndexedRepo(firstRepo.shortName);
}
}, [sections, tutorialStep, shouldShowTutorial]);

const handleBack = useCallback(() => {
setChosenStep({ id: CommandBarStepEnum.INITIAL });
}, []);
Expand All @@ -198,6 +237,29 @@ const ManageRepos = ({}: Props) => {
placeholder={t('')}
disableKeyNav={isDropdownVisible}
/>
{shouldShowTutorial && tutorialStep < 5 ? (
<TutorialTooltip
content={
<TutorialBody
stepNumber={tutorialStep + 1}
title={t(tutorialSteps[tutorialStep].title)}
description={t(tutorialSteps[tutorialStep].description, {
repoName: tutorialStep === 3 ? selectedRepo : indexedRepo,
})}
hint={
tutorialStep > 0
? t(tutorialSteps[tutorialStep].hint[0])
: t(tutorialSteps[tutorialStep].hint[0]) +
t(tutorialSteps[0].hint[1]) +
'.'
}
/>
}
wrapperClassName="absolute top-[7.5rem] left-0 right-0"
>
<div className="" />
</TutorialTooltip>
) : null}
{sectionsToShow.length ? (
<Body sections={sectionsToShow} disableKeyNav={isDropdownVisible} />
) : (
Expand Down
11 changes: 6 additions & 5 deletions client/src/CommandBar/steps/PrivateRepos/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ import RepoItem from '../items/RepoItem';
import TutorialBody from '../../Tutorial/TutorialBody';
import TutorialTooltip from '../../Tutorial/TutorialTooltip';
import { tutorialSteps } from '../../../consts/tutorialSteps';
import {
CMD_BAR_TUTORIAL_FINISHED_KEY,
savePlainToStorage,
} from '../../../services/storage';
import { UIContext } from '../../../context/uiContext';
import ActionsDropdown from './ActionsDropdown';

type Props = {
Expand All @@ -41,6 +38,7 @@ const PrivateReposStep = ({ shouldShowTutorial }: Props) => {
[],
);
const { setChosenStep } = useContext(CommandBarContext.Handlers);
const { setOnBoardingState } = useContext(UIContext.Onboarding);
const [inputValue, setInputValue] = useState('');
const [tutorialStep, setTutorialStep] = useState(2);
const [isDropdownVisible, setIsDropdownVisible] = useState(false);
Expand Down Expand Up @@ -70,7 +68,10 @@ const PrivateReposStep = ({ shouldShowTutorial }: Props) => {
setTutorialStep(4);
},
onAddToProject: () => {
savePlainToStorage(CMD_BAR_TUTORIAL_FINISHED_KEY, 'true');
setOnBoardingState((prev) => ({
...prev,
isCommandBarTutorialFinished: true,
}));
setTutorialStep(5);
},
},
Expand Down
4 changes: 3 additions & 1 deletion client/src/Onboarding/Desktop/UserForm/Step1.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ const UserFormStep1 = ({ form, setForm, onContinue }: Props) => {
</Button>
</Dropdown>
</div>
<Button onClick={handleSubmit}>
<Button onClick={handleSubmit} type="submit">
<Trans>Continue</Trans>
</Button>
<p className="body-mini text-label-base text-center">
Expand All @@ -135,13 +135,15 @@ const UserFormStep1 = ({ form, setForm, onContinue }: Props) => {
<button
onClick={() => openLink('https://bloop.ai/terms')}
className="text-label-link"
type="button"
>
<Trans>Terms & conditions</Trans>
</button>{' '}
<Trans>and </Trans>
<button
onClick={() => openLink('https://bloop.ai/privacy')}
className="text-label-link"
type="button"
>
<Trans>Privacy policy</Trans>
</button>
Expand Down
3 changes: 3 additions & 0 deletions client/src/Onboarding/Desktop/UserForm/Step2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { copyToClipboard } from '../../../utils';
import Button from '../../../components/Button';
import { polling } from '../../../utils/requestUtils';
import { EnvContext } from '../../../context/envContext';
import { useEnterKey } from '../../../hooks/useEnterKey';

type Props = {
onContinue: () => void;
Expand Down Expand Up @@ -114,6 +115,8 @@ const UserFormStep2 = ({ onContinue }: Props) => {
}
}, [loginUrl, checkGHAuth]);

useEnterKey(onClick, isBtnClicked && !isGithubConnected && !isTimedOut);

return (
<div className="w-full flex flex-col gap-4">
<div
Expand Down
2 changes: 1 addition & 1 deletion client/src/Project/CurrentTabContent/ChatTab/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ const ChatTab = ({
sizeClassName="w-4 h-4"
className="text-brand-default"
/>
{title || t('New chat')}
{title || t('New conversation')}
</div>
{focusedPanel === side && (
<Dropdown
Expand Down
4 changes: 4 additions & 0 deletions client/src/Project/CurrentTabContent/FileTab/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ const FileTab = ({
const { openNewTab, updateTabProperty } = useContext(TabsContext.Handlers);
const { focusedPanel } = useContext(TabsContext.All);
const { isLeftSidebarFocused } = useContext(UIContext.Focus);
const { setOnBoardingState } = useContext(UIContext.Onboarding);
const { project, refreshCurrentProjectStudios } = useContext(
ProjectContext.Current,
);
Expand Down Expand Up @@ -279,6 +280,9 @@ const FileTab = ({
},
side === 'left' ? 'right' : 'left',
);
setOnBoardingState((prev) =>
prev.isFileExplained ? prev : { ...prev, isFileExplained: true },
);
}, [path, repoRef, branch, linesNumber, side, openNewTab]);

const handleAddToStudio = useCallback(() => {
Expand Down
25 changes: 22 additions & 3 deletions client/src/Project/CurrentTabContent/Header/AddTabButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ import { TabTypesEnum } from '../../../types/general';
import useKeyboardNavigation from '../../../hooks/useKeyboardNavigation';
import { TabsContext } from '../../../context/tabsContext';
import Dropdown from '../../../components/Dropdown';
import {
newChatTabShortcut,
newStudioTabShortcut,
} from '../../../consts/shortcuts';
import { postCodeStudio } from '../../../services/api';
import { ProjectContext } from '../../../context/projectContext';
import AddTabDropdown from './AddTabDropdown';

type Props = {
Expand All @@ -15,11 +21,12 @@ type Props = {
focusedPanel: 'left' | 'right';
};

const newTabShortcut = ['option', 'N'];

const AddTabButton = ({ side, focusedPanel, tabsLength }: Props) => {
const { t } = useTranslation();
const { openNewTab } = useContext(TabsContext.Handlers);
const { refreshCurrentProjectStudios, project } = useContext(
ProjectContext.Current,
);

const dropdownComponentProps = useMemo(() => {
return { side };
Expand All @@ -29,12 +36,24 @@ const AddTabButton = ({ side, focusedPanel, tabsLength }: Props) => {
openNewTab({ type: TabTypesEnum.CHAT }, side);
}, [openNewTab, side]);

const openStudioTab = useCallback(async () => {
if (project?.id) {
const newId = await postCodeStudio(project?.id);
refreshCurrentProjectStudios();
openNewTab({ type: TabTypesEnum.STUDIO, studioId: newId }, side);
}
}, [openNewTab, side, project?.id]);

const handleKeyEvent = useCallback(
(e: KeyboardEvent) => {
if (checkEventKeys(e, newTabShortcut)) {
if (checkEventKeys(e, newChatTabShortcut)) {
e.stopPropagation();
e.preventDefault();
openChatTab();
} else if (checkEventKeys(e, newStudioTabShortcut)) {
e.stopPropagation();
e.preventDefault();
openStudioTab();
}
},
[openNewTab],
Expand Down
Loading

0 comments on commit 5d5df07

Please sign in to comment.