Skip to content
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

Implement file locking information #9566

Merged
merged 16 commits into from
Aug 24, 2023
Merged
6 changes: 6 additions & 0 deletions changelog/unreleased/enhancement-display-lock-information
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Enhancement: Display locking information

We've added indicators and information in case a file is locked.

https://github.com/owncloud/web/pull/9566
https://github.com/owncloud/web/issues/6682
23 changes: 15 additions & 8 deletions packages/design-system/src/components/OcResource/OcResource.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,15 @@
class="oc-resource-thumbnail"
width="40"
height="40"
v-oc-tooltip="tooltipLabelIcon"
:aria-label="tooltipLabelIcon"
/>
<oc-resource-icon v-else :resource="resource">
<oc-resource-icon
v-oc-tooltip="tooltipLabelIcon"
:aria-label="tooltipLabelIcon"
v-else
:resource="resource"
>
<template v-if="showStatusIcon" #status>
<oc-icon v-bind="statusIconAttrs" size="xsmall" />
</template>
Expand Down Expand Up @@ -216,6 +223,13 @@ export default defineComponent({
return this.resource.locked || this.resource.processing
},

tooltipLabelIcon() {
if (this.resource.locked) {
return this.$gettext('This item is locked')
}
return null
},

statusIconAttrs() {
if (this.resource.locked) {
return {
Expand All @@ -224,13 +238,6 @@ export default defineComponent({
}
}

if (this.resource.processing) {
return {
name: 'loop-right',
fillType: 'line'
}
}

lookacat marked this conversation as resolved.
Show resolved Hide resolved
return {}
}
},
Expand Down
24 changes: 22 additions & 2 deletions packages/design-system/src/components/OcTile/OcTile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@
>
<span v-text="$gettext('Disabled')" />
</oc-tag>
<div class="oc-tile-card-preview oc-flex oc-flex-middle oc-flex-center">
<div
class="oc-tile-card-preview oc-flex oc-flex-middle oc-flex-center"
v-oc-tooltip="tooltipLabelIcon"
:aria-label="tooltipLabelIcon"
>
<div class="oc-tile-card-hover"></div>
<slot name="imageField" :item="resource">
<oc-img v-if="resource.thumbnail" class="tile-preview" :src="resource.thumbnail" />
Expand Down Expand Up @@ -76,6 +80,7 @@ import OcResource from '../OcResource/OcResource.vue'
import OcResourceIcon from '../OcResourceIcon/OcResourceIcon.vue'
import OcResourceLink from '../OcResourceLink/OcResourceLink.vue'
import OcTag from '../OcTag/OcTag.vue'
import { useGettext } from 'vue3-gettext'

export default defineComponent({
name: 'OcTile',
Expand Down Expand Up @@ -119,6 +124,7 @@ export default defineComponent({
},
emits: ['click', 'contextmenu'],
setup(props) {
const { $gettext } = useGettext()
const showStatusIcon = computed(() => {
return props.resource.locked || props.resource.processing
})
Expand All @@ -141,9 +147,23 @@ export default defineComponent({
return {}
})

const tooltipLabelIcon = computed(() => {
if (props.resource.locked) {
return $gettext('This item is locked')
}
if (props.resource.processing) {
return {
name: 'loop-right',
fillType: 'line'
}
}
return null
})

return {
statusIconAttrs,
showStatusIcon
showStatusIcon,
tooltipLabelIcon
}
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ export default defineComponent({
setup() {
const store = useStore()
const { $gettext } = useGettext()
const client = useClientService()

const copiedDirect = ref(false)
const copiedEos = ref(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ export const useFileActionsDelete = ({ store }: { store?: Store<any> } = {}) =>
return false
}

if (resources.length === 1 && resources[0].locked) {
lookacat marked this conversation as resolved.
Show resolved Hide resolved
return false
}

if (isLocationCommonActive(router, 'files-common-search')) {
return resources.some(
(r) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ export const useFileActionsMove = ({ store }: { store?: Store<any> } = {}) => {
return false
}

if (resources.length === 1 && resources[0].locked) {
lookacat marked this conversation as resolved.
Show resolved Hide resolved
return false
}

const moveDisabled = resources.some((resource) => {
return canBeMoved(resource, store.getters['Files/currentFolder'].path) === false
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ export const useFileActionsRename = ({ store }: { store?: Store<any> } = {}) =>
return false
}

if (resources.length === 1 && resources[0].locked) {
lookacat marked this conversation as resolved.
Show resolved Hide resolved
return false
}

const renameDisabled = resources.some((resource) => {
return !resource.canRename()
})
Expand Down
8 changes: 8 additions & 0 deletions packages/web-client/src/helpers/resource/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ export function buildResource(resource): Resource {
if (!resourcePath.startsWith('/')) {
resourcePath = `/${resourcePath}`
}

const lock = resource.fileInfo[DavProperty.LockDiscovery]
let activeLock
if (lock) {
activeLock = lock[DavProperty.ActiveLock]
}
const id = resource.fileInfo[DavProperty.FileId]
const r = {
id,
Expand All @@ -98,6 +104,8 @@ export function buildResource(resource): Resource {
webDavPath: resource.name,
type: isFolder ? 'folder' : resource.type,
isFolder,
locked: activeLock ? true : false,
lockOwner: activeLock ? activeLock[DavProperty.LockOwner] : '',
processing: resource.processing || false,
mdate: resource.fileInfo[DavProperty.LastModifiedDate],
size: isFolder
Expand Down
1 change: 1 addition & 0 deletions packages/web-client/src/helpers/resource/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export interface Resource {
status?: number
processing?: boolean
locked?: boolean
lockOwner?: string
spaceRoles?: {
[k: string]: SpaceRole[]
}
Expand Down
6 changes: 6 additions & 0 deletions packages/web-client/src/webdav/constants/dav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ export abstract class DavProperty {
static readonly ETag: string = '{DAV:}getetag'
static readonly MimeType: string = '{DAV:}getcontenttype'
static readonly ResourceType: string = '{DAV:}resourcetype'
static readonly LockDiscovery: string = '{DAV:}lockdiscovery'
static readonly LockOwner: string = '{DAV:}owner'
static readonly ActiveLock: string = '{DAV:}activelock'
static readonly DownloadURL: string = '{http://owncloud.org/ns}downloadURL'
static readonly Highlights: string = '{http://owncloud.org/ns}highlights'

Expand Down Expand Up @@ -58,6 +61,9 @@ export abstract class DavProperties {
DavProperty.FileId,
DavProperty.FileParent,
DavProperty.Name,
DavProperty.LockDiscovery,
DavProperty.ActiveLock,
DavProperty.LockOwner,
DavProperty.OwnerId,
DavProperty.OwnerDisplayName,
DavProperty.ShareId,
Expand Down
2 changes: 1 addition & 1 deletion packages/web-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"luxon": "^2.4.0",
"marked": "^4.0.12",
"oidc-client-ts": "^2.1.0",
"owncloud-sdk": "~3.1.0-alpha.7",
"owncloud-sdk": "3.1.0-alpha.8",
"p-queue": "^6.6.2",
"pinia": "^2.1.3",
"portal-vue": "3.0.0",
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.