Skip to content

Commit

Permalink
Adjusted share model used in shared file list
Browse files Browse the repository at this point in the history
Now using _buildShare to have the same format like in other places.
  • Loading branch information
Vincent Petry committed Feb 27, 2020
1 parent b0b9960 commit bf877c2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 26 deletions.
12 changes: 6 additions & 6 deletions apps/files/src/components/Collaborators/SharedFilesList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,22 @@
<div><!-- indicators column --></div>
<div key="shared-with-cell" v-if="!$_isSharedWithMe" class="uk-text-meta uk-text-nowrap uk-text-truncate uk-width-medium uk-flex file-row-collaborators">
<span v-for="share in item.shares" :key="share.sourceId" class="uk-margin-small-right uk-flex uk-flex-middle">
<avatar-image v-if="share.type === shareTypes.user" class="uk-margin-xsmall-right" :width="24" :userid="share.targetName" :userName="share.targetDisplayName" />
<avatar-image v-if="share.shareType === shareTypes.user && share.collaborator" class="uk-margin-xsmall-right" :width="24" :userid="share.collaborator.name" :userName="share.collaborator.displayName" />
<oc-icon
v-else
:name="$_shareTypeIcon(share.type)"
:name="$_shareTypeIcon(share.shareType)"
class="uk-margin-xsmall-right"
size="small"
variation="active"
aria-hidden="true"
/>
<span v-if="share.targetDisplayName" v-text="share.targetDisplayName" />
<translate v-if="share.type === shareTypes.link" translate-context="Short public link indicator">Public</translate>
<span v-if="share.collaborator" v-text="share.collaborator.displayName" />
<translate v-if="share.shareType === shareTypes.link" translate-context="Short public link indicator">Public</translate>
</span>
</div>
<div v-else key="shared-from-cell" class="uk-text-meta uk-text-nowrap uk-text-truncate uk-width-small uk-flex uk-flex-middle file-row-collaborators">
<avatar-image class="uk-margin-xsmall-right" :width="24" :userid="item.shareOwner" :userName="item.shareOwnerDisplayname" />
<span v-text="item.shareOwnerDisplayname"/>
<avatar-image class="uk-margin-xsmall-right" :width="24" :userid="item.shareOwner.username" :userName="item.shareOwner.displayName" />
<span v-text="item.shareOwner.displayName"/>
</div>
<div v-if="$route.name === 'files-shared-with-me'" class="uk-text-nowrap uk-width-small" :key="item.id + item.status">
<a v-if="item.status === 1 || item.status === 2" class="uk-text-meta" @click="pendingShareAction(item, 'POST')" v-translate>Accept</a>
Expand Down
36 changes: 16 additions & 20 deletions apps/files/src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,24 +133,21 @@ function _aggregateFileShares (data, incomingShares = false) {
id: share.item_source,
sourceId: share.item_source,
type: share.item_type,
extension: share.item_type !== 'dir' ? path.extname(share.path) : '',
share: {
id: share.id,
type: share.share_type,
targetName: share.share_with,
shareTime: share.stime * 1000,
shareTimeMoment: moment(share.stime * 1000),
expiration: share.expiration
}
extension: share.item_type !== 'dir' ? path.extname(share.path) : ''
}
file.share = _buildShare(share, file)

file.canDownload = () => file.item_type !== 'folder'

if (incomingShares) {
file.owner = share.uid_file_owner
file.ownerDisplayname = share.displayname_file_owner
file.shareOwner = share.uid_owner
file.shareOwnerDisplayname = share.displayname_owner
file.owner = {
username: share.uid_file_owner,
displayName: share.displayname_file_owner
}
file.shareOwner = {
username: share.uid_owner,
displayName: share.displayname_owner
}
file.status = share.state
file.name = path.basename(share.file_target)
file.basename = path.basename(share.file_target, file.extension)
Expand All @@ -163,10 +160,6 @@ function _aggregateFileShares (data, incomingShares = false) {
file.isMounted = () => false
file.isReceivedShare = () => true
} else {
if (share.share_type !== shareTypes.link) {
file.share.targetName = share.share_with
file.share.targetDisplayName = share.share_with_displayname
}
file.shareOwner = share.uid_owner
file.shareOwnerDisplayname = share.displayname_owner
file.name = path.basename(share.path)
Expand All @@ -192,11 +185,13 @@ function _aggregateFileShares (data, incomingShares = false) {
if (!data) {
data = memo[file.id] = file
data.shares = [file.share]
data.mtime = file.share.stime
data.shareTime = file.share.stime * 1000
data.shareTimeMoment = moment(file.share.stime * 1000)
} else {
// always take the most recent stime
if (file.share.stime > data.mtime) {
data.shareTime = file.share.stime
if (file.share.stime * 1000 > data.shareTime) {
data.shareTime = file.share.stime * 1000
data.shareTimeMoment = moment(file.share.stime * 1000)
}
data.shares.push(file.share)
}
Expand Down Expand Up @@ -311,6 +306,7 @@ function _buildCollaboratorShare (s, file) {
share.expires = Date.parse(s.expiration)
}
share.path = s.path
share.stime = s.stime

return share
}
Expand Down

0 comments on commit bf877c2

Please sign in to comment.