Skip to content

Commit

Permalink
Saber
Browse files Browse the repository at this point in the history
  • Loading branch information
Dead4W-Saber committed Oct 15, 2023
1 parent 01b09b1 commit 7e34a8a
Show file tree
Hide file tree
Showing 27 changed files with 487 additions and 1,608 deletions.
Empty file removed apps/desktop/dist/.keep
Empty file.
26 changes: 15 additions & 11 deletions client/src/components/Chat/ChatBody/ConversationMessage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ import { getDateFnsLocale } from '../../../../utils';
import MarkdownWithCode from '../../../MarkdownWithCode';
import { AppNavigationContext } from '../../../../context/appNavigationContext';
import {
getJsonFromStorage,
getPlainFromStorage,
LOADING_STEPS_SHOWN_KEY,
savePlainToStorage,
savePlainToStorage, USER_DATA,
} from '../../../../services/storage';
import MessageFeedback from './MessageFeedback';
import FileChip from './FileChip';
import {User} from "../../../../types/user";

type Props = {
author: ChatMessageAuthor;
Expand All @@ -44,6 +46,8 @@ type Props = {
singleFileExplanation?: boolean;
};

const user: User | null = getJsonFromStorage(USER_DATA);

const ConversationMessage = ({
author,
message,
Expand Down Expand Up @@ -160,7 +164,7 @@ const ConversationMessage = ({
<div className="w-6 h-6 rounded-full bg-chat-bg-border overflow-hidden flex items-center justify-center select-none">
{author === ChatMessageAuthor.User ? (
<img
src={envConfig.github_user?.avatar_url}
src={user?.avatar_url ?? ''}
alt={t('avatar')}
/>
) : (
Expand Down Expand Up @@ -203,15 +207,15 @@ const ConversationMessage = ({
</div>
)}
</div>
<MessageFeedback
showInlineFeedback={showInlineFeedback}
isHistory={isHistory}
threadId={threadId}
queryId={queryId}
repoRef={repoRef}
error={!!error}
scrollToBottom={scrollToBottom}
/>
{/*<MessageFeedback*/}
{/* showInlineFeedback={showInlineFeedback}*/}
{/* isHistory={isHistory}*/}
{/* threadId={threadId}*/}
{/* queryId={queryId}*/}
{/* repoRef={repoRef}*/}
{/* error={!!error}*/}
{/* scrollToBottom={scrollToBottom}*/}
{/*/>*/}
</>
) : error ? (
<div className="flex items-start gap-3 text-bg-danger p-4 rounded-lg bg-[linear-gradient(90deg,rgba(251,113,133,0.08)_0%,rgba(231,139,152,0.08)_33.18%,rgba(191,191,191,0.08)_100%)]">
Expand Down
3 changes: 2 additions & 1 deletion client/src/components/Chat/ChatFooter/NLInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { UIContext } from '../../../context/uiContext';
import { DeviceContext } from '../../../context/deviceContext';
import Button from '../../Button';
import InputLoader from './InputLoader';
import {getJsonFromStorage, PROMPT_GUIDE} from "../../../services/storage";

type Props = {
id?: string;
Expand Down Expand Up @@ -90,7 +91,7 @@ const NLInput = ({
);

const handleInputFocus = useCallback(() => {
if (envConfig?.bloop_user_profile?.prompt_guide !== 'dismissed') {
if (getJsonFromStorage(PROMPT_GUIDE) !== 'dismissed') {
setPromptGuideOpen(true);
}
}, [envConfig?.bloop_user_profile?.prompt_guide]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export const LightNavigation = () => {
<ListNavigation
title=""
items={[
{ title: 'General', icon: <Person /> },
// { title: 'General', icon: <Person /> },
{ title: 'Preferences', icon: <TuneControls /> },
{ title: 'Repositories', icon: <Repository /> },
]}
Expand Down
4 changes: 1 addition & 3 deletions client/src/components/LanguageSelector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import { LocaleType } from '../../types/general';

const localesMap: Record<LocaleType, { name: string; icon: string }> = {
en: { name: 'English', icon: '🇬🇧' },
ja: { name: '日本', icon: '🇯🇵' },
zhCN: { name: '简体中文', icon: '🇨🇳' },
es: { name: 'Español', icon: '🇪🇸' },
ru: { name: 'Russian', icon: '🇷🇺' },
};

const LanguageSelector = () => {
Expand Down
14 changes: 6 additions & 8 deletions client/src/components/NavBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { getSubscriptionLink, githubLogout } from '../../services/api';
import { PersonalQuotaContext } from '../../context/personalQuotaContext';
import LiteLoaderContainer from '../Loaders/LiteLoader';
import Tab from './Tab';
import {User} from "../../types/user";
import {getJsonFromStorage, USER_DATA, USER_DATA_FORM} from "../../services/storage";

type Props = {
isSkeleton?: boolean;
Expand All @@ -29,6 +31,8 @@ const NavBar = ({ isSkeleton, activeTab }: Props) => {
const { tabs, handleReorderTabs, setActiveTab } = useContext(TabsContext);
const [isFetchingLink, setIsFetchingLink] = useState(false);

const user: User | null = getJsonFromStorage(USER_DATA);

const handleUpgrade = useCallback(() => {
setIsFetchingLink(true);
getSubscriptionLink()
Expand Down Expand Up @@ -73,12 +77,6 @@ const NavBar = ({ isSkeleton, activeTab }: Props) => {
type: MenuListItemType.DEFAULT,
onClick: () => openLink('https://bloop.ai/docs'),
},
{
text: t('Report a bug'),
icon: <Bug />,
type: MenuListItemType.DEFAULT,
onClick: () => setBugReportModalOpen(true),
},
{
text: t('Sign out'),
icon: <DoorRight />,
Expand Down Expand Up @@ -141,9 +139,9 @@ const NavBar = ({ isSkeleton, activeTab }: Props) => {
<DropdownWithIcon
items={dropdownItems}
icon={
envConfig.github_user?.avatar_url ? (
user?.avatar_url ? (
<div className="w-5 h-5 rounded-full overflow-hidden">
<img src={envConfig.github_user?.avatar_url} alt="avatar" />
<img src={user?.avatar_url} alt="avatar" />
</div>
) : (
<Person />
Expand Down
17 changes: 2 additions & 15 deletions client/src/components/PromptGuidePopup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { DeviceContext } from '../../context/deviceContext';
import { UIContext } from '../../context/uiContext';
import { getConfig, putConfig } from '../../services/api';
import PromptSvg from './PromptSvg';
import {PROMPT_GUIDE, saveJsonToStorage} from "../../services/storage";

const PromptGuidePopup = () => {
const { t } = useTranslation();
Expand All @@ -17,21 +18,7 @@ const PromptGuidePopup = () => {

const handlePromptGuideClose = useCallback(() => {
setPromptGuideOpen(false);
setEnvConfig((prev) => ({
...prev,
bloop_user_profile: {
...(prev.bloop_user_profile || {}),
prompt_guide: 'dismissed',
},
}));
putConfig({
bloop_user_profile: {
...(envConfig?.bloop_user_profile || {}),
prompt_guide: 'dismissed',
},
}).then(() => {
getConfig().then(setEnvConfig);
});
saveJsonToStorage(PROMPT_GUIDE, 'dismissed');
}, [envConfig?.bloop_user_profile]);

return (
Expand Down
63 changes: 1 addition & 62 deletions client/src/components/Settings/General/Profile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,68 +67,7 @@ const ProfileSettings = () => {

return (
<form className="block">
<SettingsRow>
<SettingsText
title={t('First and last name')}
subtitle={t('Manage how you will be called in bloop')}
/>
<div className="flex flex-1 flex-col gap-4">
<TextInput
value={form.firstName}
onChange={onChange}
name="firstName"
label={t('First name')}
variant="filled"
placeholder={t('Your name')}
/>
<TextInput
value={form.lastName}
onChange={onChange}
name="lastName"
label={t('Last name')}
variant="filled"
placeholder={t('Your last name')}
/>
</div>
</SettingsRow>
<SettingsRow>
<SettingsText
title={t('Email')}
subtitle={t('Used to sign in, syncing and product updates')}
/>
<div className="flex-1 flex flex-col items-end">
<TextInput
value={form.email}
onChange={onChange}
name="email"
label={t('Email')}
variant="filled"
placeholder={t('Your email address')}
validate={() => {
if (!EMAIL_REGEX.test(form.email)) {
setForm((prev) => ({
...prev,
emailError: t('Email is not valid'),
}));
}
}}
error={form.emailError}
/>
</div>
</SettingsRow>
<Button
size="small"
className="absolute top-0 right-0"
disabled={
!!form.emailError ||
(form.email === savedForm?.email &&
form.firstName === savedForm?.firstName &&
form.lastName === savedForm?.lastName)
}
onClick={handleSubmit}
>
<Trans>Save changes</Trans>
</Button>

</form>
);
};
Expand Down
4 changes: 2 additions & 2 deletions client/src/components/Settings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const Settings = () => {

const listNavigationItems = useMemo(
() => [
{ title: t('General'), icon: <Person /> },
// { title: t('General'), icon: <Person /> },
{ title: t('Preferences'), icon: <TuneControls /> },
// { title: 'Repositories', icon: <Repository /> },
],
Expand All @@ -48,7 +48,7 @@ const Settings = () => {
style={isSettingsOpen ? backdropFilterVisible : backdropFilterInvisible}
onClick={() => {
setSettingsOpen(false);
setSettingsSection(SettingSections.GENERAL);
setSettingsSection(SettingSections.PREFERENCES);
}}
>
<div
Expand Down
15 changes: 0 additions & 15 deletions client/src/components/StatusBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,21 +138,6 @@ const StatusBar = () => {
<Magazine />
<Trans>Documentation</Trans>
</Button>
<Button
size="small"
variant="secondary"
onClick={() => openLink(discordLink)}
>
<DiscordLogo />
<Trans>Discord</Trans>
</Button>
<Button
size="small"
variant="secondary"
onClick={() => setBugReportModalOpen(true)}
>
<Trans>Report a bug</Trans>
</Button>
</span>
</div>
);
Expand Down
14 changes: 3 additions & 11 deletions client/src/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';
import backend from 'i18next-http-backend';
import en from './locales/en.json';
import ja from './locales/ja.json';
import zhCN from './locales/zh-CN.json';
import es from './locales/es.json';
import ru from './locales/ru.json';
import { getPlainFromStorage, LANGUAGE_KEY } from './services/storage';

// the translations
Expand All @@ -14,14 +12,8 @@ const resources = {
en: {
translation: en,
},
ja: {
translation: ja,
},
zhCN: {
translation: zhCN,
},
es: {
translation: es,
ru: {
translation: ru,
},
};

Expand Down
4 changes: 3 additions & 1 deletion client/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -392,5 +392,7 @@
"No change in payment status identified.": "No change in payment status identified.",
"You've upgraded your account!": "You've upgraded your account!",
"Unlimited usage and premium features are activated.": "Unlimited usage and premium features are activated.",
"Let's go": "Let's go"
"Let's go": "Let's go",
"Login": "Login",
"Password": "Password"
}
Loading

0 comments on commit 7e34a8a

Please sign in to comment.