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

Commit

Permalink
feat: show error if library cannot be connected (#543)
Browse files Browse the repository at this point in the history
* feat: show error if library cannot be connected

* fix: make ts happy

* fix: try entire analysis and send
  • Loading branch information
tilmx authored and marionebl committed Jun 14, 2018
1 parent 56a60cd commit 9ff88e9
Showing 1 changed file with 62 additions and 26 deletions.
88 changes: 62 additions & 26 deletions src/electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,20 +330,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 @@ -365,20 +383,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

0 comments on commit 9ff88e9

Please sign in to comment.