Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]
Copy link
Contributor

@srinaath srinaath Oct 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it better to put both error and warning content inside if(notificationMap[currentProjectId][dialog.id]) instead of typescript ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's about equivalent. I've gotten used to using ?. for cases like this.

.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