Skip to content

Commit

Permalink
Login changes (#1069)
Browse files Browse the repository at this point in the history
* use 2-step onboarding, some refactoring

* show login page any time there is no user_login field in config (meaning user is not authorized)

* Update github copy

---------

Co-authored-by: Louis Knight-Webb <louis@bloop.ai>
  • Loading branch information
anastasiya1155 and stunningpixels authored Nov 8, 2023
1 parent 1ba867b commit 7b51018
Show file tree
Hide file tree
Showing 23 changed files with 620 additions and 566 deletions.
2 changes: 1 addition & 1 deletion client/src/components/AddStudioContext/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import React, {
import { Trans, useTranslation } from 'react-i18next';
import { CloseSign, PlusSignInCircle } from '../../icons';
import SeparateOnboardingStep from '../SeparateOnboardingStep';
import DialogText from '../../pages/Onboarding/DialogText';
import DialogText from '../SeparateOnboardingStep/DialogText';
import SearchableRepoList from '../RepoList/SearchableRepoList';
import Button from '../Button';
import {
Expand Down
7 changes: 4 additions & 3 deletions client/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@
"Something went wrong": "Something went wrong",
"chats in bloop": "chats in bloop",
"Setup bloop": "Setup bloop",
"Please log into your GitHub account to complete setup": "Please log into your GitHub account to complete setup",
"Please log into your GitHub account to complete setup, this helps us us combat misuse.": "Please log into your GitHub account to complete setup, this helps us us combat misuse.",
"Select color theme:": "Select color theme:",
"Connect account": "Connect account",
"Continue": "Continue",
Expand Down Expand Up @@ -416,5 +416,6 @@
"Search pages": "Search pages",
"This page is currently unavailable. Ability to generate will be resumed as soon as this issue is resolved.": "This page is currently unavailable. Ability to generate will be resumed as soon as this issue is resolved.",
"Hold <1></1> to add multiple files": "Hold <1></1> to add multiple files",
"Clear section": "Clear section"
}
"Clear section": "Clear section",
"Let’s get you started with bloop!": "Let’s get you started with bloop!"
}
5 changes: 3 additions & 2 deletions client/src/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@
"Something went wrong": "Algo salió mal",
"chats in bloop": "Chats en bloop",
"Setup bloop": "Configuración de bloop",
"Please log into your GitHub account to complete setup": "Inicie sesión con su cuenta de GitHub para completar la configuración",
"Please log into your GitHub account to complete setup, this helps us us combat misuse.": "Inicie sesión con su cuenta de GitHub para completar la configuración",
"Select color theme:": "Seleccione el tema:",
"Connect account": "Conectar cuenta",
"Continue": "Continuar",
Expand Down Expand Up @@ -417,5 +417,6 @@
"Search pages": "Páginas de búsqueda",
"This page is currently unavailable. Ability to generate will be resumed as soon as this issue is resolved.": "Esta página no está disponible. La capacidad de generar se reanudará tan pronto como se resuelva este problema.",
"Hold <1></1> to add multiple files": "Mantenga presionada <1> </1> para agregar múltiples archivos",
"Clear section": "Borrar sección"
"Clear section": "Borrar sección",
"Let’s get you started with bloop!": "¡Vamos a comenzar con Bloop!"
}
2 changes: 1 addition & 1 deletion client/src/locales/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@
"Something went wrong": "Qualcosa è andato storto",
"chats in bloop": "chat in bloop",
"Setup bloop": "Configura bloop",
"Please log into your GitHub account to complete setup": "Accedi al tuo account GitHub per completare la configurazione",
"Please log into your GitHub account to complete setup, this helps us us combat misuse.": "Accedi al tuo account GitHub per completare la configurazione",
"Select color theme:": "Seleziona tema colori:",
"Connect account": "Collega account",
"Continue": "Continua",
Expand Down
7 changes: 4 additions & 3 deletions client/src/locales/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@
"Something went wrong": "何かがうまくいかなかった",
"chats in bloop": "bloopでチャット",
"Setup bloop": "bloopをセットアップする",
"Please log into your GitHub account to complete setup": "セットアップを完了するため、GitHubアカウントにログインしてください",
"Please log into your GitHub account to complete setup, this helps us us combat misuse.": "セットアップを完了するため、GitHubアカウントにログインしてください",
"Select color theme:": "カラーテーマを選択する",
"Connect account": "アカウントを接続する",
"Continue": "次へ",
Expand Down Expand Up @@ -414,5 +414,6 @@
"Search pages": "検索ページ",
"This page is currently unavailable. Ability to generate will be resumed as soon as this issue is resolved.": "このページは現在利用できません。 生成能力は、この問題が解決されるとすぐに再開されます。",
"Hold <1></1> to add multiple files": "<1> </1>を保持して複数のファイルを追加する",
"Clear section": "クリアセクション"
}
"Clear section": "クリアセクション",
"Let’s get you started with bloop!": "Bloopを始めましょう!"
}
7 changes: 4 additions & 3 deletions client/src/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@
"Something went wrong": "出错了",
"chats in bloop": "在bloop中对话",
"Setup bloop": "设置bloop",
"Please log into your GitHub account to complete setup": "请登录您的GitHub账户以完成设置",
"Please log into your GitHub account to complete setup, this helps us us combat misuse.": "请登录您的GitHub账户以完成设置",
"Select color theme:": "选择颜色主题:",
"Connect account": "连接账户",
"Continue": "继续",
Expand Down Expand Up @@ -423,5 +423,6 @@
"Search pages": "搜索页",
"This page is currently unavailable. Ability to generate will be resumed as soon as this issue is resolved.": "此页面当前不可用。 一旦解决此问题,就会恢复产生的能力。",
"Hold <1></1> to add multiple files": "保持<1> </1>添加多个文件",
"Clear section": "清除部分"
}
"Clear section": "清除部分",
"Let’s get you started with bloop!": "让我们开始开始Bloop!"
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import React, {
useState,
} from 'react';
import { Trans, useTranslation } from 'react-i18next';
import TextInput from '../../../components/TextInput';
import DialogText from '../../Onboarding/DialogText';
import { CodeStudioIcon } from '../../../icons';
import Button from '../../../components/Button';
import TextInput from '../../../../components/TextInput';
import DialogText from '../../../../components/SeparateOnboardingStep/DialogText';
import { CodeStudioIcon } from '../../../../icons';
import Button from '../../../../components/Button';

type Props = {
handleSubmit: (name: string) => void;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
import React, { useCallback, useContext, useEffect, useState } from 'react';
import { Trans, useTranslation } from 'react-i18next';
import DialogText from '../DialogText';
import Button from '../../../components/Button';
import { ArrowRight } from '../../../icons';
import SearchableRepoList from '../../../components/RepoList/SearchableRepoList';
import DialogText from '../../../../components/SeparateOnboardingStep/DialogText';
import Button from '../../../../components/Button';
import { ArrowRight } from '../../../../icons';
import SearchableRepoList from '../../../../components/RepoList/SearchableRepoList';
import {
RepoProvider,
RepoType,
RepoUi,
SyncStatus,
} from '../../../types/general';
} from '../../../../types/general';
import GoBackButton from '../GoBackButton';
import { UIContext } from '../../../context/uiContext';
import { splitPath } from '../../../utils';
import { RepositoriesContext } from '../../../context/repositoriesContext';
import { splitPath } from '../../../../utils';
import { RepositoriesContext } from '../../../../context/repositoriesContext';

type Props = {
handleNext: (e?: any) => void;
handleBack?: (e: any) => void;
disableSkip?: boolean;
};

export const STEP_KEY = 'STEP_GITHUB_REPOS';
let intervalId: number;

const GithubReposStep = ({ handleNext, handleBack, disableSkip }: Props) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Button from '../../../components/Button';
import { ArrowLeft } from '../../../icons';
import Button from '../../../../components/Button';
import { ArrowLeft } from '../../../../icons';

type Props = {
handleBack: (e: any) => void;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import React, { useCallback, useContext, useEffect, useState } from 'react';
import { Trans, useTranslation } from 'react-i18next';
import DialogText from '../DialogText';
import Button from '../../../components/Button';
import { ArrowRight } from '../../../icons';
import SearchableRepoList from '../../../components/RepoList/SearchableRepoList';
import { scanLocalRepos, syncRepo } from '../../../services/api';
import { RepoType, RepoUi } from '../../../types/general';
import DialogText from '../../../../components/SeparateOnboardingStep/DialogText';
import Button from '../../../../components/Button';
import { ArrowRight } from '../../../../icons';
import SearchableRepoList from '../../../../components/RepoList/SearchableRepoList';
import { scanLocalRepos, syncRepo } from '../../../../services/api';
import { RepoType, RepoUi } from '../../../../types/general';
import GoBackButton from '../GoBackButton';
import { splitPath } from '../../../utils';
import { DeviceContext } from '../../../context/deviceContext';
import { RepositoriesContext } from '../../../context/repositoriesContext';
import { splitPath } from '../../../../utils';
import { DeviceContext } from '../../../../context/deviceContext';
import { RepositoriesContext } from '../../../../context/repositoriesContext';

type Props = {
handleNext: (e?: any) => void;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React, { FormEvent, useCallback, useState } from 'react';
import axios from 'axios';
import { Trans, useTranslation } from 'react-i18next';
import DialogText from '../DialogText';
import Button from '../../../components/Button';
import { ArrowRight, Globe2 } from '../../../icons';
import DialogText from '../../../../components/SeparateOnboardingStep/DialogText';
import Button from '../../../../components/Button';
import { ArrowRight, Globe2 } from '../../../../icons';
import GoBackButton from '../GoBackButton';
import TextInput from '../../../components/TextInput';
import { syncRepo } from '../../../services/api';
import TextInput from '../../../../components/TextInput';
import { syncRepo } from '../../../../services/api';

type Props = {
handleNext: (e?: any) => void;
Expand Down
6 changes: 3 additions & 3 deletions client/src/pages/HomeTab/AddRepos/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { memo, useCallback } from 'react';
import LocalReposStep from '../../Onboarding/LocalReposStep';
import GithubReposStep from '../../Onboarding/GithubReposStep';
import SeparateOnboardingStep from '../../../components/SeparateOnboardingStep';
import PublicGithubReposStep from '../../Onboarding/PublicGithubReposStep';
import useKeyboardNavigation from '../../../hooks/useKeyboardNavigation';
import LocalReposStep from './LocalReposStep';
import GithubReposStep from './GithubReposStep';
import PublicGithubReposStep from './PublicGithubReposStep';
import AddCodeStudio from './AddCodeStudio';

type Props = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React, { useCallback } from 'react';
import { Trans, useTranslation } from 'react-i18next';
import Button from '../../../components/Button';
import { ChatBubble, PointClick, CodeStudioIcon } from '../../../icons';
import DialogText from '../DialogText';
import GoBackButton from '../GoBackButton';
import Button from '../../../../components/Button';
import { ChatBubble, PointClick, CodeStudioIcon } from '../../../../icons';
import DialogText from '../../../../components/SeparateOnboardingStep/DialogText';
import GoBackButton from '../../../HomeTab/AddRepos/GoBackButton';
import Feature from './Feature';

type Props = {
Expand Down
161 changes: 161 additions & 0 deletions client/src/pages/Onboarding/Desktop/UserForm/Step1.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
import React, {
Dispatch,
memo,
SetStateAction,
useCallback,
useContext,
useState,
} from 'react';
import { Trans, useTranslation } from 'react-i18next';
import TextInput from '../../../../components/TextInput';
import { EMAIL_REGEX } from '../../../../consts/validations';
import Dropdown from '../../../../components/Dropdown/Normal';
import { themesMap } from '../../../../components/Settings/Preferences';
import { MenuItemType } from '../../../../types/general';
import { Theme } from '../../../../types';
import { previewTheme } from '../../../../utils';
import Button from '../../../../components/Button';
import { UIContext } from '../../../../context/uiContext';
import { Form } from '../../index';
import { DeviceContext } from '../../../../context/deviceContext';

type Props = {
form: Form;
setForm: Dispatch<SetStateAction<Form>>;
onContinue: () => void;
};

const UserFormStep1 = ({ form, setForm, onContinue }: Props) => {
const { t } = useTranslation();
const { theme, setTheme } = useContext(UIContext.Theme);
const { openLink } = useContext(DeviceContext);
const [showErrors, setShowErrors] = useState(false);

const handleSubmit = useCallback(
(e: React.MouseEvent) => {
e.preventDefault();
e.stopPropagation();
if (
!form.firstName ||
!form.lastName ||
!form.email ||
!!form.emailError ||
!EMAIL_REGEX.test(form.email)
) {
if (!EMAIL_REGEX.test(form.email)) {
setForm((prev) => ({
...prev,
emailError: t('Email is not valid'),
}));
}
setShowErrors(true);
return;
}
onContinue();
},
[form, onContinue],
);

return (
<form
className="flex flex-col gap-4 w-full"
onSubmit={(e) => e.preventDefault()}
>
<TextInput
value={form.firstName}
name="firstName"
placeholder={t('First name')}
variant="filled"
onChange={(e) =>
setForm((prev) => ({ ...prev, firstName: e.target.value }))
}
autoFocus
error={
showErrors && !form.firstName
? t('First name is required')
: undefined
}
/>
<TextInput
value={form.lastName}
name="lastName"
placeholder={t('Last name')}
variant="filled"
onChange={(e) =>
setForm((prev) => ({ ...prev, lastName: e.target.value }))
}
error={
showErrors && !form.lastName ? t('Last name is required') : undefined
}
/>
<TextInput
value={form.email}
variant="filled"
onChange={(e) =>
setForm((prev) => ({
...prev,
email: e.target.value,
emailError: null,
}))
}
validate={() => {
if (form.email && !EMAIL_REGEX.test(form.email)) {
setForm((prev) => ({
...prev,
emailError: t('Email is not valid'),
}));
}
}}
error={
form.emailError ||
(showErrors && !form.email ? t('Email is required') : undefined)
}
name="email"
placeholder={t('Email address')}
/>
<div className="flex flex-col w-full">
<Dropdown
btnHint={
<span className="text-label-title">
<Trans>Select color theme:</Trans>
</span>
}
btnClassName="w-full border-transparent"
items={Object.entries(themesMap).map(([key, name]) => ({
type: MenuItemType.DEFAULT,
text: t(name),
onClick: () => setTheme(key as Theme),
onMouseOver: () => previewTheme(key),
}))}
onClose={() => previewTheme(theme)}
selected={{
type: MenuItemType.DEFAULT,
text: t(themesMap[theme]),
}}
/>
</div>
<Button onClick={handleSubmit}>
<Trans>Continue</Trans>
</Button>
<p className="caption text-label-base text-center">
<Trans>By continuing you accept our</Trans>
<br />
<button
onClick={() => openLink('https://bloop.ai/terms')}
className="text-label-link"
>
<Trans>Terms & conditions</Trans>
</button>{' '}
<Trans>and </Trans>
<button
onClick={() => openLink('https://bloop.ai/privacy')}
className="text-label-link"
>
<Trans>Privacy policy</Trans>
</button>
</p>
</form>
);
};

export default memo(UserFormStep1);
Loading

0 comments on commit 7b51018

Please sign in to comment.