Skip to content

Commit

Permalink
Improve sharing flow
Browse files Browse the repository at this point in the history
Resolves: #26691

Signed-off-by: fenn-cs <[email protected]>
  • Loading branch information
nfebe committed Aug 7, 2023
1 parent b27a2e9 commit c10f540
Show file tree
Hide file tree
Showing 6 changed files with 896 additions and 120 deletions.
176 changes: 61 additions & 115 deletions apps/files_sharing/src/components/SharingEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,139 +29,60 @@
:menu-position="'left'"
:url="share.shareWithAvatar" />

<component :is="share.shareWithLink ? 'a' : 'div'"
:title="tooltip"
:aria-label="tooltip"
:href="share.shareWithLink"
class="sharing-entry__desc">
<span>{{ title }}<span v-if="!isUnique" class="sharing-entry__desc-unique"> ({{ share.shareWithDisplayNameUnique }})</span></span>
<p v-if="hasStatus">
<span>{{ share.status.icon || '' }}</span>
<span>{{ share.status.message || '' }}</span>
</p>
</component>
<NcActions menu-align="right"
class="sharing-entry__actions"
@close="onMenuClose">
<template v-if="share.canEdit">
<!-- edit permission -->
<NcActionCheckbox ref="canEdit"
:checked.sync="canEdit"
:value="permissionsEdit"
:disabled="saving || !canSetEdit">
{{ t('files_sharing', 'Allow editing') }}
</NcActionCheckbox>

<!-- create permission -->
<NcActionCheckbox v-if="isFolder"
ref="canCreate"
:checked.sync="canCreate"
:value="permissionsCreate"
:disabled="saving || !canSetCreate">
{{ t('files_sharing', 'Allow creating') }}
</NcActionCheckbox>

<!-- delete permission -->
<NcActionCheckbox v-if="isFolder"
ref="canDelete"
:checked.sync="canDelete"
:value="permissionsDelete"
:disabled="saving || !canSetDelete">
{{ t('files_sharing', 'Allow deleting') }}
</NcActionCheckbox>

<!-- reshare permission -->
<NcActionCheckbox v-if="config.isResharingAllowed"
ref="canReshare"
:checked.sync="canReshare"
:value="permissionsShare"
:disabled="saving || !canSetReshare">
{{ t('files_sharing', 'Allow resharing') }}
</NcActionCheckbox>

<NcActionCheckbox v-if="isSetDownloadButtonVisible"
ref="canDownload"
:checked.sync="canDownload"
:disabled="saving || !canSetDownload">
{{ allowDownloadText }}
</NcActionCheckbox>

<!-- expiration date -->
<NcActionCheckbox :checked.sync="hasExpirationDate"
:disabled="config.isDefaultInternalExpireDateEnforced || saving"
@uncheck="onExpirationDisable">
{{ config.isDefaultInternalExpireDateEnforced
? t('files_sharing', 'Expiration date enforced')
: t('files_sharing', 'Set expiration date') }}
</NcActionCheckbox>
<NcActionInput v-if="hasExpirationDate"
ref="expireDate"
:is-native-picker="true"
:hide-label="true"
:class="{ error: errors.expireDate}"
:disabled="saving"
:value="new Date(share.expireDate)"
type="date"
:min="dateTomorrow"
:max="dateMaxEnforced"
@input="onExpirationChange">
{{ t('files_sharing', 'Enter a date') }}
</NcActionInput>

<!-- note -->
<template v-if="canHaveNote">
<NcActionCheckbox :checked.sync="hasNote"
:disabled="saving"
@uncheck="queueUpdate('note')">
{{ t('files_sharing', 'Note to recipient') }}
</NcActionCheckbox>
<NcActionTextEditable v-if="hasNote"
ref="note"
:class="{ error: errors.note}"
:disabled="saving"
:value="share.newNote || share.note"
icon="icon-edit"
@update:value="onNoteChange"
@submit="onNoteSubmit" />
</template>
<div class="sharing-entry__summary" @click="toggleQuickShareSelect">
<component :is="share.shareWithLink ? 'a' : 'div'"
:title="tooltip"
:aria-label="tooltip"
:href="share.shareWithLink"
class="sharing-entry__desc">
<span>{{ title }}<span v-if="!isUnique" class="sharing-entry__desc-unique"> ({{
share.shareWithDisplayNameUnique }})</span></span>
<p v-if="hasStatus">
<span>{{ share.status.icon || '' }}</span>
<span>{{ share.status.message || '' }}</span>
</p>
</component>
<QuickShareSelect :options="options" :value.sync="selectedOption" :toggle="showDropdown" />
</div>
<NcButton class="sharing-entry__action"
:aria-label="t('files_sharing', 'Open Sharing Details')"
type="tertiary-no-background"
@click="openSharingDetails">
<template #icon>
<DotsHorizontalIcon :size="20" />
</template>

<NcActionButton v-if="share.canDelete"
icon="icon-close"
:disabled="saving"
@click.prevent="onDelete">
{{ t('files_sharing', 'Unshare') }}
</NcActionButton>
</NcActions>
</NcButton>
</li>
</template>

<script>
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
import NcSelect from '@nextcloud/vue/dist/Components/NcSelect.js'
import NcAvatar from '@nextcloud/vue/dist/Components/NcAvatar.js'
import NcActions from '@nextcloud/vue/dist/Components/NcActions.js'
import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js'
import NcActionCheckbox from '@nextcloud/vue/dist/Components/NcActionCheckbox.js'
import NcActionInput from '@nextcloud/vue/dist/Components/NcActionInput.js'
import NcActionTextEditable from '@nextcloud/vue/dist/Components/NcActionTextEditable.js'
import DotsHorizontalIcon from 'vue-material-design-icons/DotsHorizontal.vue'
import QuickShareSelect from './SharingEntryQuickShareSelect.vue'
import SharesMixin from '../mixins/SharesMixin.js'
export default {
name: 'SharingEntry',
components: {
NcActions,
NcActionButton,
NcActionCheckbox,
NcActionInput,
NcActionTextEditable,
NcButton,
NcAvatar,
DotsHorizontalIcon,
NcSelect,
QuickShareSelect,
},
mixins: [SharesMixin],
data() {
return {
showDropdown: false,
selectedOption: 'Can view',
options: ['Can view', 'Can edit', 'File drop'],
permissionsEdit: OC.PERMISSION_UPDATE,
permissionsCreate: OC.PERMISSION_CREATE,
permissionsDelete: OC.PERMISSION_DELETE,
Expand Down Expand Up @@ -456,30 +377,55 @@ export default {
onMenuClose() {
this.onNoteSubmit()
},
openSharingDetails() {
this.$emit('open-sharing-details')
},
toggleQuickShareSelect() {
this.showDropdown = !this.showDropdown
},
},
}
</script>

<style lang="scss" scoped>
.sharing-entry {
display: flex;
align-items: center;
align-items: flex-start;
justify-content: center;
height: 44px;
::v-deep &__avatar {
--size: 40px !important;
line-height: 40px !important;
}
&__desc {
display: flex;
flex-direction: column;
justify-content: space-between;
padding: 8px;
padding-bottom: 0;
line-height: 1.2em;
p {
color: var(--color-text-maxcontrast);
}
&-unique {
color: var(--color-text-maxcontrast);
}
}
&__actions {
margin-left: auto;
}
&__summary {
padding-left: 0.2em;
display: flex;
flex-direction: column;
justify-content: center;
width: 100%;
}
}
</style>
15 changes: 14 additions & 1 deletion apps/files_sharing/src/components/SharingEntryLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<p v-if="subtitle">
{{ subtitle }}
</p>
<QuickShareSelect :options="options" :value.sync="selectedOption" :toggle="showDropdown" />
</div>

<!-- clipboard -->
Expand Down Expand Up @@ -292,6 +293,8 @@ import NcActionTextEditable from '@nextcloud/vue/dist/Components/NcActionTextEdi
import NcActions from '@nextcloud/vue/dist/Components/NcActions.js'
import NcAvatar from '@nextcloud/vue/dist/Components/NcAvatar.js'
import QuickShareSelect from './SharingEntryQuickShareSelect.vue'
import ExternalShareAction from './ExternalShareAction.vue'
import SharePermissionsEditor from './SharePermissionsEditor.vue'
import GeneratePassword from '../utils/GeneratePassword.js'
Expand All @@ -313,6 +316,7 @@ export default {
NcAvatar,
ExternalShareAction,
SharePermissionsEditor,
QuickShareSelect,
},
mixins: [SharesMixin],
Expand All @@ -330,6 +334,9 @@ export default {
data() {
return {
showDropdown: false,
selectedOption: 'Can edit',
options: ['Can view', 'Can edit', 'File drop'],
copySuccess: true,
copied: false,
Expand Down Expand Up @@ -671,7 +678,7 @@ export default {
* accordingly
*
* @param {Share} share the new share
* @param {boolean} [update=false] do we update the current share ?
* @param {boolean} [update] do we update the current share ?
*/
async pushNewLinkShare(share, update) {
try {
Expand Down Expand Up @@ -879,6 +886,12 @@ export default {
display: flex;
align-items: center;
min-height: 44px;
::v-deep &__avatar {
--size: 40px !important;
line-height: 40px !important;
}
&__desc {
display: flex;
flex-direction: column;
Expand Down
108 changes: 108 additions & 0 deletions apps/files_sharing/src/components/SharingEntryQuickShareSelect.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<template>
<div :class="{ 'active': showDropdown, 'share-select': true }">
<span class="trigger-text" @click="toggleDropdown">
{{ selectedOption }}
<DropdownIcon :size="15" />
</span>
<div v-if="showDropdown" class="share-select-dropdown-container">
<div v-for="option in options"
:key="option"
class="dropdown-item"
@click="selectOption(option)">
{{ option }}
</div>
</div>
</div>
</template>

<script>
import DropdownIcon from 'vue-material-design-icons/ArrowDown.vue'
export default {
components: {
DropdownIcon,
},
props: {
options: {
type: Array,
required: true,
},
value: {
type: String,
required: true,
},
toggle: {
type: Boolean,
default: false,
},
},
data() {
return {
showDropdown: this.toggle,
}
},
computed: {
selectedOption() {
return this.value
},
},
methods: {
toggleDropdown() {
this.showDropdown = !this.showDropdown
},
selectOption(option) {
this.$emit('update:value', option)
this.showDropdown = false
},
},
}
</script>

<style lang="scss" scoped>
.share-select {
position: relative;
cursor: pointer;
.trigger-text {
display: flex;
flex-direction: row;
align-items: center;
font-size: 12.5px;
gap: 5px;
color: var(--color-primary-element);
}
.share-select-dropdown-container {
position: absolute;
top: 100%;
left: 0;
width: 100%;
background-color: #ffffff;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
padding: 4px 0;
z-index: 1;
.dropdown-item {
padding: 8px;
font-size: 14px;
&:hover {
background-color: #f2f2f2;
}
}
}
/* Optional: Add a transition effect for smoother dropdown animation */
.share-select-dropdown-container {
max-height: 0;
overflow: hidden;
transition: max-height 0.3s ease;
}
&.active .share-select-dropdown-container {
max-height: 200px;
/* Adjust the value to your desired height */
}
}
</style>
Loading

0 comments on commit c10f540

Please sign in to comment.