fix: Get proper rich object for card actions
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
@@ -252,4 +252,52 @@ describe('Card', function() {
|
||||
|
||||
})
|
||||
|
||||
describe('Card actions', () => {
|
||||
beforeEach(function() {
|
||||
cy.login(user)
|
||||
useModal(false).then(() => {
|
||||
cy.visit(`/apps/deck/#/board/${boardId}`)
|
||||
})
|
||||
})
|
||||
|
||||
it('Custom card actions', () => {
|
||||
const myAction = {
|
||||
label: 'Test action',
|
||||
icon: 'icon-user',
|
||||
callback(card) {
|
||||
console.log('Called callback', card)
|
||||
},
|
||||
}
|
||||
cy.spy(myAction, 'callback').as('myAction.callback')
|
||||
|
||||
cy.window().then(win => {
|
||||
win.OCA.Deck.registerCardAction(myAction)
|
||||
})
|
||||
|
||||
cy.get('.card:contains("Hello world")').should('be.visible').click()
|
||||
cy.get('#app-sidebar-vue')
|
||||
.find('.ProseMirror h1').contains('Hello world').should('be.visible')
|
||||
|
||||
cy.get('.app-sidebar-header .action-item__menutoggle').click()
|
||||
cy.get('.v-popper__popper button:contains("Test action")').click()
|
||||
|
||||
cy.get('@myAction.callback')
|
||||
.should('be.called')
|
||||
.its('firstCall.args.0')
|
||||
.as('args')
|
||||
|
||||
cy.url().then(url => {
|
||||
const cardId = url.split('/').pop()
|
||||
cy.get('@args').should('have.property', 'name', 'Hello world')
|
||||
cy.get('@args').should('have.property', 'stackname', 'TestList')
|
||||
cy.get('@args').should('have.property', 'boardname', 'MyTestBoard')
|
||||
cy.get('@args').its('link').then((url) => {
|
||||
expect(url.split('/').pop() === cardId).to.be.true
|
||||
cy.visit(url)
|
||||
cy.get('#app-sidebar-vue')
|
||||
.find('.ProseMirror h1').contains('Hello world').should('be.visible')
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -83,7 +83,6 @@
|
||||
|
||||
<script>
|
||||
import { NcActionButton, NcAppSidebar, NcAppSidebarTab } from '@nextcloud/vue'
|
||||
import { generateUrl } from '@nextcloud/router'
|
||||
import { mapState, mapGetters } from 'vuex'
|
||||
import CardSidebarTabDetails from './CardSidebarTabDetails.vue'
|
||||
import CardSidebarTabAttachments from './CardSidebarTabAttachments.vue'
|
||||
@@ -160,15 +159,6 @@ export default {
|
||||
subtitleTooltip() {
|
||||
return t('deck', 'Modified') + ': ' + this.formatDate(this.currentCard.lastModified) + '\n' + t('deck', 'Created') + ': ' + this.formatDate(this.currentCard.createdAt)
|
||||
},
|
||||
cardRichObject() {
|
||||
return {
|
||||
id: '' + this.currentCard.id,
|
||||
name: this.currentCard.title,
|
||||
boardname: this.currentBoard.title,
|
||||
stackname: this.stackById(this.currentCard.stackId)?.title,
|
||||
link: window.location.protocol + '//' + window.location.host + generateUrl('/apps/deck/') + `#/board/${this.currentBoard.id}/card/${this.currentCard.id}`,
|
||||
}
|
||||
},
|
||||
cardDetailsInModal: {
|
||||
get() {
|
||||
return this.$store.getters.config('cardDetailsInModal')
|
||||
|
||||
@@ -136,6 +136,8 @@ export default {
|
||||
'isArchived',
|
||||
'boards',
|
||||
'cardActions',
|
||||
'stackById',
|
||||
'boardById',
|
||||
]),
|
||||
...mapState({
|
||||
showArchived: state => state.showArchived,
|
||||
@@ -165,7 +167,17 @@ export default {
|
||||
},
|
||||
|
||||
boardId() {
|
||||
return this.card?.boardId ? this.card.boardId : this.$route.params.id
|
||||
return this.card?.boardId ? this.card.boardId : Number(this.$route.params.id)
|
||||
},
|
||||
|
||||
cardRichObject() {
|
||||
return {
|
||||
id: '' + this.card.id,
|
||||
name: this.card.title,
|
||||
boardname: this.boardById(this.boardId)?.title,
|
||||
stackname: this.stackById(this.card.stackId)?.title,
|
||||
link: window.location.protocol + '//' + window.location.host + generateUrl('/apps/deck/') + `card/${this.card.id}`,
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
|
||||
Reference in New Issue
Block a user