Skip to content

Commit

Permalink
fix: sort multi-skill bots in list by first opening of root (without …
Browse files Browse the repository at this point in the history
…skills) (microsoft#7185)

* add isRootBot argument to fetching projects

* Update Home.tsx

* Update project.test.ts

* Update en-US.json
  • Loading branch information
beyackle authored Apr 21, 2021
1 parent 6759ec0 commit 777396c
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 127 deletions.
6 changes: 3 additions & 3 deletions Composer/packages/client/src/pages/home/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ const resources = [
];

const Home: React.FC<RouteComponentProps> = () => {
const projectId = useRecoilValue(currentProjectIdState);
const botName = useRecoilValue(botDisplayNameState(projectId));
const projectId = useRecoilValue<string>(currentProjectIdState);
const botName = useRecoilValue<string>(botDisplayNameState(projectId));
const recentProjects = useRecoilValue(recentProjectsState);
const feed = useRecoilValue(feedState);
const templateId = useRecoilValue(templateIdState);
const templateId = useRecoilValue<string>(templateIdState);
const { openProject, setCreationFlowStatus, setCreationFlowType, setWarnAboutDotNet } = useRecoilValue(
dispatcherState
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,10 +350,11 @@ export const loadProjectData = async (data) => {

export const fetchProjectDataByPath = async (
path: string,
storageId
storageId,
isRootBot: boolean
): Promise<{ botFiles: any; projectData: any; error: any }> => {
try {
const response = await httpClient.put(`/projects/open`, { path, storageId });
const response = await httpClient.put(`/projects/open`, { path, storageId, isRootBot });
const projectData = await loadProjectData(response.data);
return projectData;
} catch (ex) {
Expand Down Expand Up @@ -580,7 +581,7 @@ export const openRemoteSkill = async (

export const openLocalSkill = async (callbackHelpers, pathToBot: string, storageId, botNameIdentifier: string) => {
const { set } = callbackHelpers;
const { projectData, botFiles, error } = await fetchProjectDataByPath(pathToBot, storageId);
const { projectData, botFiles, error } = await fetchProjectDataByPath(pathToBot, storageId, false);

if (error) {
throw error;
Expand Down Expand Up @@ -801,7 +802,7 @@ export const postRootBotCreation = async (
};

export const openRootBotAndSkillsByPath = async (callbackHelpers: CallbackInterface, path: string, storageId) => {
const data = await fetchProjectDataByPath(path, storageId);
const data = await fetchProjectDataByPath(path, storageId, true);
if (data.error) {
throw data.error;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ describe('get bot project', () => {
const mockReq = {
params: {},
query: {},
body: { storageId: 'default', path: Path.resolve(__dirname, '../../__mocks__/samplebots/bot1') },
body: { storageId: 'default', path: Path.resolve(__dirname, '../../__mocks__/samplebots/bot1'), isRootBot: true },
} as Request;
await ProjectController.openProject(mockReq, mockRes);
expect(mockRes.status).toHaveBeenCalledWith(200);
Expand Down Expand Up @@ -143,7 +143,7 @@ describe('open bot operation', () => {
const mockReq = {
params: {},
query: {},
body: { storageId: 'default', path: Path.resolve(__dirname, '../../__mocks__/samplebots/bot1') },
body: { storageId: 'default', path: Path.resolve(__dirname, '../../__mocks__/samplebots/bot1'), isRootBot: true },
} as Request;
await ProjectController.openProject(mockReq, mockRes);
expect(mockRes.status).toHaveBeenCalledWith(200);
Expand Down
4 changes: 2 additions & 2 deletions Composer/packages/server/src/controllers/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ async function createProject(req: Request, res: Response) {
await BotProjectService.cleanProject(locationRef);
const newProjRef = await getNewProjRef(templateDir, templateId, locationRef, user, locale);

const id = await BotProjectService.openProject(newProjRef, user);
const id = await BotProjectService.openProject(newProjRef, user, true);
// in the case of a remote template, we need to update the eTag and alias used by the import mechanism
BotProjectService.setProjectLocationData(id, { alias, eTag });
const currentProject = await BotProjectService.getProjectById(id, user);
Expand Down Expand Up @@ -207,7 +207,7 @@ async function openProject(req: Request, res: Response) {
};

try {
const id = await BotProjectService.openProject(location, user);
const id = await BotProjectService.openProject(location, user, req.body.isRootBot);
const currentProject = await BotProjectService.getProjectById(id, user);
if (currentProject !== undefined) {
await currentProject.init();
Expand Down
Loading

0 comments on commit 777396c

Please sign in to comment.