Skip to content

[WIP] exchange cloud ID #4417

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
200 changes: 200 additions & 0 deletions src/components/CloudIdExchangeInvite.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
<!--
- SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
- SPDX-License-Identifier: AGPL-3.0-or-later
-->

<template>
<div v-if="displayCloudIdExchangeButton(propName)">
<Actions class="property__actions exchange-cloud-id">
<ActionButton @click="openExchangeInviteModal">
<template #icon>
<IconAccountSwitchOutline :size="20" />
</template>
Invite remote user to exchange cloud IDs. This will add the remote user to your contacts list.
</ActionButton>
</Actions>

<Modal v-if="showInviteModal"

Check failure on line 17 in src/components/CloudIdExchangeInvite.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Trailing spaces not allowed
id="invitation-modal"

Check failure on line 18 in src/components/CloudIdExchangeInvite.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Trailing spaces not allowed
size="small"

Check failure on line 19 in src/components/CloudIdExchangeInvite.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Trailing spaces not allowed
:clear-view-delay="-1"
:close-button-contained="false"

Check failure on line 21 in src/components/CloudIdExchangeInvite.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Trailing spaces not allowed
@close="closeExchangeInviteModal"
class="modal-cloud-id-exchange">

Check warning on line 23 in src/components/CloudIdExchangeInvite.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Expected 1 line break after opening tag (`<Modal>`), but 2 line breaks found

Check warning on line 23 in src/components/CloudIdExchangeInvite.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Attribute "class" should go before "@close"

<InvitationDetails :local-contact="localContact">
<template #name>
<NcTextField type="text" :placeholder="t('contacts', 'name')" :value="displayName"

Check failure on line 27 in src/components/CloudIdExchangeInvite.vue

View workflow job for this annotation

GitHub Actions / NPM lint

':value' should be on a new line

Check failure on line 27 in src/components/CloudIdExchangeInvite.vue

View workflow job for this annotation

GitHub Actions / NPM lint

':placeholder' should be on a new line
@input="setDisplayName" />
</template>
<template #email>
<NcTextField type="text" :placeholder="t('contacts', 'email')" :value="email" @input="setEmail" />

Check failure on line 31 in src/components/CloudIdExchangeInvite.vue

View workflow job for this annotation

GitHub Actions / NPM lint

'@input' should be on a new line
</template>
<template #personal-message>
<NcTextArea id="personal-message" ref="textarea" :placeholder="t('contacts', 'personal message')"

Check failure on line 34 in src/components/CloudIdExchangeInvite.vue

View workflow job for this annotation

GitHub Actions / NPM lint

':placeholder' should be on a new line

Check failure on line 34 in src/components/CloudIdExchangeInvite.vue

View workflow job for this annotation

GitHub Actions / NPM lint

'ref' should be on a new line
:value="message" :inputmode="inputmode" @input="setMessage" />

Check failure on line 35 in src/components/CloudIdExchangeInvite.vue

View workflow job for this annotation

GitHub Actions / NPM lint

':inputmode' should be on a new line
</template>
<template #invitation-actions>
<NcButton @click="sendInvitation">
<template #icon>
<IconLoading v-if="loadingUpdate" :size="20" />
<IconCheck v-else :size="20" />
</template>
{{ t('contacts', 'Send') }}
</NcButton>
</template>

Check warning on line 45 in src/components/CloudIdExchangeInvite.vue

View check run for this annotation

Codecov / codecov/patch

src/components/CloudIdExchangeInvite.vue#L44-L45

Added lines #L44 - L45 were not covered by tests
</InvitationDetails>
</Modal>

Check warning on line 47 in src/components/CloudIdExchangeInvite.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Expected 1 line break before closing tag (`</div>`), but 2 line breaks found

Check warning on line 48 in src/components/CloudIdExchangeInvite.vue

View check run for this annotation

Codecov / codecov/patch

src/components/CloudIdExchangeInvite.vue#L47-L48

Added lines #L47 - L48 were not covered by tests
</div>

Check warning on line 49 in src/components/CloudIdExchangeInvite.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Expected 1 line break before closing tag (`</template>`), but 2 line breaks found

</template>

<script>

Check warning on line 53 in src/components/CloudIdExchangeInvite.vue

View check run for this annotation

Codecov / codecov/patch

src/components/CloudIdExchangeInvite.vue#L53

Added line #L53 was not covered by tests
import {
NcActionButton as ActionButton,
NcActions as Actions,
NcButton,
NcLoadingIcon as IconLoading,
NcModal as Modal,
NcTextArea,

Check warning on line 60 in src/components/CloudIdExchangeInvite.vue

View check run for this annotation

Codecov / codecov/patch

src/components/CloudIdExchangeInvite.vue#L58-L60

Added lines #L58 - L60 were not covered by tests
NcTextField,
} from '@nextcloud/vue'

Check warning on line 62 in src/components/CloudIdExchangeInvite.vue

View check run for this annotation

Codecov / codecov/patch

src/components/CloudIdExchangeInvite.vue#L62

Added line #L62 was not covered by tests
import Contact from '../models/contact.js'
import IconAccountSwitchOutline from 'vue-material-design-icons/AccountSwitchOutline.vue'
import IconCheck from 'vue-material-design-icons/Check.vue'

Check warning on line 65 in src/components/CloudIdExchangeInvite.vue

View check run for this annotation

Codecov / codecov/patch

src/components/CloudIdExchangeInvite.vue#L64-L65

Added lines #L64 - L65 were not covered by tests
import InvitationDetails from './CloudIdExchangeInviteDetails.vue'
import PropertyMixin from '../mixins/PropertyMixin.js'

Check warning on line 68 in src/components/CloudIdExchangeInvite.vue

View check run for this annotation

Codecov / codecov/patch

src/components/CloudIdExchangeInvite.vue#L67-L68

Added lines #L67 - L68 were not covered by tests
export default {
name: 'PropertyText',

components: {
ActionButton,
Actions,

Check warning on line 74 in src/components/CloudIdExchangeInvite.vue

View check run for this annotation

Codecov / codecov/patch

src/components/CloudIdExchangeInvite.vue#L70-L74

Added lines #L70 - L74 were not covered by tests
Contact,
IconAccountSwitchOutline,
IconCheck,
IconLoading,
InvitationDetails,

Check warning on line 79 in src/components/CloudIdExchangeInvite.vue

View check run for this annotation

Codecov / codecov/patch

src/components/CloudIdExchangeInvite.vue#L78-L79

Added lines #L78 - L79 were not covered by tests
Modal,
NcButton,
NcTextArea,

Check warning on line 82 in src/components/CloudIdExchangeInvite.vue

View check run for this annotation

Codecov / codecov/patch

src/components/CloudIdExchangeInvite.vue#L81-L82

Added lines #L81 - L82 were not covered by tests
NcTextField,
},
mixins: [PropertyMixin],

Check warning on line 85 in src/components/CloudIdExchangeInvite.vue

View check run for this annotation

Codecov / codecov/patch

src/components/CloudIdExchangeInvite.vue#L84-L85

Added lines #L84 - L85 were not covered by tests
props: {
localContact: {
type: Contact,

Check warning on line 88 in src/components/CloudIdExchangeInvite.vue

View check run for this annotation

Codecov / codecov/patch

src/components/CloudIdExchangeInvite.vue#L87-L88

Added lines #L87 - L88 were not covered by tests
default: null,
},
propName: {
type: String,
default: 'text',
required: true,

Check warning on line 94 in src/components/CloudIdExchangeInvite.vue

View check run for this annotation

Codecov / codecov/patch

src/components/CloudIdExchangeInvite.vue#L90-L94

Added lines #L90 - L94 were not covered by tests
},
value: {

Check warning on line 96 in src/components/CloudIdExchangeInvite.vue

View check run for this annotation

Codecov / codecov/patch

src/components/CloudIdExchangeInvite.vue#L96

Added line #L96 was not covered by tests
type: String,
default: '',
required: true,
},
contactFormEditMode: {

Check warning on line 101 in src/components/CloudIdExchangeInvite.vue

View check run for this annotation

Codecov / codecov/patch

src/components/CloudIdExchangeInvite.vue#L100-L101

Added lines #L100 - L101 were not covered by tests
type: Boolean,
default: false
}
},
computed: {
displayName() {
return this.localContact.displayName
},
email() {
return this.localContact.email
}
},
emits: [

Check warning on line 114 in src/components/CloudIdExchangeInvite.vue

View check run for this annotation

Codecov / codecov/patch

src/components/CloudIdExchangeInvite.vue#L112-L114

Added lines #L112 - L114 were not covered by tests
'setContactFormEditModeEvent:value'
],

Check warning on line 116 in src/components/CloudIdExchangeInvite.vue

View check run for this annotation

Codecov / codecov/patch

src/components/CloudIdExchangeInvite.vue#L116

Added line #L116 was not covered by tests
methods: {
displayCloudIdExchangeButton(propName) {
// TODO add check for:
// 1. cloud ID exchange invitation capability present ?
// 2. is it active ?
if (propName === 'cloud' && this.localContact && !(typeof this.value === 'string' || this.value instanceof String)) {
console.log(`displayCloudIdExchangeButton(${propName}): true`)
this.isNewContact = false
return true
}
return false
},
closeExchangeInviteModal() {
this.showInviteModal = false
},
openExchangeInviteModal() {

Check warning on line 132 in src/components/CloudIdExchangeInvite.vue

View check run for this annotation

Codecov / codecov/patch

src/components/CloudIdExchangeInvite.vue#L131-L132

Added lines #L131 - L132 were not covered by tests
this.showInviteModal = true
},
sendInvitation() {
console.log('contactFormEditMode: ' + this.contactFormEditMode)
this.localContact.properties.find(p => p.name === 'fn').setValue(this.localDisplayName)
this.localContact.properties.find(p => p.name === 'email').setValue(this.localEmail)
this.updateContact()
// TODO on close:
// - display saved contact; like when save button is pressed
// - the cloud ID prop should be displayed saying '... awaiting cloud ID exchange invite response'
this.$emit('setContactFormEditModeEvent:value', false)
this.showInviteModal = false
},
setDisplayName(e) {
this.localDisplayName = e.target.value
},
setEmail(e) {
this.localEmail = e.target.value
},
setMessage(e) {
this.localMessage = e.target.value
},
updateContact() {
this.fixed = false
this.loadingUpdate = true

Check warning on line 157 in src/components/CloudIdExchangeInvite.vue

View check run for this annotation

Codecov / codecov/patch

src/components/CloudIdExchangeInvite.vue#L157

Added line #L157 was not covered by tests
try {
this.$store.dispatch('updateContact', this.localContact)
} finally {
this.loadingUpdate = false
}
},
},
data() {
return {
showInviteModal: false,
isNewContact: false,
localDisplayName: '',
localEmail: '',
localMessage: '',
loadingUpdate: false,
}
}
}
</script>

Check warning on line 177 in src/components/CloudIdExchangeInvite.vue

View check run for this annotation

Codecov / codecov/patch

src/components/CloudIdExchangeInvite.vue#L176-L177

Added lines #L176 - L177 were not covered by tests
<style lang="scss">
div.property.property-cloud {
position: relative;
}
</style>

<style lang="scss" scoped>
#invitation-modal {
background-color: rgba(0, 0, 0, .5);
div.modal-container__content {
margin: 0 1em 1em;
}
}

div.property.property-cloud {
button.exchange-cloud-id {

Check warning on line 193 in src/components/CloudIdExchangeInvite.vue

View check run for this annotation

Codecov / codecov/patch

src/components/CloudIdExchangeInvite.vue#L192-L193

Added lines #L192 - L193 were not covered by tests
position: absolute;
top: 0;
right: 4em;
}
}

</style>
35 changes: 35 additions & 0 deletions src/components/CloudIdExchangeInviteDetails.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!--
- SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
- SPDX-License-Identifier: AGPL-3.0-or-later
-->

<template>
<div class="contact-header__infos">
<h5 class="">

Check warning on line 8 in src/components/CloudIdExchangeInviteDetails.vue

View check run for this annotation

Codecov / codecov/patch

src/components/CloudIdExchangeInviteDetails.vue#L5-L8

Added lines #L5 - L8 were not covered by tests
{{ t('contacts', 'Invitation to exchange cloud IDs') }}
</h5>
<div class="invitation-name">
<label>Name</label>
<slot name="name" />
</div>
<div class="invitation-email">
<label>Email</label>
<slot name="email" />
</div>
<div class="invitation-personal-message">
<label>Message</label>
<slot name="personal-message" />
</div>
<div class="actions">
<slot name="invitation-actions" />
</div>
</div>

</template>

<script>

export default {
name: 'InvitationDetails',
}
</script>
7 changes: 6 additions & 1 deletion src/components/ContactDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,9 @@
:local-contact="localContact"
:contacts="contacts"
:bus="bus"
:is-read-only="isReadOnly" />
:is-read-only="isReadOnly"
:contactFormEditMode="editMode"
@setContactFormEditModeEvent:value="setEditMode" />
</div>
</section>

Expand Down Expand Up @@ -1069,6 +1071,9 @@ export default {
showError(t('contacts', 'Unable to update contact'))
}
},
setEditMode(value) {
this.editMode = value
}
},
}
</script>
Expand Down
17 changes: 17 additions & 0 deletions src/components/ContactDetails/ContactDetailsProperty.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
:is-read-only="isReadOnly"
:bus="bus"
:is-multiple="isMultiple"
:contactFormEditMode="contactFormEditMode"
@setContactFormEditModeEvent:value="setEditMode"
@delete="onDelete" />
</template>

Expand All @@ -38,6 +40,7 @@
import PropertyDateTime from '../Properties/PropertyDateTime.vue'
import PropertySelect from '../Properties/PropertySelect.vue'
import { matchTypes } from '../../utils/matchTypes.ts'
import PropertyCloudId from '../Properties/PropertyCloudId.vue'

Check warning on line 43 in src/components/ContactDetails/ContactDetailsProperty.vue

View check run for this annotation

Codecov / codecov/patch

src/components/ContactDetails/ContactDetailsProperty.vue#L43

Added line #L43 was not covered by tests

export default {
name: 'ContactDetailsProperty',
Expand Down Expand Up @@ -99,6 +102,8 @@
return PropertyDateTime
} else if (this.propType && this.propType === 'select') {
return PropertySelect
} else if (this.propType && this.propName === 'cloud') {

Check warning on line 105 in src/components/ContactDetails/ContactDetailsProperty.vue

View check run for this annotation

Codecov / codecov/patch

src/components/ContactDetails/ContactDetailsProperty.vue#L105

Added line #L105 was not covered by tests
return PropertyCloudId
} else if (this.propType && this.propType !== 'unknown') {
return PropertyText
}
Expand Down Expand Up @@ -358,6 +363,14 @@
this.bus.off('focus-prop', this.onFocusProp)
},

data() {
return {
contactFormEditMode: false,
}
},

Check warning on line 370 in src/components/ContactDetails/ContactDetailsProperty.vue

View check run for this annotation

Codecov / codecov/patch

src/components/ContactDetails/ContactDetailsProperty.vue#L369-L370

Added lines #L369 - L370 were not covered by tests
emits: [
'setContactFormEditModeEvent:value'
],

Check warning on line 373 in src/components/ContactDetails/ContactDetailsProperty.vue

View check run for this annotation

Codecov / codecov/patch

src/components/ContactDetails/ContactDetailsProperty.vue#L372-L373

Added lines #L372 - L373 were not covered by tests
methods: {
/**
* Focus first input element of the new prop
Expand All @@ -383,6 +396,10 @@
onDelete() {
this.localContact.vCard.removeProperty(this.property)
},

setEditMode(value) {
this.$emit('setContactFormEditModeEvent:value', value)
}
},
}
</script>
Loading
Loading