Skip to content

Commit

Permalink
fix: correctly read project paths on Windows (microsoft#4483)
Browse files Browse the repository at this point in the history
* Update en-US.json

* add serverside path check for Windows and some null checks
  • Loading branch information
beyackle authored Oct 22, 2020
1 parent 2a89e74 commit 73e479b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,12 @@ export const ProjectTree: React.FC<Props> = ({
const botProjectSpace = useRecoilValue(botProjectSpaceSelector);

const notificationMap: { [projectId: string]: { [dialogId: string]: Diagnostic[] } } = {};

for (const bot of projectCollection) {
notificationMap[bot.projectId] = {};

const matchingBot = botProjectSpace.filter((project) => project.projectId === bot.projectId)[0];
if (matchingBot == null) continue; // should never happen, but just to be safe
const matchingBot = botProjectSpace?.filter((project) => project.projectId === bot.projectId)[0];
if (matchingBot == null) continue;

for (const dialog of matchingBot.dialogs) {
const dialogId = dialog.id;
Expand All @@ -151,15 +152,15 @@ export const ProjectTree: React.FC<Props> = ({
}

const dialogHasWarnings = (dialog: DialogInfo) => {
notificationMap[currentProjectId][dialog.id].some((diag) => diag.severity === DiagnosticSeverity.Warning);
notificationMap[currentProjectId][dialog.id]?.some((diag) => diag.severity === DiagnosticSeverity.Warning);
};

const botHasWarnings = (bot: BotInProject) => {
return bot.dialogs.some(dialogHasWarnings);
};

const dialogHasErrors = (dialog: DialogInfo) => {
notificationMap[currentProjectId][dialog.id].some((diag) => diag.severity === DiagnosticSeverity.Error);
notificationMap[currentProjectId][dialog.id]?.some((diag) => diag.severity === DiagnosticSeverity.Error);
};

const botHasErrors = (bot: BotInProject) => {
Expand Down Expand Up @@ -212,11 +213,11 @@ export const ProjectTree: React.FC<Props> = ({

const renderDialogHeader = (skillId: string, dialog: DialogInfo) => {
const warningContent = notificationMap[currentProjectId][dialog.id]
.filter((diag) => diag.severity === DiagnosticSeverity.Warning)
?.filter((diag) => diag.severity === DiagnosticSeverity.Warning)
.map((diag) => diag.message)
.join(',');
const errorContent = notificationMap[currentProjectId][dialog.id]
.filter((diag) => diag.severity === DiagnosticSeverity.Error)
?.filter((diag) => diag.severity === DiagnosticSeverity.Error)
.map((diag) => diag.message)
.join(',');

Expand Down
3 changes: 2 additions & 1 deletion Composer/packages/server/src/controllers/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,11 @@ async function openProject(req: Request, res: Response) {
return;
}
const user = await ExtensionContext.getUserFromRequest(req);
const path = process.platform === 'win32' ? req.body.path.replace(/^\//, '') : req.body.path;

const location: LocationRef = {
storageId: req.body.storageId,
path: req.body.path,
path,
};

try {
Expand Down

0 comments on commit 73e479b

Please sign in to comment.