Skip to content

Commit

Permalink
feat: export skipped when file conflict is skipped
Browse files Browse the repository at this point in the history
Signed-off-by: grnd-alt <salimbelakkaf@outlook.de>
  • Loading branch information
grnd-alt authored and AndyScherzinger committed Jul 10, 2024
1 parent dcd8c0c commit 9d31963
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
10 changes: 3 additions & 7 deletions cypress/components/ConflictPicker.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ describe('ConflictPicker resolving', () => {
mtime: new Date('2021-01-01T00:00:00.000Z'),
})

const onSubmit = cy.spy().as('onSubmitSpy')
const onSkip = cy.spy().as('onSkipSpy')
const onCancel = cy.spy().as('onCancelSpy')
cy.mount(ConflictPicker, {
propsData: {
Expand All @@ -271,7 +271,7 @@ describe('ConflictPicker resolving', () => {
conflicts: images,
},
listeners: {
submit: onSubmit,
skip: onSkip,
cancel: onCancel,
},
})
Expand All @@ -280,11 +280,7 @@ describe('ConflictPicker resolving', () => {
cy.get('[data-cy-conflict-picker-fieldset]').should('have.length', 3)
cy.get('[data-cy-conflict-picker-skip]').click()

cy.get('@onSubmitSpy').should('have.been.calledOnce').then((onSubmit) => {
const results = (onSubmit as unknown as sinon.SinonSpy).firstCall.args[0]
expect(results.selected).to.have.length(0)
expect(results.renamed).to.have.length(0)
})
cy.get('@onSkipSpy').should('have.been.calledOnce')
cy.get('@onCancelSpy').should('not.have.been.called')
})
})
6 changes: 2 additions & 4 deletions lib/components/ConflictPicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,7 @@ export default defineComponent({
onSkip() {
logger.debug('Conflict skipped. Ignoring all conflicting files')
this.opened = false
this.$emit('submit', {
selected: [],
renamed: [],
} as ConflictResolutionResult<File>)
this.$emit('skip')
},

onSubmit() {
Expand Down Expand Up @@ -344,6 +341,7 @@ export default defineComponent({
this.$emit('submit', {
selected,
renamed,
skipped: false,
} as ConflictResolutionResult<File|Node|FileSystemEntry>)
},

Expand Down
8 changes: 8 additions & 0 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ let _uploader: Uploader | null = null
export type ConflictResolutionResult<T extends File|FileSystemEntry|Node> = {
selected: T[],
renamed: T[],
skipped: boolean,
}
/**
* Get an Uploader instance
Expand Down Expand Up @@ -104,6 +105,13 @@ export async function openConflictPicker<T extends File|FileSystemEntry|Node>(
picker.$destroy()
picker.$el?.parentNode?.removeChild(picker.$el)
},
skip() {
resolve({selected: [],renamed: [], skipped: true})

// Destroy the component
picker.$destroy()
picker.$el?.parentNode?.removeChild(picker.$el)
}
},
}),
})
Expand Down

0 comments on commit 9d31963

Please sign in to comment.