-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move sharing indicators into own component and add extension point
Moved to smaller components Load custom indicators as part of extension Added click handler
- Loading branch information
Showing
7 changed files
with
236 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
142 changes: 142 additions & 0 deletions
142
apps/files/src/components/FilesLists/StatusIndicators/DefaultIndicators.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
<template> | ||
<div> | ||
<oc-button | ||
v-for="(indicator, index) in indicators" | ||
:key="index" | ||
class="file-row-share-indicator uk-text-middle" | ||
:class="{ 'uk-margin-xsmall-left' : index > 0 }" | ||
:aria-label="indicator.label" | ||
@click="indicator.handler(item, indicator.id)" | ||
variation="raw" | ||
> | ||
<oc-icon | ||
:name="indicator.icon" | ||
class="uk-text-middle" | ||
size="small" | ||
:variation="indicator.status" | ||
/> | ||
</oc-button> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import intersection from 'lodash/intersection' | ||
import { shareTypes } from '../../../helpers/shareTypes' | ||
import { getParentPaths } from '../../../helpers/path' | ||
const userShareTypes = [shareTypes.user, shareTypes.group, shareTypes.guest, shareTypes.remote] | ||
export default { | ||
name: 'StatusIndicators', | ||
props: { | ||
item: { | ||
type: Object, | ||
required: true | ||
}, | ||
currentFolderPath: { | ||
type: String, | ||
required: true | ||
} | ||
}, | ||
computed: { | ||
indicators () { | ||
const indicators = [] | ||
if (this.isUserShare(this.item)) { | ||
indicators.push({ | ||
id: 'files-sharing', | ||
label: this.shareUserIconLabel(this.item), | ||
icon: 'group', | ||
status: this.shareUserIconVariation(this.item), | ||
handler: this.indicatorHandler | ||
}) | ||
} | ||
if (this.isLinkShare(this.item)) { | ||
indicators.push({ | ||
id: 'file-link', | ||
label: this.shareLinkIconLabel(this.item), | ||
icon: 'link', | ||
status: this.shareLinkIconVariation(this.item), | ||
handler: this.indicatorHandler | ||
}) | ||
} | ||
return indicators | ||
}, | ||
shareTypesIndirect () { | ||
const parentPaths = getParentPaths(this.currentFolderPath, true) | ||
if (parentPaths.length === 0) { | ||
return [] | ||
} | ||
// remove root entry | ||
parentPaths.pop() | ||
const shareTypes = {} | ||
parentPaths.forEach((parentPath) => { | ||
// TODO: optimize for performance by skipping once we got all known types | ||
const shares = this.sharesTree[parentPath] | ||
if (shares) { | ||
shares.forEach((share) => { | ||
// note: no distinction between incoming and outgoing shares as we display the same | ||
// indirect indicator for them | ||
shareTypes[share.info.share_type] = true | ||
}) | ||
} | ||
}) | ||
return Object.keys(shareTypes).map(shareType => parseInt(shareType, 10)) | ||
} | ||
}, | ||
methods: { | ||
isDirectUserShare (item) { | ||
return (intersection(userShareTypes, item.shareTypes).length > 0) | ||
}, | ||
isIndirectUserShare (item) { | ||
return (item.isReceivedShare() || intersection(userShareTypes, this.shareTypesIndirect).length > 0) | ||
}, | ||
isDirectLinkShare (item) { | ||
return (item.shareTypes.indexOf(shareTypes.link) >= 0) | ||
}, | ||
isIndirectLinkShare () { | ||
return (this.shareTypesIndirect.indexOf(shareTypes.link) >= 0) | ||
}, | ||
isUserShare (item) { | ||
return this.isDirectUserShare(item) || this.isIndirectUserShare(item) | ||
}, | ||
isLinkShare (item) { | ||
return this.isDirectLinkShare(item) || this.isIndirectLinkShare(item) | ||
}, | ||
shareUserIconVariation (item) { | ||
return this.isDirectUserShare(item) ? 'active' : 'passive' | ||
}, | ||
shareLinkIconVariation (item) { | ||
return this.isDirectLinkShare(item) ? 'active' : 'passive' | ||
}, | ||
shareUserIconLabel (item) { | ||
return this.isDirectUserShare(item) ? this.$gettext('Directly shared with collaborators') : this.$gettext('Shared with collaborators through one of the parent folders') | ||
}, | ||
shareLinkIconLabel (item) { | ||
return this.isDirectLinkShare(item) ? this.$gettext('Directly shared with links') : this.$gettext('Shared with links through one of the parent folders') | ||
}, | ||
indicatorHandler (item, sideBarName) { | ||
this.$emit('click', item, sideBarName) | ||
} | ||
} | ||
} | ||
</script> |
64 changes: 64 additions & 0 deletions
64
apps/files/src/components/FilesLists/StatusIndicators/StatusIndicators.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<template> | ||
<div class="uk-flex uk-flex-middle"> | ||
<DefaultIndicators | ||
v-if="displayDefaultIndicators" | ||
:item="item" | ||
:currentFolderPath="currentFolderPath" | ||
:class="{ 'uk-margin-xsmall-right' : customIndicators }" | ||
@click="openSidebar" | ||
/> | ||
<template v-if="customIndicators"> | ||
<component | ||
v-for="(indicator, index) in customIndicators" | ||
:is="indicator" | ||
:key="index" | ||
:item="item" | ||
:currentFolderPath="currentFolderPath" | ||
/> | ||
</template> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { mapGetters } from 'vuex' | ||
const DefaultIndicators = () => import('./DefaultIndicators.vue') | ||
export default { | ||
name: 'StatusIndicators', | ||
components: { | ||
DefaultIndicators | ||
}, | ||
props: { | ||
item: { | ||
type: Object, | ||
required: true | ||
}, | ||
currentFolderPath: { | ||
type: String, | ||
required: true | ||
} | ||
}, | ||
computed: { | ||
...mapGetters(['configuration', 'customFilesListIndicators']), | ||
displayDefaultIndicators () { | ||
return !this.configuration.theme.filesList.hideDefaultStatusIndicators | ||
}, | ||
customIndicators () { | ||
return this.customFilesListIndicators | ||
} | ||
}, | ||
methods: { | ||
// TODO: Adjust to send the event via store | ||
openSidebar (item, indicatorId) { | ||
this.$emit('click', item, indicatorId) | ||
} | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Enhancement: Add status indicator extension point | ||
|
||
We've added the ability for the extension to inject custom status indicator into files list. | ||
New indicators will then appear next to the default one. | ||
We've also added ability to disable default indicators. | ||
|
||
https://github.com/owncloud/phoenix/issues/2895 | ||
https://github.com/owncloud/phoenix/pull/2928 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,9 @@ const state = { | |
}, | ||
logo: { | ||
favicon: '' | ||
}, | ||
filesList: { | ||
hideDefaultStatusIndicators: false | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,5 +5,8 @@ | |
}, | ||
"logo": { | ||
"favicon": "themes/owncloud/favicon.jpg" | ||
}, | ||
"filesList": { | ||
"hideDefaultStatusIndicators": false | ||
} | ||
} |