refactor(updatenotification): Migrate legacy code
1. Remove hook usage and just provide an initial state 2. Replace jQuery code with modern non-deprecated frontend code Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>pull/48323/head
parent
280f6df66c
commit
71f1e0cb9c
@ -1,15 +0,0 @@
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-FileCopyrightText: 2015-2016 ownCloud, Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
/**
|
||||
* This only gets loaded if an update is available and the notifications app is not enabled for the user.
|
||||
*/
|
||||
window.addEventListener('DOMContentLoaded', function(){
|
||||
var text = t('core', '{version} is available. Get more information on how to update.', {version: oc_updateState.updateVersion}),
|
||||
element = $('<a>').attr('href', oc_updateState.updateLink).attr('target','_blank').text(text);
|
||||
|
||||
OC.Notification.showHtml(element.prop('outerHTML'), { type: 'error' });
|
||||
});
|
||||
@ -0,0 +1,24 @@
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
import { showInfo } from '@nextcloud/dialogs'
|
||||
import { loadState } from '@nextcloud/initial-state'
|
||||
import { t } from '@nextcloud/l10n'
|
||||
|
||||
interface IUpdateNotificationState {
|
||||
updateLink: string
|
||||
updateVersion: string
|
||||
}
|
||||
|
||||
/**
|
||||
* This only gets loaded if an update is available and the notifications app is not enabled for the user.
|
||||
*/
|
||||
window.addEventListener('DOMContentLoaded', function() {
|
||||
const { updateLink, updateVersion } = loadState<IUpdateNotificationState>('updatenotification', 'updateState')
|
||||
const text = t('core', '{version} is available. Get more information on how to update.', { version: updateVersion })
|
||||
|
||||
// On click open the update link in a new tab
|
||||
showInfo(text, { onClick: () => window.open(updateLink, '_blank') })
|
||||
})
|
||||
Loading…
Reference in New Issue