Skip to content

Commit eb53f25

Browse files
committed
introduce first pinia store
Signed-off-by: grnd-alt <git@belakkaf.net>
1 parent 72ed55f commit eb53f25

File tree

8 files changed

+365
-779
lines changed

8 files changed

+365
-779
lines changed

package-lock.json

Lines changed: 327 additions & 749 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"markdown-it-task-checkbox": "^1.0.6",
5555
"moment": "^2.30.1",
5656
"p-queue": "^8.0.1",
57+
"pinia": "^2.3.1",
5758
"url-search-params-polyfill": "^8.2.5",
5859
"vue": "^2.7.15",
5960
"vue-at": "^2.5.1",

src/components/card/CardSidebar.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ export default {
149149
currentBoard: (state) => state.currentBoard,
150150
hasCardSaveError: (state) => state.hasCardSaveError,
151151
}),
152-
...mapGetters(['canEdit', 'assignables', 'cardActions', 'stackById']),
152+
...mapGetters(['canEdit', 'assignables', 'stackById']),
153153
currentCard() {
154154
return this.$store.getters.cardById(this.id)
155155
},

src/components/cards/CardMenuEntries.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ import { showUndo } from '@nextcloud/dialogs'
7373
7474
import '@nextcloud/dialogs/style.css'
7575
import { emit } from '@nextcloud/event-bus'
76+
import { useActionsStore } from '../../stores/actions.js'
7677
7778
export default {
7879
name: 'CardMenuEntries',
@@ -88,6 +89,12 @@ export default {
8889
},
8990
},
9091
emits: ['edit-title'],
92+
setup() {
93+
const actionsStore = useActionsStore()
94+
return {
95+
cardActions: actionsStore.cardActions,
96+
}
97+
},
9198
data() {
9299
return {
93100
modalShow: false,
@@ -100,7 +107,6 @@ export default {
100107
...mapGetters([
101108
'isArchived',
102109
'boards',
103-
'cardActions',
104110
'stackById',
105111
'boardById',
106112
]),

src/main.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import ClickOutside from 'vue-click-outside'
1414
import './shared-init.js'
1515
import './models/index.js'
1616
import { initSessions } from './sessions.js'
17+
import { useActionsStore } from './stores/actions.js'
18+
import { createPinia, PiniaVuePlugin } from 'pinia'
1719

1820
// the server snap.js conflicts with vertical scrolling so we disable it
1921
document.body.setAttribute('data-snap-ignore', 'true')
@@ -41,13 +43,17 @@ Vue.config.errorHandler = (err, vm, info) => {
4143
console.error(err)
4244
}
4345

46+
const pinia = createPinia()
47+
Vue.use(PiniaVuePlugin)
48+
4449
/* eslint-disable-next-line no-new */
4550
new Vue({
4651
el: '#content',
4752
// eslint-disable-next-line vue/match-component-file-name
4853
name: 'Deck',
4954
router,
5055
store,
56+
pinia,
5157
data() {
5258
return {
5359
time: Date.now(),
@@ -115,5 +121,6 @@ window.OCA.Deck.registerCardAction = ({ label, callback, icon }) => {
115121
callback,
116122
icon,
117123
}
118-
store.dispatch('addCardAction', cardAction)
124+
const actionsStore = useActionsStore()
125+
actionsStore.addCardAction(cardAction)
119126
}

src/store/actions.js

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/store/main.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import Vuex from 'vuex'
1111
import axios from '@nextcloud/axios'
1212
import { generateOcsUrl, generateUrl } from '@nextcloud/router'
1313
import { BoardApi } from '../services/BoardApi.js'
14-
import actions from './actions.js'
1514
import stackModuleFactory from './stack.js'
1615
import cardModuleFactory from './card.js'
1716
import comment from './comment.js'
@@ -35,7 +34,6 @@ export const BOARD_FILTERS = {
3534
export default function storeFactory() {
3635
return new Vuex.Store({
3736
modules: {
38-
actions,
3937
stack: stackModuleFactory(),
4038
card: cardModuleFactory(),
4139
comment,
@@ -385,6 +383,7 @@ export default function storeFactory() {
385383
*
386384
* @param commit.commit
387385
* @param commit
386+
* @param commit.state
388387
* @param board The board to update.
389388
* @return {Promise<void>}
390389
*/

src/stores/actions.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
3+
* SPDX-License-Identifier: AGPL-3.0-or-later
4+
*/
5+
6+
import { defineStore } from 'pinia'
7+
8+
export const useActionsStore = defineStore('actions',
9+
{
10+
state: () => ({
11+
actions: {
12+
card: [],
13+
},
14+
}),
15+
actions: {
16+
async addCardAction(action) {
17+
this.actions.card.push(action)
18+
},
19+
},
20+
})

0 commit comments

Comments
 (0)