mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-09-04 19:54:32 +08:00
feat(changelog): Link to changelog before and after updates
Summary: Link to the changelog, and add a new notification which appears after updates are installed Test Plan: No tests to see here.. Reviewers: evan Reviewed By: evan Differential Revision: https://phab.nylas.com/D2201
This commit is contained in:
parent
08e2e7581a
commit
edaf751c3b
10 changed files with 85 additions and 29 deletions
|
@ -26,9 +26,12 @@ module.exports =
|
|||
icon: 'fa-inbox',
|
||||
actions: [{
|
||||
label: 'Yes'
|
||||
dismisses: true
|
||||
default: true
|
||||
id: NOTIF_ACTION_YES
|
||||
},{
|
||||
label: 'Not Now'
|
||||
dismisses: true
|
||||
id: NOTIF_ACTION_NO
|
||||
}]
|
||||
|
||||
|
|
|
@ -9,23 +9,52 @@ module.exports =
|
|||
updater = remote.getGlobal('application').autoUpdateManager
|
||||
@_unlisten = Actions.notificationActionTaken.listen(@_onNotificationActionTaken, @)
|
||||
|
||||
configVersion = atom.config.get("lastVersion")
|
||||
currentVersion = atom.getVersion()
|
||||
if configVersion and configVersion isnt currentVersion
|
||||
atom.config.set("lastVersion", currentVersion)
|
||||
@displayThanksNotification()
|
||||
|
||||
if updater.getState() is 'update-available'
|
||||
@displayNotification(updater.releaseVersion)
|
||||
|
||||
atom.onUpdateAvailable ({releaseVersion, releaseNotes} = {}) =>
|
||||
@displayNotification(releaseVersion)
|
||||
|
||||
displayThanksNotification: ->
|
||||
Actions.postNotification
|
||||
type: 'info'
|
||||
tag: 'app-update'
|
||||
sticky: true
|
||||
message: "You're running the latest version of N1 - view the changelog to see what's new.",
|
||||
icon: 'fa-magic'
|
||||
actions: [{
|
||||
dismisses: true
|
||||
label: 'Thanks'
|
||||
id: 'release-bar:no-op'
|
||||
},{
|
||||
default: true
|
||||
dismisses: true
|
||||
label: 'See What\'s New'
|
||||
id: 'release-bar:view-changelog'
|
||||
}]
|
||||
|
||||
displayNotification: (version) ->
|
||||
version = if version then "(#{version})" else ''
|
||||
Actions.postNotification
|
||||
type: 'info'
|
||||
tag: 'app-update'
|
||||
sticky: true
|
||||
message: "An update to N1 is available #{version} - Restart now to update!",
|
||||
message: "An update to N1 is available #{version} - click to update now!",
|
||||
icon: 'fa-flag'
|
||||
actions: [{
|
||||
label: 'Install'
|
||||
label: 'Install Now'
|
||||
dismisses: true
|
||||
default: true
|
||||
id: 'release-bar:install-update'
|
||||
},{
|
||||
label: 'See What\'s New'
|
||||
id: 'release-bar:view-changelog'
|
||||
}]
|
||||
|
||||
deactivate: ->
|
||||
|
@ -35,3 +64,6 @@ module.exports =
|
|||
if action.id is 'release-bar:install-update'
|
||||
ipc.send 'command', 'application:install-update'
|
||||
true
|
||||
if action.id is 'release-bar:view-changelog'
|
||||
require('shell').openExternal('https://github.com/nylas/N1/blob/master/CHANGELOG.md')
|
||||
false
|
||||
|
|
|
@ -8,15 +8,32 @@ class NotificationStickyItem extends React.Component
|
|||
render: =>
|
||||
notif = @props.notification
|
||||
iconClass = if notif.icon then "fa #{notif.icon}" else ""
|
||||
actionDefault = null
|
||||
actionComponents = notif.actions?.map (action) =>
|
||||
<a className="action" key={action.label} onClick={=> @_fireItemAction(notif, action)}>{action.label}</a>
|
||||
classname = "action "
|
||||
if action.default
|
||||
actionDefault = action
|
||||
classname += "default"
|
||||
|
||||
<div className={"notifications-sticky-item notification-#{notif.type}"}>
|
||||
<i className={iconClass}></i><span>{notif.message}</span>{actionComponents}
|
||||
</div>
|
||||
<a className={classname}
|
||||
key={action.label}
|
||||
onClick={=> @_fireItemAction(notif, action)}>
|
||||
{action.label}
|
||||
</a>
|
||||
|
||||
if actionDefault
|
||||
<div className={"notifications-sticky-item notification-#{notif.type} has-default-action"}
|
||||
onClick={=> @_fireItemAction(notif, actionDefault)}>
|
||||
<i className={iconClass}></i><span>{notif.message}</span>{actionComponents}
|
||||
</div>
|
||||
else
|
||||
<div className={"notifications-sticky-item notification-#{notif.type}"}>
|
||||
<i className={iconClass}></i><span>{notif.message}</span>{actionComponents}
|
||||
</div>
|
||||
|
||||
_fireItemAction: (notification, action) =>
|
||||
Actions.notificationActionTaken({notification, action})
|
||||
event.stopPropagation()
|
||||
|
||||
|
||||
class NotificationStickyBar extends React.Component
|
||||
|
|
|
@ -44,7 +44,7 @@ NotificationStore = Reflux.createStore
|
|||
# your package should listen to notificationActionTaken and check the
|
||||
# notification and action objects.
|
||||
@listenTo Actions.notificationActionTaken, ({notification, action}) =>
|
||||
@_removeNotification(notification)()
|
||||
@_removeNotification(notification)() if action.dismisses
|
||||
@listenTo Actions.postNotification, (data) =>
|
||||
@_postNotification(new Notification(data))
|
||||
@listenTo Actions.multiWindowNotification, (data={}, context={}) =>
|
||||
|
|
|
@ -148,34 +148,35 @@
|
|||
.notifications-sticky-item {
|
||||
display:block;
|
||||
font-size: @font-size-base;
|
||||
line-height: @line-height-base;
|
||||
padding: @padding-base-vertical @padding-base-horizontal @padding-base-vertical @padding-base-horizontal;
|
||||
color:@text-color-inverse;
|
||||
border-top:1px solid rgba(0,0,0,0.25);
|
||||
border-bottom:1px solid rgba(0,0,0,0.25);
|
||||
padding-left: @padding-base-horizontal;
|
||||
line-height: @line-height-base * 1.5;
|
||||
a {
|
||||
float:right;
|
||||
font-size:13px;
|
||||
background-color: rgba(255,255,255,0.2);
|
||||
color:@text-color-inverse;
|
||||
border-radius: 4px;
|
||||
padding:1px;
|
||||
padding-left:6px;
|
||||
padding-right:6px;
|
||||
margin-left:10px;
|
||||
border-top:1px solid transparent;
|
||||
border-bottom:none;
|
||||
padding: 0 @padding-base-horizontal;
|
||||
}
|
||||
a:hover {
|
||||
background-color: rgba(0,0,0,0.2);
|
||||
border-top:1px solid rgba(0,0,0,0.35);
|
||||
background-color: rgba(255,255,255,0.15);
|
||||
text-decoration:none;
|
||||
color:@text-color-inverse;
|
||||
}
|
||||
|
||||
a.default {
|
||||
background-color: rgba(0,0,0,0.15);
|
||||
}
|
||||
a.default:hover {
|
||||
background-color: rgba(255,255,255,0.15);
|
||||
}
|
||||
i {
|
||||
margin-right:@padding-base-horizontal;
|
||||
}
|
||||
|
||||
&.has-default-action:hover {
|
||||
-webkit-filter: brightness(110%);
|
||||
cursor:default;
|
||||
}
|
||||
}
|
||||
}
|
||||
body.platform-win32 {
|
||||
|
|
|
@ -82,7 +82,7 @@ class AutoUpdateManager
|
|||
@setState(UnsupportedState)
|
||||
|
||||
emitUpdateAvailableEvent: (windows...) ->
|
||||
return unless @releaseVersion? and @releaseNotes
|
||||
return unless @releaseVersion
|
||||
for atomWindow in windows
|
||||
atomWindow.sendMessage('update-available', {@releaseVersion, @releaseNotes})
|
||||
|
||||
|
@ -95,7 +95,6 @@ class AutoUpdateManager
|
|||
@state
|
||||
|
||||
check: ({hidePopups}={}) ->
|
||||
console.log "Checking for updates..."
|
||||
unless hidePopups
|
||||
autoUpdater.once 'update-not-available', @onUpdateNotAvailable
|
||||
autoUpdater.once 'error', @onUpdateError
|
||||
|
|
|
@ -51,12 +51,11 @@ class AutoUpdater
|
|||
@emit 'update-not-available'
|
||||
return
|
||||
|
||||
@emit 'update-available'
|
||||
@installUpdate (error) =>
|
||||
if error?
|
||||
@emit 'update-not-available'
|
||||
return
|
||||
|
||||
@emit 'update-available'
|
||||
@emit 'update-downloaded', {}, update.releaseNotes, update.version, new Date(), 'https://atom.io', => @quitAndInstall()
|
||||
@emit 'update-downloaded', {}, update.releaseNotes, update.version
|
||||
|
||||
module.exports = new AutoUpdater()
|
||||
|
|
|
@ -357,10 +357,13 @@ class Actions
|
|||
icon: 'fa-inbox',
|
||||
actions: [{
|
||||
label: 'Yes'
|
||||
default: true
|
||||
dismisses: true
|
||||
id: NOTIF_ACTION_YES
|
||||
},{
|
||||
label: 'Not Now'
|
||||
id: NOTIF_ACTION_NO
|
||||
label: 'More Info'
|
||||
dismisses: false
|
||||
id: NOTIF_ACTION_MORE_INFO
|
||||
}]
|
||||
|
||||
```
|
||||
|
|
|
@ -231,6 +231,8 @@ class NylasAPI
|
|||
account and sign in again.",
|
||||
icon: 'fa-sign-out'
|
||||
actions: [{
|
||||
default: true
|
||||
dismisses: true
|
||||
label: 'Unlink'
|
||||
id: '401:unlink'
|
||||
}]
|
||||
|
|
|
@ -221,7 +221,7 @@ class WindowEventHandler
|
|||
icon: 'fa-flask'
|
||||
type: 'developer'
|
||||
sticky: true
|
||||
actions: [{label: 'Thanks', id: 'ok'}]
|
||||
actions: [{label: 'Thanks', id: 'ok', dismisses: true, default: true}]
|
||||
message: "N1 is running with debug flags enabled (slower). Packages in
|
||||
~/.nylas/dev/packages will be loaded. Have fun!"
|
||||
else
|
||||
|
|
Loading…
Add table
Reference in a new issue