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

Feat: Add additional locking information #9658

Merged
merged 5 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/unreleased/enhancement-display-lock-information
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ 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/pull/9658
https://github.com/owncloud/web/issues/6682
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@
<span v-else v-text="capitalizedTimestamp" />
</td>
</tr>
<tr v-if="resource.locked" data-testid="locked-by">
<th scope="col" class="oc-pr-s oc-font-semibold" v-text="$gettext('Locked by')" />
<td>
<span>{{ resource.lockOwnerName }} ({{ formatDateRelative(resource.lockTime) }})</span>
</td>
</tr>
<tr v-if="showSharedVia" data-testid="shared-via">
<th scope="col" class="oc-pr-s oc-font-semibold" v-text="$gettext('Shared via')" />
<td>
Expand Down Expand Up @@ -204,7 +210,11 @@ import {
import { getIndicators } from '../../../helpers/statusIndicators'
import { useClipboard } from '@vueuse/core'
import { encodePath } from 'web-pkg/src/utils'
import { formatDateFromHTTP, formatFileSize } from 'web-pkg/src/helpers'
import {
formatDateFromHTTP,
formatFileSize,
formatRelativeDateFromJSDate
} from 'web-pkg/src/helpers'
import { eventBus } from 'web-pkg/src/services/eventBus'
import { SideBarEventTopics } from 'web-pkg/src/composables/sideBar'
import { Resource, SpaceResource } from 'web-client'
Expand All @@ -218,6 +228,7 @@ export default defineComponent({
setup() {
const store = useStore()
const { $gettext } = useGettext()
const language = useGettext()
const client = useClientService()

const copiedDirect = ref(false)
Expand Down Expand Up @@ -326,6 +337,9 @@ export default defineComponent({
ShareTypes.containsAnyValue(ShareTypes.authenticated, a.shareTypes)
)
})
const formatDateRelative = (date) => {
return formatRelativeDateFromJSDate(new Date(date), language.current)
}

watch(
resource,
Expand Down Expand Up @@ -355,7 +369,8 @@ export default defineComponent({
hasTags: useCapabilityFilesTags(),
isPreviewLoading,
ancestorMetaData,
sharedAncestor
sharedAncestor,
formatDateRelative
}
},
computed: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ exports[`ResourceDetails component renders resource details correctly 1`] = `
<!--v-if-->
<!--v-if-->
<!--v-if-->
<!--v-if-->
<tr>
<th class="oc-pr-s oc-font-semibold" scope="col">Size</th>
<td>24 kB</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ const getResourceMock = ({
thumbnail = null,
shareTypes = [],
share = null,
path = '/somePath/someResource'
path = '/somePath/someResource',
locked = false
} = {}) =>
mock<Resource>({
id: '1',
Expand All @@ -33,7 +34,8 @@ const getResourceMock = ({
path,
thumbnail,
shareTypes,
share
share,
locked
})

const selectors = {
Expand All @@ -43,6 +45,7 @@ const selectors = {
ownerDisplayName: '[data-testid="ownerDisplayName"]',
preview: '[data-testid="preview"]',
resourceIcon: '.details-icon',
lockedBy: '[data-testid="locked-by"]',
sharedBy: '[data-testid="shared-by"]',
sharedVia: '[data-testid="shared-via"]',
sharingInfo: '[data-testid="sharingInfo"]',
Expand Down Expand Up @@ -94,6 +97,13 @@ describe('Details SideBar Panel', () => {
expect(wrapper.find(selectors.timestamp).exists()).toBeTruthy()
})
})
describe('locked by', () => {
it('shows if the resource is locked', () => {
const resource = getResourceMock({ locked: true })
const { wrapper } = createWrapper({ resource })
expect(wrapper.find(selectors.lockedBy).exists()).toBeTruthy()
})
})
describe('shared via', () => {
it('shows if the resource has an indirect share', () => {
const resource = getResourceMock()
Expand Down
7 changes: 5 additions & 2 deletions packages/web-client/src/helpers/resource/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,11 @@ export function buildResource(resource): Resource {
}

const lock = resource.fileInfo[DavProperty.LockDiscovery]
let activeLock
let activeLock, lockOwnerName, lockTime
if (lock) {
activeLock = lock[DavProperty.ActiveLock]
lockOwnerName = activeLock[DavProperty.LockOwnerName]
lockTime = activeLock[DavProperty.LockTime]
}
const id = resource.fileInfo[DavProperty.FileId]
const r = {
Expand All @@ -105,7 +107,8 @@ export function buildResource(resource): Resource {
type: isFolder ? 'folder' : resource.type,
isFolder,
locked: activeLock ? true : false,
lockOwner: activeLock ? activeLock[DavProperty.LockOwner] : '',
lockOwnerName,
lockTime,
processing: resource.processing || false,
mdate: resource.fileInfo[DavProperty.LastModifiedDate],
size: isFolder
Expand Down
3 changes: 2 additions & 1 deletion packages/web-client/src/helpers/resource/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ export interface Resource {
status?: number
processing?: boolean
locked?: boolean
lockOwner?: string
lockOwnerName?: string
lockTime?: string
spaceRoles?: {
[k: string]: SpaceRole[]
}
Expand Down
4 changes: 2 additions & 2 deletions packages/web-client/src/webdav/constants/dav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ export abstract class DavProperty {
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 LockOwnerName: string = '{http://owncloud.org/ns}ownername'
static readonly LockTime: string = '{http://owncloud.org/ns}locktime'
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 @@ -63,7 +64,6 @@ export abstract class DavProperties {
DavProperty.Name,
DavProperty.LockDiscovery,
DavProperty.ActiveLock,
DavProperty.LockOwner,
DavProperty.OwnerId,
DavProperty.OwnerDisplayName,
DavProperty.ShareId,
Expand Down