Skip to content

Commit

Permalink
Move link share list items into a new component to avoid code
Browse files Browse the repository at this point in the history
duplication and fix styling of indirect link shares.
  • Loading branch information
kulmann committed Jan 30, 2020
1 parent 390b149 commit f854fc9
Show file tree
Hide file tree
Showing 3 changed files with 150 additions and 112 deletions.
12 changes: 6 additions & 6 deletions apps/files/src/components/Collaborators/Collaborator.vue
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<template>
<oc-table middle class="files-collaborators-collaborator">
<oc-table-row v-if="$_reshareInformation || $_getViaLabel" class="files-collaborators-collaborator-table-row-extra">
<oc-table-row v-if="$_reshareInformation || $_viaLabel" class="files-collaborators-collaborator-table-row-extra">
<oc-table-cell shrink colspan="2"></oc-table-cell>
<oc-table-cell colspan="2">
<div v-if="$_reshareInformation" class="uk-text-meta uk-flex uk-flex-middle">
<oc-icon name="repeat" class="uk-preserve-width" />
<span>{{ $_reshareInformation }}</span>
</div>
<div v-if="$_getViaLabel" class="uk-text-meta">
<router-link :to="$_getViaRouterParams" :aria-label="$gettext('Navigate to parent')"
<div v-if="$_viaLabel" class="uk-text-meta">
<router-link :to="$_viaRouterParams" :aria-label="$gettext('Navigate to parent')"
class="files-collaborators-collaborator-follow-via uk-flex uk-flex-middle">
<oc-icon name="exit_to_app" size="small" class="uk-preserve-width" />
<span class="oc-file-name uk-padding-remove uk-text-truncate files-collaborators-collaborator-via-label">{{ $_getViaLabel }}</span>
<span class="oc-file-name uk-padding-remove uk-text-truncate files-collaborators-collaborator-via-label">{{ $_viaLabel }}</span>
</router-link>
</div>
</oc-table-cell>
Expand Down Expand Up @@ -99,15 +99,15 @@ export default {
return parseInt(this.collaborator.info.share_type, 10)
},
$_getViaLabel () {
$_viaLabel () {
if (!this.$_isIndirectShare) {
return null
}
const translated = this.$gettext('Via %{folderName}')
return this.$gettextInterpolate(translated, { folderName: basename(this.collaborator.info.path) }, false)
},
$_getViaRouterParams () {
$_viaRouterParams () {
const viaPath = this.collaborator.info.path
return {
name: 'files-list',
Expand Down
122 changes: 16 additions & 106 deletions apps/files/src/components/FileLinkSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,42 +34,17 @@
name="custom-classes-transition"
tag="ul">
<li v-for="link in $_links" :key="'li-' + link.id">
<oc-table midldle class="files-file-links-link">
<oc-table-row class="files-file-links-link-table-row-info">
<oc-table-cell shrink>
<oc-button :aria-label="$_deleteButtonLabel" @click="$_removePublicLink(link)" variation="raw" class="oc-files-file-link-delete">
<oc-icon name="close" />
</oc-button>
</oc-table-cell>
<oc-table-cell>
<a :href="link.url" target="_blank" :uk-tooltip="$_tooltipTextLink" class="uk-text-bold uk-text-truncate oc-files-file-link-url">{{ link.name }}</a>
<br>
<span class="uk-text-meta uk-text-break">
<span class="oc-files-file-link-role">{{ link.description }}</span>
<template v-if="link.expiration"> |
<span v-translate>Expires</span> {{ formDateFromNow(link.expiration) }}
</template>
<template v-if="link.password"> |
<span v-translate>Password protected</span>
</template>
</span>
</oc-table-cell>
<oc-table-cell shrink class="uk-text-nowrap">
<oc-button :aria-label="$_publicLinkCopyLabel" variation="raw" class="oc-files-file-link-copy-url">
<oc-icon v-if="!linksCopied[link.url]" name="copy_to_clipboard" size="small"
v-clipboard:copy="link.url" v-clipboard:success="$_clipboardSuccessHandler"/>
<oc-icon v-else name="ready" size="small" class="oc-files-file-link-copied-url _clipboard-success-animation"/>
</oc-button>
<oc-button :aria-label="$_editButtonLabel" @click="$_editPublicLink(link)" variation="raw" class="oc-files-file-link-edit">
<oc-icon name="edit" size="small"/>
</oc-button>
</oc-table-cell>
</oc-table-row>
</oc-table>
<public-link-list-item :link="link"
:modifiable="true"
:indirect="false"
:linksCopied="linksCopied"
@onCopy="$_clipboardSuccessHandler"
@onDelete="$_removePublicLink"
@onEdit="$_editPublicLink" />
</li>
</transition-group>
</section>
<section v-if="$_indirectLinks.length > 0" class="uk-margin-medium-bottom">
<section v-if="$_indirectLinks.length > 0" class="uk-margin-medium-top">
<div class="uk-text-bold">
<translate>Public Links Via Parent</translate>
</div>
Expand All @@ -79,43 +54,11 @@
name="custom-classes-transition"
tag="ul">
<li v-for="link in $_indirectLinks" :key="'li-' + link.id">
<div class="uk-text-meta">
<router-link :to="$_getViaRouterParams(link)" :aria-label="$gettext('Navigate to parent')"
class="oc-files-file-link-via uk-flex uk-flex-middle">
<oc-icon name="exit_to_app" size="small" class="uk-preserve-width" />
<span class="oc-file-name uk-padding-remove uk-text-truncate files-collaborators-collaborator-via-label">{{ $_getViaLabel(link) }}</span>
</router-link>
</div>
<oc-table midldle class="files-file-links-link">
<oc-table-row class="files-file-links-link-table-row-info">
<oc-table-cell shrink>
<oc-icon name="lock" />
</oc-table-cell>
<oc-table-cell>
<a :href="link.url" target="_blank" :uk-tooltip="$_tooltipTextLink" class="uk-text-bold uk-text-truncate oc-files-file-link-url">{{ link.name }}</a>
<br>
<span class="uk-text-meta uk-text-break">
<span class="oc-files-file-link-role">{{ link.description }}</span>
<template v-if="link.expiration"> |
<span v-translate>Expires</span> {{ formDateFromNow(link.expiration) }}
</template>
<template v-if="link.password"> |
<span v-translate>Password protected</span>
</template>
</span>
</oc-table-cell>
<oc-table-cell shrink class="uk-text-nowrap">
<oc-button :aria-label="$_publicLinkCopyLabel" variation="raw" class="oc-files-file-link-copy-url">
<oc-icon v-if="!linksCopied[link.url]" name="copy_to_clipboard" size="small"
v-clipboard:copy="link.url" v-clipboard:success="$_clipboardSuccessHandler"/>
<oc-icon v-else name="ready" size="small" class="oc-files-file-link-copied-url _clipboard-success-animation"/>
</oc-button>
<oc-button :aria-label="$_editButtonLabel" @click="$_editPublicLink(link)" variation="raw" class="oc-files-file-link-edit">
<oc-icon name="edit" size="small"/>
</oc-button>
</oc-table-cell>
</oc-table-row>
</oc-table>
<public-link-list-item :link="link"
:modifiable="false"
:indirect="true"
:linksCopied="linksCopied"
@onCopy="$_clipboardSuccessHandler" />
</li>
</transition-group>
</section>
Expand All @@ -137,18 +80,19 @@ import { mapGetters, mapActions, mapState } from 'vuex'
import moment from 'moment'
import mixins from '../mixins'
import { shareTypes } from '../helpers/shareTypes'
import { basename, dirname } from 'path'
import { getParentPaths } from '../helpers/path'
const EditPublicLink = _ => import('./PublicLinksSidebar/EditPublicLink.vue')
const PublicLinkListItem = _ => import('./PublicLinksSidebar/PublicLinkListItem.vue')
const PANEL_SHOW = 'showLinks'
const PANEL_EDIT = 'editPublicLink'
export default {
mixins: [mixins],
components: {
EditPublicLink
EditPublicLink,
PublicLinkListItem
},
title: ($gettext) => {
return $gettext('Links')
Expand Down Expand Up @@ -242,21 +186,9 @@ export default {
enforced: expireDate.enforced === '1'
}
},
$_tooltipTextLink () {
return `title: ${this.$gettext('Click to open the link')}; pos: bottom`
},
$_addButtonLabel () {
return this.$gettext('Add public link')
},
$_deleteButtonLabel () {
return this.$gettext('Delete public link')
},
$_editButtonLabel () {
return this.$gettext('Edit public link')
},
$_publicLinkCopyLabel () {
return this.$gettext('Copy public link url')
},
$_privateLinkCopyLabel () {
return this.$gettext('Copy private link url')
},
Expand All @@ -282,22 +214,6 @@ export default {
expireDate: (this.$_expirationDate.days) ? moment().add(this.$_expirationDate.days, 'days').endOf('day').toISOString() : null
}
},
$_getViaLabel (link) {
const translated = this.$gettext('Via %{folderName}')
return this.$gettextInterpolate(translated, { folderName: basename(link.info.path) }, false)
},
$_getViaRouterParams (link) {
const viaPath = link.info.path
return {
name: 'files-list',
params: {
item: dirname(viaPath) || '/'
},
query: {
scrollTo: basename(viaPath)
}
}
},
$_removePublicLink (link) {
this.removeLink({
client: this.$client,
Expand Down Expand Up @@ -351,12 +267,6 @@ export default {
}
}
</style>
<style scoped="scoped">
/* FIXME: Move to ODS somehow */
.files-file-links-link-table-row-info > td {
padding: 0 10px 0 0;
}
</style>
<style>
/* FIXME: Move to design system (copied from FileSharingSidebar.vue) */
.oc-app-side-bar .oc-label {
Expand Down
128 changes: 128 additions & 0 deletions apps/files/src/components/PublicLinksSidebar/PublicLinkListItem.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
<template>
<oc-table middle class="files-file-links-link">
<oc-table-row v-if="$_viaLabel" class="files-file-links-link-table-row-extra">
<oc-table-cell shrink></oc-table-cell>
<oc-table-cell colspan="2">
<div class="uk-text-meta">
<router-link :to="$_viaRouterParams" :aria-label="$gettext('Navigate to parent')"
class="oc-files-file-link-via uk-flex uk-flex-middle">
<oc-icon name="exit_to_app" size="small" class="uk-preserve-width" />
<span class="oc-file-name uk-padding-remove uk-text-truncate files-file-links-link-via-label">{{ $_viaLabel }}</span>
</router-link>
</div>
</oc-table-cell>
</oc-table-row>
<oc-table-row class="files-file-links-link-table-row-info">
<oc-table-cell shrink>
<oc-button v-if="modifiable" :aria-label="$_deleteButtonLabel" @click="$_removePublicLink(link)" variation="raw" class="oc-files-file-link-delete">
<oc-icon name="close" />
</oc-button>
<oc-icon v-else name="lock" />
</oc-table-cell>
<oc-table-cell>
<a :href="link.url" target="_blank" :uk-tooltip="$_tooltipTextLink" class="uk-text-bold uk-text-truncate oc-files-file-link-url">{{ link.name }}</a>
<br>
<span class="uk-text-meta uk-text-break">
<span class="oc-files-file-link-role">{{ link.description }}</span>
<template v-if="link.expiration"> |
<span v-translate>Expires</span> {{ formDateFromNow(link.expiration) }}
</template>
<template v-if="link.password"> |
<span v-translate>Password protected</span>
</template>
</span>
</oc-table-cell>
<oc-table-cell shrink class="uk-text-nowrap">
<oc-button :aria-label="$_publicLinkCopyLabel" variation="raw" class="oc-files-file-link-copy-url">
<oc-icon v-if="!linksCopied[link.url]" name="copy_to_clipboard" size="small"
v-clipboard:copy="link.url" v-clipboard:success="this.$emit('onCopy', link.url)"/>
<oc-icon v-else name="ready" size="small" class="oc-files-file-link-copied-url _clipboard-success-animation"/>
</oc-button>
<oc-button v-if="modifiable" :aria-label="$_editButtonLabel" @click="this.$emit('onEdit', link)" variation="raw" class="oc-files-file-link-edit">
<oc-icon name="edit" size="small"/>
</oc-button>
</oc-table-cell>
</oc-table-row>
</oc-table>
</template>

<script>
import { basename, dirname } from 'path'
export default {
name: 'PublicLinkListItem',
props: {
link: {
type: Object,
required: true
},
modifiable: {
type: Boolean,
default: false
},
indirect: {
type: Boolean,
default: false
},
linksCopied: {
type: Object,
default: () => {}
}
},
computed: {
$_viaLabel () {
if (!this.indirect) {
return null
}
const translated = this.$gettext('Via %{folderName}')
return this.$gettextInterpolate(translated, { folderName: basename(this.link.info.path) }, false)
},
$_viaRouterParams () {
const viaPath = this.link.info.path
console.log({
name: 'files-list',
params: {
item: dirname(viaPath) || '/'
},
query: {
scrollTo: basename(viaPath)
}
})
return {
name: 'files-list',
params: {
item: dirname(viaPath) || '/'
},
query: {
scrollTo: basename(viaPath)
}
}
},
$_tooltipTextLink () {
return `title: ${this.$gettext('Click to open the link')}; pos: bottom`
},
$_deleteButtonLabel () {
return this.$gettext('Delete public link')
},
$_editButtonLabel () {
return this.$gettext('Edit public link')
},
$_publicLinkCopyLabel () {
return this.$gettext('Copy public link url')
}
}
}
</script>

<style scoped="scoped">
/* FIXME: Move to ODS somehow */
.files-file-links-link-table-row-extra > td {
padding: 0 10px 5px 0;
}
.files-file-links-link-table-row-info > td {
padding: 0 10px 0 0;
}
.files-file-links-link-via-label {
max-width: 65%;
}
</style>

0 comments on commit f854fc9

Please sign in to comment.