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

Commit

Permalink
add repo to project when it finished indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
anastasiya1155 committed Jan 26, 2024
1 parent 2b48290 commit 596b073
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 27 deletions.
13 changes: 7 additions & 6 deletions client/src/CommandBar/steps/ManageRepos/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ const ManageRepos = ({ shouldShowTutorial }: Props) => {
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 @@ -106,15 +105,18 @@ const ManageRepos = ({ shouldShowTutorial }: Props) => {
setTutorialStep(3);
},
onDone: () => {
setIndexedRepo(r.shortName);
setOnBoardingState((prev) => ({
...prev,
isCommandBarTutorialFinished: true,
}));
setTutorialStep(4);
},
onAddToProject: () => {
setOnBoardingState((prev) => ({
...prev,
isCommandBarTutorialFinished: true,
}));
setTutorialStep(5);
setTutorialStep(4);
},
},
key: r.ref,
Expand Down Expand Up @@ -210,7 +212,6 @@ const ManageRepos = ({ shouldShowTutorial }: Props) => {
.componentProps.repo;
setTutorialStep(firstRepo.isSyncing ? 3 : 4);
setSelectedRepo(firstRepo.shortName);
setIndexedRepo(firstRepo.shortName);
}
}, [sections, tutorialStep, shouldShowTutorial]);

Expand All @@ -237,14 +238,14 @@ const ManageRepos = ({ shouldShowTutorial }: Props) => {
placeholder={t('')}
disableKeyNav={isDropdownVisible}
/>
{shouldShowTutorial && tutorialStep < 5 ? (
{shouldShowTutorial && tutorialStep < 4 ? (
<TutorialTooltip
content={
<TutorialBody
stepNumber={tutorialStep + 1}
title={t(tutorialSteps[tutorialStep].title)}
description={t(tutorialSteps[tutorialStep].description, {
repoName: tutorialStep === 3 ? selectedRepo : indexedRepo,
repoName: selectedRepo,
})}
hint={
tutorialStep > 0
Expand Down
12 changes: 7 additions & 5 deletions client/src/CommandBar/steps/PrivateRepos/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ const PrivateReposStep = ({ shouldShowTutorial }: Props) => {
const [tutorialStep, setTutorialStep] = useState(2);
const [isDropdownVisible, setIsDropdownVisible] = useState(false);
const [selectedRepo, setSelectedRepo] = useState('');
const [indexedRepo, setIndexedRepo] = useState('');

const handleInputChange = useCallback((e: ChangeEvent<HTMLInputElement>) => {
setInputValue(e.target.value);
Expand All @@ -64,15 +63,18 @@ const PrivateReposStep = ({ shouldShowTutorial }: Props) => {
setTutorialStep(3);
},
onDone: () => {
setIndexedRepo(r.shortName);
setOnBoardingState((prev) => ({
...prev,
isCommandBarTutorialFinished: true,
}));
setTutorialStep(4);
},
onAddToProject: () => {
setOnBoardingState((prev) => ({
...prev,
isCommandBarTutorialFinished: true,
}));
setTutorialStep(5);
setTutorialStep(4);
},
},
key: r.ref,
Expand Down Expand Up @@ -133,14 +135,14 @@ const PrivateReposStep = ({ shouldShowTutorial }: Props) => {
placeholder={t('Search private repos...')}
disableKeyNav={isDropdownVisible}
/>
{shouldShowTutorial && tutorialStep < 5 ? (
{shouldShowTutorial && tutorialStep < 4 ? (
<TutorialTooltip
content={
<TutorialBody
stepNumber={tutorialStep + 1}
title={t(tutorialSteps[tutorialStep].title)}
description={t(tutorialSteps[tutorialStep].description, {
repoName: tutorialStep === 3 ? selectedRepo : indexedRepo,
repoName: selectedRepo,
})}
hint={t(tutorialSteps[tutorialStep].hint[0])}
/>
Expand Down
7 changes: 5 additions & 2 deletions client/src/Project/EmptyProject.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { memo, useCallback, useContext } from 'react';
import { Trans, useTranslation } from 'react-i18next';
import Header from '../components/Header';
import { PlusSignIcon, ShapesIcon } from '../icons';
import { ShapesIcon } from '../icons';
import Button from '../components/Button';
import { CommandBarContext } from '../context/commandBarContext';
import { CommandBarStepEnum } from '../types/general';
Expand All @@ -12,10 +12,13 @@ type Props = {};
const EmptyProject = ({}: Props) => {
useTranslation();
const shortcut = useShortcuts(['cmd']);
const { setIsVisible } = useContext(CommandBarContext.Handlers);
const { setIsVisible, setChosenStep } = useContext(
CommandBarContext.Handlers,
);

const openCommandBar = useCallback(() => {
setIsVisible(true);
setChosenStep({ id: CommandBarStepEnum.MANAGE_REPOS });
}, []);

return (
Expand Down
8 changes: 1 addition & 7 deletions client/src/consts/tutorialSteps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,7 @@ export const tutorialSteps = [
{
title: 'Indexing in progress',
description:
'{{repoName}} is currently indexing as soon as it is finished you will be able to add it to your project.',
'{{repoName}} is currently indexing as soon as it is finished it will be added to your project.',
hint: [],
},
{
title: 'Add to project',
description:
'{{repoName}} has finished indexing and you can use it in your projects now.',
hint: ['Start by selecting again and pressing Enter (↵) on your keyboard.'],
},
];
10 changes: 8 additions & 2 deletions client/src/context/providers/RepositoriesContextProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { splitPath } from '../../utils';
import { RepositoryIcon } from '../../icons';
import { DeviceContext } from '../deviceContext';
import { ProjectContext } from '../projectContext';
import { getIndexedRepos } from '../../services/api';
import { addRepoToProject, getIndexedRepos } from '../../services/api';

type Props = {};

Expand All @@ -41,6 +41,11 @@ const RepositoriesContextProvider = ({
const data = JSON.parse(ev.data);
if (data.ev?.status_change === SyncStatus.Done) {
if (!data.rsync) {
if (project?.id) {
addRepoToProject(project.id, data.ref).finally(() => {
refreshCurrentProjectRepos();
});
}
toast(t('Repository indexed'), {
id: `${data.ref}-indexed`,
description: (
Expand All @@ -52,7 +57,8 @@ const RepositoriesContextProvider = ({
}}
>
<span className="text-label-base body-s-b">repoName</span> has
finished indexing. You can use it in your projects now.
finished indexing and was added to the context of the current
project. You can also use it in your other projects now.
</Trans>
),
icon: <RepositoryIcon sizeClassName="w-4 h-4" />,
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 @@ -711,5 +711,7 @@
"Back to current": "Back to current",
"Go to current state": "Go to current state",
"Continue from this state": "Continue from this state",
"Restore session": "Restore session"
"Restore session": "Restore session",
"<0>repoName</0> has finished indexing and was added to the context of the current project. You can also use it in your other projects now.": "<0>repoName</0> has finished indexing and was added to the context of the current project. You can also use it in your other projects now.",
"{{repoName}} is currently indexing as soon as it is finished it will be added to your project.": "{{repoName}} is currently indexing as soon as it is finished it will be added to your project."
}
4 changes: 3 additions & 1 deletion client/src/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -696,5 +696,7 @@
"Current": "Actual",
"Back to current": "Volver a la corriente",
"Go to current state": "Ir al estado actual",
"Continue from this state": "Continuar desde este estado"
"Continue from this state": "Continuar desde este estado",
"<0>repoName</0> has finished indexing and was added to the context of the current project. You can also use it in your other projects now.": "<0> Reponame </0> ha terminado de indexación y se agregó al contexto del proyecto actual. También puede usarlo en sus otros proyectos ahora.",
"{{repoName}} is currently indexing as soon as it is finished it will be added to your project.": "{{Reponame}} actualmente está indexando tan pronto como finalice, se agregará a su proyecto."
}
4 changes: 3 additions & 1 deletion client/src/locales/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -659,5 +659,7 @@
"Current": "Attuale",
"Back to current": "Torna alla corrente",
"Go to current state": "Vai allo stato attuale",
"Continue from this state": "Continua da questo stato"
"Continue from this state": "Continua da questo stato",
"<0>repoName</0> has finished indexing and was added to the context of the current project. You can also use it in your other projects now.": "<0> Reponame </0> ha terminato l'indicizzazione ed è stato aggiunto al contesto dell'attuale progetto. Ora puoi anche usarlo nei tuoi altri progetti.",
"{{repoName}} is currently indexing as soon as it is finished it will be added to your project.": "{{Reponame}} sta attualmente indicizzando non appena sarà finito, verrà aggiunto al tuo progetto."
}
4 changes: 3 additions & 1 deletion client/src/locales/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -678,5 +678,7 @@
"Current": "現在",
"Back to current": "現在に戻ります",
"Go to current state": "現在の状態に移動します",
"Continue from this state": "この状態から続けます"
"Continue from this state": "この状態から続けます",
"<0>repoName</0> has finished indexing and was added to the context of the current project. You can also use it in your other projects now.": "<0>レプネーム</0>はインデックス作成が終了し、現在のプロジェクトのコンテキストに追加されました。 今すぐ他のプロジェクトで使用することもできます。",
"{{repoName}} is currently indexing as soon as it is finished it will be added to your project.": "{{reponame}}は現在、完了するとすぐにインデックスを作成しています。プロジェクトに追加されます。"
}
4 changes: 3 additions & 1 deletion client/src/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -689,5 +689,7 @@
"Current": "当前的",
"Back to current": "回到电流",
"Go to current state": "进入当前状态",
"Restore session": "还原会话"
"Restore session": "还原会话",
"<0>repoName</0> has finished indexing and was added to the context of the current project. You can also use it in your other projects now.": "<0> reponame </0>已完成索引,并已添加到当前项目的上下文中。 您现在也可以在其他项目中使用它。",
"{{repoName}} is currently indexing as soon as it is finished it will be added to your project.": "{{reponame}}当前索引一旦完成后,它将被添加到您的项目中。"
}

0 comments on commit 596b073

Please sign in to comment.