Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
show welcome notification on first launch with dependency check
- check atom-ide-ui dependency - TODO programatically input text in settings page
- Loading branch information
Showing
3 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
node_modules | ||
npm-debug.log | ||
WELCOME_SHOWN |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// show welcome message on first installation | ||
const path = require('path') | ||
const fs = require('fs') | ||
|
||
const WELCOME_SHOWN = path.join(__dirname, '..', 'WELCOME_SHOWN') | ||
|
||
const generateWelcomeMsg = () => { | ||
return `## Welcome to ide-html\n\nQuick start for ide-html:\n${[ | ||
'Open a HTML file from the Project', | ||
'Dispatch command `Outline View: Toggle`', | ||
].map((str, i) => `${i}. ${str}\n`).join('') | ||
}\nHappy Using Atom IDE : )` | ||
} | ||
|
||
const generateWarnMsg = () => { | ||
return `## Welcome to ide-html\n\nPlease install following requirements:\n${[ | ||
'[`atom-ide-ui`](https://atom.io/packages/atom-ide-ui)', | ||
].map((str, i) => `${i}. ${str}\n`).join('') | ||
}\nso that ide-html can work properly` | ||
} | ||
|
||
const helpButton = [ | ||
{ | ||
text: ' Help', | ||
onDidClick: () => { atom.commands.dispatch( | ||
atom.views.getView(atom.workspace.getActivePane()), | ||
'ide-html:help' | ||
)}, | ||
className: 'btn btn-success btn-lg icon-light-bulb', | ||
}, | ||
] | ||
|
||
const settingsButton = [ | ||
{ | ||
text: ' Open Settings Page', | ||
onDidClick: () => { | ||
atom.commands.dispatch( | ||
atom.views.getView(atom.workspace.getActivePane()), | ||
'settings-view:install-packages-and-themes' | ||
) | ||
}, | ||
className: 'btn btn-success btn-lg icon-tools', | ||
}, | ||
] | ||
|
||
const showWelcomeNotification = () => { | ||
try { | ||
fs.accessSync(WELCOME_SHOWN) | ||
} catch (err) { | ||
if (atom.packages.isPackageLoaded('atom-ide-ui')) { | ||
atom.notifications.addSuccess( | ||
generateWelcomeMsg(), | ||
{ | ||
buttons: helpButton, | ||
dismissable: true, | ||
icon: 'thumbsup', | ||
} | ||
) | ||
fs.closeSync(fs.openSync(WELCOME_SHOWN, 'w')) | ||
} else { | ||
atom.notifications.addWarning( | ||
generateWarnMsg(), | ||
{ | ||
buttons: settingsButton, | ||
dismissable: true, | ||
icon: 'info', | ||
} | ||
) | ||
} | ||
} | ||
} | ||
|
||
|
||
module.exports = { | ||
showWelcomeNotification, | ||
} |