Skip to content

Commit

Permalink
fixup! Import file FileAction 28 compatibility
Browse files Browse the repository at this point in the history
Signed-off-by: greta <gretadoci@gmail.com>
  • Loading branch information
GretaD committed Oct 24, 2023
1 parent 7d8f1bb commit ea8b95d
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions src/files-action.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ import { registerFileAction, FileAction } from '@nextcloud/files'
const mime = 'text/vcard'
const name = 'contacts-import'

registerFileAction(new FileAction({
window.addEventListener('DOMContentLoaded', () => {
if (!nextcloudVersion >= 26 && OCA.Files && OCA?.Files?.fileActions) {

Check failure on line 29 in src/files-action.js

View workflow job for this annotation

GitHub Actions / eslint

'nextcloudVersion' is not defined
OCA.Files.fileActions.registerAction({
name,
displayName: t('contacts', 'Import'),
mime,
Expand All @@ -36,8 +38,26 @@ registerFileAction(new FileAction({
window.location = generateUrl(`/apps/contacts/import?file=${absPath}`)
},
})
// to be changed
OCA.Files.fileActions.setDefault(mime, name)
return
}
console.error('Unable to register vcf import action')
)
})

if (nextcloudVersion >= 26) {

Check failure on line 47 in src/files-action.js

View workflow job for this annotation

GitHub Actions / eslint

'nextcloudVersion' is not defined
registerFileAction(new FileAction({

Check warning on line 48 in src/files-action.js

View check run for this annotation

Codecov / codecov/patch

src/files-action.js#L48

Added line #L48 was not covered by tests
name,
displayName() {
return t('contacts', 'Import')

Check warning on line 51 in src/files-action.js

View check run for this annotation

Codecov / codecov/patch

src/files-action.js#L50-L51

Added lines #L50 - L51 were not covered by tests
},
default: 'default',
mime,
permissions: OC.PERMISSION_READ,
iconClass: 'icon-contacts-dark',
actionHandler(fileName, context) {

Check warning on line 57 in src/files-action.js

View check run for this annotation

Codecov / codecov/patch

src/files-action.js#L57

Added line #L57 was not covered by tests
const absPath = `${context.dir === '/' ? '' : context.dir}/${fileName}`
window.location = generateUrl(`/apps/contacts/import?file=${absPath}`)

Check warning on line 59 in src/files-action.js

View check run for this annotation

Codecov / codecov/patch

src/files-action.js#L59

Added line #L59 was not covered by tests
},
}),
)
}

0 comments on commit ea8b95d

Please sign in to comment.