0
0
Fork 0
mirror of https://github.com/nextcloud/server.git synced 2025-04-28 02:52:59 +00:00
nextcloud_server/apps/updatenotification/src/update-notification-legacy.ts
Ferdinand Thiessen 71f1e0cb9c
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>
2024-09-24 18:53:49 +02:00

24 lines
870 B
TypeScript

/**
* 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') })
})