aboutsummaryrefslogtreecommitdiffstats
path: root/apps/updatenotification/src/update-notification-legacy.ts
diff options
context:
space:
mode:
authorFerdinand Thiessen <opensource@fthiessen.de>2024-09-24 17:23:48 +0200
committerFerdinand Thiessen <opensource@fthiessen.de>2024-09-24 18:53:49 +0200
commit71f1e0cb9c62574f39f6c458f286041184aae9b5 (patch)
tree4e4f5b9ed5f92068940cfcc3d0d7aa03b0ddeb04 /apps/updatenotification/src/update-notification-legacy.ts
parent280f6df66c199b9e72c23ffa921bbdad7c68d3c0 (diff)
downloadnextcloud-server-71f1e0cb9c62574f39f6c458f286041184aae9b5.tar.gz
nextcloud-server-71f1e0cb9c62574f39f6c458f286041184aae9b5.zip
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>
Diffstat (limited to 'apps/updatenotification/src/update-notification-legacy.ts')
-rw-r--r--apps/updatenotification/src/update-notification-legacy.ts24
1 files changed, 24 insertions, 0 deletions
diff --git a/apps/updatenotification/src/update-notification-legacy.ts b/apps/updatenotification/src/update-notification-legacy.ts
new file mode 100644
index 00000000000..5809c1761dc
--- /dev/null
+++ b/apps/updatenotification/src/update-notification-legacy.ts
@@ -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') })
+})