Skip to content

Commit

Permalink
fixup! Add shared items and events for each contact
Browse files Browse the repository at this point in the history
Signed-off-by: greta <[email protected]>
  • Loading branch information
GretaD committed Oct 25, 2023
1 parent e0f464a commit 2a117d5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/components/ContactDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,8 @@
</template>
</NcButton>
</div>
<NcRelatedResourcesPanel provider-id="account"
<NcRelatedResourcesPanel v-if="nextcloudVersion"
provider-id="account"
:item-id="contact.uid" />
<!-- contact details -->
<section class="contact-details">
Expand Down Expand Up @@ -680,6 +681,10 @@ export default {
isInSystemAddressBook() {
return this.contact.addressbook.id === 'z-server-generated--system'
},
nextcloudVersion() {
// TODO: remove it when NC 25 is not supported anymore
return parseInt(OC.config.version.split('.')[0]) >= 26
},
},

watch: {
Expand Down
24 changes: 22 additions & 2 deletions src/files-action.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@
*
*/
import { generateUrl } from '@nextcloud/router'

import { translate as t } from '@nextcloud/l10n'
import { registerFileAction, FileAction } from '@nextcloud/files'
const mime = 'text/vcard'
const name = 'contacts-import'
const nextcloudIsGreaterThan26 = parseInt(OC.config.version.split('.')[0]) >= 26

window.addEventListener('DOMContentLoaded', () => {
if (OCA.Files && OCA.Files.fileActions) {
if (!nextcloudIsGreaterThan26 && OCA.Files && OCA?.Files?.fileActions) {
OCA.Files.fileActions.registerAction({
name,
displayName: t('contacts', 'Import'),
Expand All @@ -42,3 +44,21 @@ window.addEventListener('DOMContentLoaded', () => {
}
console.error('Unable to register vcf import action')
})

if (nextcloudIsGreaterThan26) {
registerFileAction(new FileAction({
name,
displayName() {
return t('contacts', 'Import')
},
default: 'default',
mime,
permissions: OC.PERMISSION_READ,
iconClass: 'icon-contacts-dark',
actionHandler(fileName, context) {
const absPath = `${context.dir === '/' ? '' : context.dir}/${fileName}`
window.location = generateUrl(`/apps/contacts/import?file=${absPath}`)
},
}),
)
}

0 comments on commit 2a117d5

Please sign in to comment.