Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feat: Add app changelog parameter
Signed-off-by: Ferdinand Thiessen <[email protected]>
  • Loading branch information
susnux committed Mar 3, 2024
commit 8acd1c52d4da647c01e3f47db08a8702ae09d587
19 changes: 13 additions & 6 deletions src/Components/Notification.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,23 @@
</template>

<script>
import { showError } from '@nextcloud/dialogs'
import { emit } from '@nextcloud/event-bus'
import { loadState } from '@nextcloud/initial-state'
import { generateOcsUrl, generateFilePath } from '@nextcloud/router'
import { Howl } from 'howler'

import axios from '@nextcloud/axios'
import moment from '@nextcloud/moment'
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
import NcRichText from '@nextcloud/vue/dist/Components/NcRichText.js'
import Close from 'vue-material-design-icons/Close.vue'
import Message from 'vue-material-design-icons/Message.vue'
import { showError } from '@nextcloud/dialogs'
import { loadState } from '@nextcloud/initial-state'
import { Howl } from 'howler'
import Action from './Action.vue'
import { generateOcsUrl, generateFilePath } from '@nextcloud/router'
import moment from '@nextcloud/moment'
import DefaultParameter from './Parameters/DefaultParameter.vue'
import File from './Parameters/File.vue'
import User from './Parameters/User.vue'
import { emit } from '@nextcloud/event-bus'
import AppChangelog from './Parameters/AppChangelog.vue'

export default {
name: 'Notification',
Expand Down Expand Up @@ -305,6 +307,11 @@ export default {
component: File,
props: parameters[p],
}
} else if (type === 'app-changelog') {
richParameters[p] = {
component: AppChangelog,
props: { ...parameters[p], dismissNotification: this.onDismissNotification },
}
} else {
richParameters[p] = {
component: DefaultParameter,
Expand Down
80 changes: 80 additions & 0 deletions src/Components/Parameters/AppChangelog.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<!--
- @copyright Copyright (c) 2024 Ferdinand Thiessen <[email protected]>
-
- @author Ferdinand Thiessen <[email protected]>
-
- @license AGPL-3.0-or-later
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-->

<template>
<NcButton v-if="canShowChangelog" class="app-changelog-button" @click="handleClick">
{{ t('notifications', 'See what\'s new for {app}', { app: name }) }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't cheat this in here. It should be part of the message itself.

Also actions exist for buttons, as explained in the server pr

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea was to make this an object (clients can fetch using OCS) so that clients do not need to move the user to a web browser. If they do not support it I expected them to use the already parsed message.

</NcButton>
</template>

<script>
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'

export default {
name: 'AppChangelog',

components: {
NcButton,
},

props: {
type: {
type: String,
required: true,
},
id: {
type: String,
required: true,
},
name: {
type: String,
required: true,
},
dismissNotification: {
type: Function,
required: false,
default: () => {},
}
},

setup() {
// Non reactive props
return {
canShowChangelog: window.OCA?.UpdateNotification?.showAppChangelogDialog !== undefined,
}
},

methods: {
async handleClick() {
if (await window.OCA.UpdateNotification.showAppChangelogDialog(this.id)) {
this.dismissNotification()
}
},
},
}
</script>

<style scoped>
.app-changelog-button {
display: block;
margin-top: 12px;
}
</style>