forked from OctoLinker/OctoLinker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add upcoming permission notification (OctoLinker#875)
- Loading branch information
1 parent
490b165
commit f051bf8
Showing
2 changed files
with
38 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
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,36 @@ | ||
import * as storage from '@octolinker/helper-settings'; | ||
import { showNotification } from '@octolinker/user-interface'; | ||
|
||
let notificationEl; | ||
|
||
document.body.addEventListener('click', event => { | ||
if ( | ||
event.target.classList.contains('js-hide-update-notice') || | ||
event.target.classList.contains('js-flash-close-update-notice') | ||
) { | ||
storage.set('showUpdateNoticePermissionUpdate', false); | ||
if (notificationEl) { | ||
notificationEl.remove(); | ||
} | ||
} | ||
}); | ||
|
||
export default async function() { | ||
if (navigator.userAgent.includes('Firefox')) { | ||
return; | ||
} | ||
|
||
const showUpdateNoticePermissionUpdate = storage.get( | ||
'showUpdateNoticePermissionUpdate', | ||
); | ||
|
||
if (showUpdateNoticePermissionUpdate === false) { | ||
return; | ||
} | ||
|
||
const url = 'https://github.com/OctoLinker/OctoLinker/issues/870'; | ||
|
||
const body = `<b>Important</b>: Our next release will ask for additional permission to access api.github.com. <a href="${url}" target="_blank" class="js-hide-update-notice">Why the change?</a>`; | ||
|
||
notificationEl = showNotification({ body, id: 'update-notice' }); | ||
} |