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

Remove unused code, rename share path #9843

Merged
merged 11 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from 6 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
10 changes: 10 additions & 0 deletions changelog/unreleased/enhancement-add-editors-to-application-menu
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Enhancement: Add editors to the application menu

We've added 'text-editor' and 'draw.io' to the application menu, so the user can easily
open those apps with a one-click approach.
We've also fixed a bug, where the full path of a resource was missing while hovering it, for example in
AlexAndBear marked this conversation as resolved.
Show resolved Hide resolved
the search preview.

https://github.com/owncloud/web/pull/9809
https://github.com/owncloud/web/pull/9843
https://github.com/owncloud/web/issues/9807
180 changes: 91 additions & 89 deletions packages/design-system/src/components/OcResource/OcResource.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
:full-path="resource.path"
:is-path-displayed="isPathDisplayed"
:is-extension-displayed="isExtensionDisplayed"
@click="$emit('clickFolder')"
AlexAndBear marked this conversation as resolved.
Show resolved Hide resolved
/>
</oc-resource-link>
<div class="oc-resource-indicators">
Expand All @@ -65,7 +66,7 @@
:to="parentFolderLink"
:style="parentFolderStyle"
class="parent-folder"
@click.stop="$emit('parentFolderClicked')"
@click.stop="$emit('clickParentFolder')"
>
<oc-icon v-bind="parentFolderLinkIconAttrs" />
<span class="text" v-text="parentFolderName" />
Expand Down Expand Up @@ -189,7 +190,7 @@ export default defineComponent({
default: true
}
},
emits: ['click', 'parentFolderClicked'],
emits: ['click', 'clickFolder', 'clickParentFolder'],
computed: {
parentFolderComponentType() {
return this.parentFolderLink !== null ? 'router-link' : 'span'
Expand Down Expand Up @@ -301,6 +302,7 @@ export default defineComponent({
a {
text-decoration: none;
}

a:hover,
a:focus {
outline-offset: 0;
Expand Down Expand Up @@ -345,94 +347,94 @@ export default defineComponent({
</style>

<docs>
```js
<template>
<div>
<oc-resource :resource="documents" parent-folder-link="parentFolderLink" class="oc-mb" />
<oc-resource :resource="notes" is-path-displayed="true" class="oc-mb" />
<oc-resource :resource="notes" is-resource-clickable="false" class="oc-mb" />
<oc-resource :resource="notes" :is-extension-displayed="false" class="oc-mb" />
<oc-resource :resource="forest" is-path-displayed="true" />
<oc-resource :resource="something" is-path-displayed="true" parent-folder-name="Example parent folder" />
</div>
</template>
<script>
export default {
computed: {
documents() {
return {
name: "Documents",
path: "/Documents",
indicators: [],
type: "folder",
isFolder: true
}
},
notes() {
return {
name: "notes.txt",
extension: "txt",
path: "Documents/notes.txt",
indicators: this.indicators,
type: "file",
isFolder: false
}
},
forest() {
return {
name: "forest-image-with-filename-with-a-lot-of-characters.jpg",
extension: "jpg",
path: "images/nature/forest-image-with-filename-with-a-lot-of-characters.jpg",
thumbnail: "https://picsum.photos/200/300",
indicators: [],
type: "file",
isFolder: false,
opensInNewWindow: true,
}
},
something() {
return {
name: "another-image.jpg",
extension: "jpg",
path: "another-image.jpg",
thumbnail: "https://picsum.photos/200/300",
indicators: [],
type: "file",
isFolder: false,
opensInNewWindow: true,
```js
<template>
<div>
<oc-resource :resource="documents" parent-folder-link="parentFolderLink" class="oc-mb"/>
<oc-resource :resource="notes" is-path-displayed="true" class="oc-mb"/>
<oc-resource :resource="notes" is-resource-clickable="false" class="oc-mb"/>
<oc-resource :resource="notes" :is-extension-displayed="false" class="oc-mb"/>
<oc-resource :resource="forest" is-path-displayed="true"/>
<oc-resource :resource="something" is-path-displayed="true" parent-folder-name="Example parent folder"/>
</div>
</template>
<script>
export default {
computed: {
documents() {
return {
name: "Documents",
path: "/Documents",
indicators: [],
type: "folder",
isFolder: true
}
},
notes() {
return {
name: "notes.txt",
extension: "txt",
path: "Documents/notes.txt",
indicators: this.indicators,
type: "file",
isFolder: false
}
},
forest() {
return {
name: "forest-image-with-filename-with-a-lot-of-characters.jpg",
extension: "jpg",
path: "images/nature/forest-image-with-filename-with-a-lot-of-characters.jpg",
thumbnail: "https://picsum.photos/200/300",
indicators: [],
type: "file",
isFolder: false,
opensInNewWindow: true,
}
},
something() {
return {
name: "another-image.jpg",
extension: "jpg",
path: "another-image.jpg",
thumbnail: "https://picsum.photos/200/300",
indicators: [],
type: "file",
isFolder: false,
opensInNewWindow: true,
}
},
indicators() {
return [
{
id: 'files-sharing',
label: "Shared with other people",
visible: true,
icon: 'group',
handler: (resource, indicatorId) => alert(`Resource: ${resource.name}, indicator: ${indicatorId}`)
},
{
id: 'file-link',
label: "Shared via link",
visible: true,
icon: 'link',
}
},
indicators() {
return [
{
id: 'files-sharing',
label: "Shared with other people",
visible: true,
icon: 'group',
handler: (resource, indicatorId) => alert(`Resource: ${resource.name}, indicator: ${indicatorId}`)
},
{
id: 'file-link',
label: "Shared via link",
visible: true,
icon: 'link',
}
]
},
parentFolderLink() {
return {
name: "home",
params: {
action: "copy",
item: 'Documents',
},
query: {
resource: "notes"
}
]
},
parentFolderLink() {
return {
name: "home",
params: {
action: "copy",
item: 'Documents',
},
query: {
resource: "notes"
}
}
},
}
</script>
```
}
},
}
</script>
```
</docs>
61 changes: 15 additions & 46 deletions packages/web-pkg/src/components/Search/ResourcePreview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
:parent-folder-link-icon-additional-attributes="parentFolderLinkIconAdditionalAttributes"
:parent-folder-name="parentFolderName"
:is-thumbnail-displayed="displayThumbnails"
@parent-folder-clicked="parentFolderClicked"
@click-parent-folder="folderClicked"
@click-folder="folderClicked"
/>
</oc-button>
</template>
Expand All @@ -27,23 +28,16 @@ import { VisibilityObserver } from '../../observer'
import { debounce } from 'lodash-es'
import { computed, defineComponent, PropType, ref, unref } from 'vue'
import { mapGetters } from 'vuex'
import { createLocationShares, createLocationSpaces } from '../../router'
import path, { dirname } from 'path'
import {
useCapabilityShareJailEnabled,
useGetMatchingSpace,
useFileActions,
useFolderLink
} from '../../composables'
import {
isProjectSpaceResource,
isShareSpaceResource,
Resource
} from '@ownclouders/web-client/src/helpers'
import { Resource } from '@ownclouders/web-client/src/helpers'
import { eventBus } from '../../services'
import { createFileRouteOptions, isResourceTxtFileAlmostEmpty } from '../../helpers'
import { isResourceTxtFileAlmostEmpty } from '../../helpers'
import { SearchResultValue } from './types'
import { useGettext } from 'vue3-gettext'

const visibilityObserver = new VisibilityObserver()

Expand All @@ -64,9 +58,13 @@ export default defineComponent({
},
setup(props) {
const { getInternalSpace, getMatchingSpace } = useGetMatchingSpace()
const { getPathPrefix, getParentFolderName, getParentFolderLinkIconAdditionalAttributes } =
useFolderLink()
const { $gettext } = useGettext()
const {
getPathPrefix,
getParentFolderName,
getParentFolderLink,
getParentFolderLinkIconAdditionalAttributes,
getFolderLink
} = useFolderLink()
const previewData = ref()

const resource = computed((): Resource => {
Expand All @@ -81,28 +79,21 @@ export default defineComponent({

const space = computed(() => getMatchingSpace(unref(resource)))

const spaceName = computed(() => {
if (isShareSpaceResource(unref(space))) {
return path.join($gettext('Shared with me'), unref(space).name)
}

return unref(space).name
})

const resourceDisabled = computed(() => {
return unref(resource).disabled === true
})

return {
space,
spaceName,
...useFileActions(),
getInternalSpace,
getMatchingSpace,
hasShareJail: useCapabilityShareJailEnabled(),
previewData,
resource,
resourceDisabled,
parentFolderLink: getParentFolderLink(unref(resource)),
folderLink: getFolderLink(unref(resource)),
pathPrefix: getPathPrefix(unref(resource)),
parentFolderName: getParentFolderName(unref(resource)),
parentFolderLinkIconAdditionalAttributes: getParentFolderLinkIconAdditionalAttributes(
Expand All @@ -117,7 +108,7 @@ export default defineComponent({
attrs() {
return this.resource.isFolder
? {
to: this.createFolderLink(this.resource.path, this.resource.fileId)
to: this.folderLink
}
: {}
},
Expand All @@ -137,18 +128,6 @@ export default defineComponent({
!this.configuration?.options?.disablePreviews &&
!isResourceTxtFileAlmostEmpty(this.resource)
)
},
folderLink() {
return this.createFolderLink(this.resource.path, this.resource.fileId)
},
parentFolderLink() {
if (this.resource.shareId && this.resource.path === '/') {
return createLocationShares('files-shares-with-me')
}
if (isProjectSpaceResource(this.resource)) {
return createLocationSpaces('files-spaces-projects')
}
return this.createFolderLink(dirname(this.resource.path), this.resource.parentFolderId)
}
},
mounted() {
Expand Down Expand Up @@ -179,18 +158,8 @@ export default defineComponent({
visibilityObserver.disconnect()
},
methods: {
parentFolderClicked() {
folderClicked() {
eventBus.publish('app.search.options-drop.hide')
},
createFolderLink(p: string, fileId: string | number) {
if (!this.space) {
return {}
}

return createLocationSpaces(
'files-spaces-generic',
createFileRouteOptions(this.space, { path: p, fileId })
)
}
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const useFolderLink = (options: ResourceRouteResolverOptions = {}) => {
}

if (isShareSpaceResource(space)) {
return path.join($gettext('Shares'), $gettext('Shared with me'), space.name)
return path.join($gettext('Shares'), space.name)
}

return space.name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,6 @@ describe('Preview component', () => {

expect(ocResource.props().resource).toMatchObject(wrapper.vm.searchResult.data)
})
describe('computed parentFolderLink', () => {
it('should use the items storageId for the resource target location if present', () => {
const driveAliasAndItem = '1'
const { wrapper } = getWrapper({
space: mock<SpaceResource>({
id: '1',
driveType: 'project',
name: 'New space',
getDriveAliasAndItem: () => driveAliasAndItem
})
})
expect(wrapper.vm.parentFolderLink.params.driveAliasAndItem).toEqual(driveAliasAndItem)
})
})
})

function getWrapper({
Expand Down
Loading