Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

feat: show error if library cannot be connected #543

Merged
merged 3 commits into from
Jun 14, 2018
Merged
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
88 changes: 62 additions & 26 deletions src/electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,20 +270,38 @@ const userStore = new ElectronStore();
const project = Project.from(message.payload);
const library = project.getPatternLibrary();

const analysis = await Analyzer.analyze(path, {
getGobalEnumOptionId: (patternId, contextId) =>
library.assignEnumOptionId(patternId, contextId),
getGlobalPatternId: contextId => library.assignPatternId(contextId),
getGlobalPropertyId: (patternId, contextId) =>
library.assignPropertyId(patternId, contextId),
getGlobalSlotId: (patternId, contextId) => library.assignSlotId(patternId, contextId)
});
try {
const analysis = await Analyzer.analyze(path, {
getGobalEnumOptionId: (patternId, contextId) =>
library.assignEnumOptionId(patternId, contextId),
getGlobalPatternId: contextId => library.assignPatternId(contextId),
getGlobalPropertyId: (patternId, contextId) =>
library.assignPropertyId(patternId, contextId),
getGlobalSlotId: (patternId, contextId) =>
library.assignSlotId(patternId, contextId)
});

send({
type: ServerMessageType.ConnectPatternLibraryResponse,
id: message.id,
payload: analysis
});
send({
type: ServerMessageType.ConnectPatternLibraryResponse,
id: message.id,
payload: analysis
});
} catch {
dialog.showMessageBox(
{
message:
'Sorry, this seems to be an uncompatible library. Learn more about supported component libraries on github.com/meetalva',
buttons: ['OK', 'Learn more']
},
response => {
if (response === 1) {
shell.openExternal(
'https://github.com/meetalva/alva#pattern-library-requirements'
);
}
}
);
}

break;
}
Expand All @@ -305,20 +323,38 @@ const userStore = new ElectronStore();
return;
}

const analysis = await Analyzer.analyze(connection.path, {
getGobalEnumOptionId: (patternId, contextId) =>
library.assignEnumOptionId(patternId, contextId),
getGlobalPatternId: contextId => library.assignPatternId(contextId),
getGlobalPropertyId: (patternId, contextId) =>
library.assignPropertyId(patternId, contextId),
getGlobalSlotId: (patternId, contextId) => library.assignSlotId(patternId, contextId)
});
try {
const analysis = await Analyzer.analyze(connection.path, {
getGobalEnumOptionId: (patternId, contextId) =>
library.assignEnumOptionId(patternId, contextId),
getGlobalPatternId: contextId => library.assignPatternId(contextId),
getGlobalPropertyId: (patternId, contextId) =>
library.assignPropertyId(patternId, contextId),
getGlobalSlotId: (patternId, contextId) =>
library.assignSlotId(patternId, contextId)
});

send({
type: ServerMessageType.ConnectPatternLibraryResponse,
id: message.id,
payload: analysis
});
send({
type: ServerMessageType.ConnectPatternLibraryResponse,
id: message.id,
payload: analysis
});
} catch {
dialog.showMessageBox(
{
message:
'Sorry, this seems to be an uncompatible library. Learn more about supported component libraries on github.com/meetalva',
buttons: ['OK', 'Learn more']
},
response => {
if (response === 1) {
shell.openExternal(
'https://github.com/meetalva/alva#pattern-library-requirements'
);
}
}
);
}

break;
}
Expand Down