Skip to content

Commit 3418bc9

Browse files
committed
introduce first pinia stores
Signed-off-by: grnd-alt <git@belakkaf.net>
1 parent b86df2a commit 3418bc9

File tree

10 files changed

+822
-780
lines changed

10 files changed

+822
-780
lines changed

package-lock.json

Lines changed: 327 additions & 750 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: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
55
import Vue from 'vue'
6+
import { pinia } from './stores/index.js'
67
import App from './App.vue'
78
import router from './router.js'
89
import storeFactory from './store/main.js'
@@ -14,6 +15,7 @@ import ClickOutside from 'vue-click-outside'
1415
import './shared-init.js'
1516
import './models/index.js'
1617
import { initSessions } from './sessions.js'
18+
import { useActionsStore } from './stores/actions.js'
1719

1820
// the server snap.js conflicts with vertical scrolling so we disable it
1921
document.body.setAttribute('data-snap-ignore', 'true')
@@ -48,6 +50,7 @@ new Vue({
4850
name: 'Deck',
4951
router,
5052
store,
53+
pinia,
5154
data() {
5255
return {
5356
time: Date.now(),
@@ -115,5 +118,6 @@ window.OCA.Deck.registerCardAction = ({ label, callback, icon }) => {
115118
callback,
116119
icon,
117120
}
118-
store.dispatch('addCardAction', cardAction)
121+
const actionsStore = useActionsStore()
122+
actionsStore.addCardAction(cardAction)
119123
}

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: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { defineStore } from 'pinia'
2+
3+
export const useActionsStore = defineStore('actions',
4+
{
5+
state: () => ({
6+
actions: {
7+
card: [],
8+
},
9+
}),
10+
getters: {
11+
cardActions: (state) => state.actions.card,
12+
},
13+
actions: {
14+
async addCardAction(action) {
15+
this.actions.card.push(action)
16+
},
17+
},
18+
})

0 commit comments

Comments
 (0)