aboutsummaryrefslogtreecommitdiff
path: root/src/components
diff options
context:
space:
mode:
authormarcin mikołajczak <git@mkljczk.pl>2024-09-24 00:05:33 +0200
committermarcin mikołajczak <git@mkljczk.pl>2024-09-24 00:05:33 +0200
commit89fbaa159f29a7d175a5323eded29e20c9f3a752 (patch)
tree60a4354fd9c96cfbfb46f79ec6e8b4ce113bd7bf /src/components
parent9e45228823cd0fa7eb9388b0eb7780b9609edf66 (diff)
Allow adding bookmarks to folders
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
Diffstat (limited to 'src/components')
-rw-r--r--src/components/extra_buttons/extra_buttons.js7
-rw-r--r--src/components/extra_buttons/extra_buttons.vue4
-rw-r--r--src/components/status_bookmark_folder_menu/status_bookmark_folder_menu.js40
-rw-r--r--src/components/status_bookmark_folder_menu/status_bookmark_folder_menu.vue38
4 files changed, 88 insertions, 1 deletions
diff --git a/src/components/extra_buttons/extra_buttons.js b/src/components/extra_buttons/extra_buttons.js
index e2c88ceb..b3e1cb2b 100644
--- a/src/components/extra_buttons/extra_buttons.js
+++ b/src/components/extra_buttons/extra_buttons.js
@@ -1,6 +1,7 @@
import Popover from '../popover/popover.vue'
import genRandomSeed from '../../services/random_seed/random_seed.service.js'
import ConfirmModal from '../confirm_modal/confirm_modal.vue'
+import StatusBookmarkFolderMenu from '../status_bookmark_folder_menu/status_bookmark_folder_menu.vue'
import { library } from '@fortawesome/fontawesome-svg-core'
import {
faEllipsisH,
@@ -36,7 +37,8 @@ const ExtraButtons = {
props: ['status'],
components: {
Popover,
- ConfirmModal
+ ConfirmModal,
+ StatusBookmarkFolderMenu
},
data () {
return {
@@ -145,6 +147,9 @@ const ExtraButtons = {
canBookmark () {
return !!this.currentUser
},
+ bookmarkFolders () {
+ return this.$store.state.instance.pleromaBookmarkFoldersAvailable
+ },
statusLink () {
return `${this.$store.state.instance.server}${this.$router.resolve({ name: 'conversation', params: { id: this.status.id } }).href}`
},
diff --git a/src/components/extra_buttons/extra_buttons.vue b/src/components/extra_buttons/extra_buttons.vue
index 7b38d974..c030de0c 100644
--- a/src/components/extra_buttons/extra_buttons.vue
+++ b/src/components/extra_buttons/extra_buttons.vue
@@ -87,6 +87,10 @@
icon="bookmark"
/><span>{{ $t("status.unbookmark") }}</span>
</button>
+ <StatusBookmarkFolderMenu
+ v-if="status.bookmarked && bookmarkFolders"
+ :status="status"
+ />
</template>
<button
v-if="ownStatus && editingAvailable"
diff --git a/src/components/status_bookmark_folder_menu/status_bookmark_folder_menu.js b/src/components/status_bookmark_folder_menu/status_bookmark_folder_menu.js
new file mode 100644
index 00000000..16b414ac
--- /dev/null
+++ b/src/components/status_bookmark_folder_menu/status_bookmark_folder_menu.js
@@ -0,0 +1,40 @@
+import { library } from '@fortawesome/fontawesome-svg-core'
+import { faChevronRight } from '@fortawesome/free-solid-svg-icons'
+import { mapState } from 'vuex'
+
+import DialogModal from '../dialog_modal/dialog_modal.vue'
+import Popover from '../popover/popover.vue'
+
+library.add(faChevronRight)
+
+const StatusBookmarkFolderMenu = {
+ props: [
+ 'status'
+ ],
+ data () {
+ return {}
+ },
+ components: {
+ DialogModal,
+ Popover
+ },
+ computed: {
+ ...mapState({
+ folders: state => state.bookmarkFolders.allFolders
+ }),
+ folderId () {
+ return this.status.bookmark_folder_id
+ }
+ },
+ methods: {
+ toggleFolder (id) {
+ const value = id === this.folderId ? null : id
+
+ this.$store.dispatch('bookmark', { id: this.status.id, bookmark_folder_id: value })
+ .then(() => this.$emit('onSuccess'))
+ .catch(err => this.$emit('onError', err.error.error))
+ }
+ }
+}
+
+export default StatusBookmarkFolderMenu
diff --git a/src/components/status_bookmark_folder_menu/status_bookmark_folder_menu.vue b/src/components/status_bookmark_folder_menu/status_bookmark_folder_menu.vue
new file mode 100644
index 00000000..48b7fe70
--- /dev/null
+++ b/src/components/status_bookmark_folder_menu/status_bookmark_folder_menu.vue
@@ -0,0 +1,38 @@
+<template>
+ <div class="StatusBookmarkFolderMenu">
+ <Popover
+ trigger="hover"
+ placement="left"
+ remove-padding
+ >
+ <template #content>
+ <div class="dropdown-menu">
+ <button
+ v-for="folder in folders"
+ :key="folder.id"
+ class="menu-item dropdown-item"
+ @click="toggleFolder(folder.id)"
+ >
+ <span
+ class="input menu-checkbox -radio"
+ :class="{ 'menu-checkbox-checked': status.bookmark_folder_id == folder.id }"
+ />
+ {{ folder.name }}
+ </button>
+ </div>
+ </template>
+ <template #trigger>
+ <button class="menu-item dropdown-item -has-submenu">
+ {{ $t('bookmark_folders.select_folder') }}
+ <FAIcon
+ class="chevron-icon"
+ size="lg"
+ icon="chevron-right"
+ />
+ </button>
+ </template>
+ </Popover>
+ </div>
+</template>
+
+<script src="./status_bookmark_folder_menu.js"></script>