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

[full-ci] Search improvements #7599

Merged
merged 21 commits into from
Sep 14, 2022
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
3 changes: 1 addition & 2 deletions packages/web-app-files/src/components/Search/List.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ import { defineComponent } from '@vue/composition-api'
import ListInfo from '../FilesList/ListInfo.vue'
import Pagination from '../FilesList/Pagination.vue'
import MixinFileActions from '../../mixins/fileActions'
import MixinFilesListFilter from '../../mixins/filesListFilter'
import MixinFilesListScrolling from '../../mixins/filesListScrolling'
import { searchLimit } from '../../search/sdk/list'
import { Resource } from 'web-client'
Expand All @@ -89,7 +88,7 @@ export default defineComponent({
ResourceTable,
FilesViewWrapper
},
mixins: [MixinFileActions, MixinFilesListFilter, MixinFilesListScrolling],
mixins: [MixinFileActions, MixinFilesListScrolling],
props: {
searchResult: {
type: Object,
Expand Down
37 changes: 28 additions & 9 deletions packages/web-app-files/src/components/Search/Preview.vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
<template>
<div class="files-search-preview">
<oc-button
:type="resource.isFolder ? 'router-link' : 'button'"
justify-content="left"
class="files-search-preview oc-flex oc-width-1-1"
appearance="raw"
v-bind="attrs"
v-on="listeners"
>
<oc-resource
:resource="resource"
:is-path-displayed="true"
:folder-link="folderLink"
:is-resource-clickable="false"
:parent-folder-link="parentFolderLink"
:parent-folder-name-default="defaultParentFolderName"
:is-thumbnail-displayed="displayThumbnails"
@click="$_fileActions_triggerDefaultAction(resource)"
/>
</div>
</oc-button>
</template>

<script lang="ts">
Expand All @@ -22,7 +28,7 @@ import Vue from 'vue'
import { mapGetters, mapState } from 'vuex'
import { createLocationSpaces } from '../../router'
import path from 'path'
import { useCapabilityShareJailEnabled, useStore } from 'web-pkg/src/composables'
import { useAccessToken, useCapabilityShareJailEnabled, useStore } from 'web-pkg/src/composables'

const visibilityObserver = new VisibilityObserver()

Expand All @@ -48,7 +54,9 @@ export default {
hasShareJail: useCapabilityShareJailEnabled(),
resourceTargetLocation: createLocationSpaces('files-spaces-personal', {
params: { storageId: store.getters.user.id }
})
}),
resourceTargetLocationSpace: createLocationSpaces('files-spaces-project'),
accessToken: useAccessToken({ store })
}
},
data() {
Expand All @@ -60,6 +68,20 @@ export default {
...mapGetters(['configuration', 'user']),
...mapState('runtime/spaces', ['spaces']),

attrs() {
return this.resource.isFolder
? {
to: this.createFolderLink(this.resource.path, this.resource)
}
: {}
},
listeners() {
return this.resource.isFolder
? {}
: {
click: () => this.$_fileActions_triggerDefaultAction(this.resource)
}
},
matchingSpace() {
return this.spaces.find((space) => space.id === this.resource.storageId)
},
Expand All @@ -80,9 +102,6 @@ export default {

return this.$gettext('Personal')
},
folderLink() {
return this.createFolderLink(this.resource.path, this.resource)
},
parentFolderLink() {
return this.createFolderLink(path.dirname(this.resource.path), this.resource)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ import { mapActions, mapGetters, mapMutations } from 'vuex'
import FileActions from '../../mixins/fileActions'
import MixinAcceptShare from '../../mixins/actions/acceptShare'
import MixinDeclineShare from '../../mixins/actions/declineShare'
import MixinFilesListFilter from '../../mixins/filesListFilter'
import { useCapabilityShareJailEnabled, useStore } from 'web-pkg/src/composables'
import { createLocationSpaces } from '../../router'
import ListInfo from '../../components/FilesList/ListInfo.vue'
Expand All @@ -115,7 +114,7 @@ export default defineComponent({
NoContentMessage
},

mixins: [FileActions, MixinAcceptShare, MixinDeclineShare, MixinFilesListFilter],
mixins: [FileActions, MixinAcceptShare, MixinDeclineShare],
props: {
title: {
type: String,
Expand Down
4 changes: 0 additions & 4 deletions packages/web-app-files/src/components/TrashBin.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@
import { mapGetters, mapMutations, mapState } from 'vuex'
import AppBar from './AppBar/AppBar.vue'
import ResourceTable from './FilesList/ResourceTable.vue'

import MixinFilesListFilter from '../mixins/filesListFilter'

import AppLoadingSpinner from 'web-pkg/src/components/AppLoadingSpinner.vue'
import NoContentMessage from 'web-pkg/src/components/NoContentMessage.vue'
import ListInfo from './FilesList/ListInfo.vue'
Expand Down Expand Up @@ -84,7 +81,6 @@ export default defineComponent({
SideBar
},

mixins: [MixinFilesListFilter],
props: {
breadcrumbs: { type: Array, default: () => [] },
noContentMessage: {
Expand Down
4 changes: 1 addition & 3 deletions packages/web-app-files/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Trashbin from './views/Trashbin.vue'
import translations from '../l10n/translations.json'
import quickActions from './quickActions'
import store from './store'
import { FilterSearch, SDKSearch } from './search'
import { SDKSearch } from './search'
import { bus } from 'web-pkg/src/instance'
import { archiverService, thumbnailService, Registry } from './services'
import fileSideBars from './fileSideBars'
Expand Down Expand Up @@ -117,12 +117,10 @@ export default {
quickActions,
translations,
ready({ router, store }) {
Registry.filterSearch = new FilterSearch(store, router)
Registry.sdkSearch = new SDKSearch(store, router)

// when discussing the boot process of applications we need to implement a
// registry that does not rely on call order, aka first register "on" and only after emit.
bus.publish('app.search.register.provider', Registry.filterSearch)
bus.publish('app.search.register.provider', Registry.sdkSearch)

archiverService.initialize(
Expand Down
10 changes: 8 additions & 2 deletions packages/web-app-files/src/mixins/actions/delete.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import MixinDeleteResources from '../../mixins/deleteResources'
import { mapState, mapGetters } from 'vuex'
import { isLocationPublicActive, isLocationSpacesActive, isLocationTrashActive } from '../../router'
import {
isLocationPublicActive,
isLocationSpacesActive,
isLocationTrashActive,
isLocationCommonActive
} from '../../router'

export default {
mixins: [MixinDeleteResources],
Expand All @@ -19,7 +24,8 @@ export default {
!isLocationSpacesActive(this.$router, 'files-spaces-personal') &&
!isLocationSpacesActive(this.$router, 'files-spaces-project') &&
!isLocationSpacesActive(this.$router, 'files-spaces-share') &&
!isLocationPublicActive(this.$router, 'files-public-files')
!isLocationPublicActive(this.$router, 'files-public-files') &&
!isLocationCommonActive(this.$router, 'files-common-search')
) {
return false
}
Expand Down
5 changes: 4 additions & 1 deletion packages/web-app-files/src/mixins/actions/downloadArchive.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ export default {
!isLocationSpacesActive(this.$router, 'files-spaces-share') &&
!isLocationPublicActive(this.$router, 'files-public-files') &&
!isLocationCommonActive(this.$router, 'files-common-favorites') &&
!isLocationSharesActive(this.$router, 'files-shares-with-me')
!isLocationCommonActive(this.$router, 'files-common-search') &&
!isLocationSharesActive(this.$router, 'files-shares-with-me') &&
!isLocationSharesActive(this.$router, 'files-shares-with-others') &&
!isLocationSharesActive(this.$router, 'files-shares-via-link')
) {
return false
}
Expand Down
9 changes: 7 additions & 2 deletions packages/web-app-files/src/mixins/actions/downloadFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import {
isLocationSpacesActive
} from '../../router'
import isFilesAppActive from './helpers/isFilesAppActive'
import isSearchActive from '../helpers/isSearchActive'

export default {
mixins: [isFilesAppActive],
mixins: [isFilesAppActive, isSearchActive],
computed: {
$_downloadFile_items() {
return [
Expand All @@ -21,12 +22,16 @@ export default {
isEnabled: ({ resources }) => {
if (
this.$_isFilesAppActive &&
!this.$_isSearchActive &&
!isLocationSpacesActive(this.$router, 'files-spaces-personal') &&
!isLocationSpacesActive(this.$router, 'files-spaces-project') &&
!isLocationSpacesActive(this.$router, 'files-spaces-share') &&
!isLocationPublicActive(this.$router, 'files-public-files') &&
!isLocationCommonActive(this.$router, 'files-common-favorites') &&
!isLocationSharesActive(this.$router, 'files-shares-with-me')
!isLocationCommonActive(this.$router, 'files-common-search') &&
AlexAndBear marked this conversation as resolved.
Show resolved Hide resolved
!isLocationSharesActive(this.$router, 'files-shares-with-me') &&
!isLocationSharesActive(this.$router, 'files-shares-with-others') &&
!isLocationSharesActive(this.$router, 'files-shares-via-link')
) {
return false
}
Expand Down
17 changes: 8 additions & 9 deletions packages/web-app-files/src/mixins/fileActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import Rename from './actions/rename'
import Restore from './actions/restore'
import kebabCase from 'lodash-es/kebabCase'
import { ShareStatus } from 'web-client/src/helpers/share'
import isSearchActive from './helpers/isSearchActive'

const actionsMixins = [
'navigate',
Expand Down Expand Up @@ -46,7 +47,8 @@ export default {
Move,
Navigate,
Rename,
Restore
Restore,
isSearchActive
],
computed: {
...mapState(['apps']),
Expand All @@ -60,12 +62,6 @@ export default {
},

$_fileActions_editorActions() {
if (
isLocationTrashActive(this.$router, 'files-trash-personal') ||
isLocationTrashActive(this.$router, 'files-trash-spaces-project')
) {
return []
}
return this.apps.fileEditors
.map((editor) => {
return {
Expand Down Expand Up @@ -98,8 +94,11 @@ export default {
}

if (
isLocationSharesActive(this.$router, 'files-shares-with-me') &&
resources[0].status !== ShareStatus.accepted
!this.$_isSearchActive &&
(isLocationTrashActive(this.$router, 'files-trash-personal') ||
isLocationTrashActive(this.$router, 'files-trash-spaces-project') ||
(isLocationSharesActive(this.$router, 'files-shares-with-me') &&
resources[0].status !== ShareStatus.accepted))
) {
return false
}
Expand Down
47 changes: 0 additions & 47 deletions packages/web-app-files/src/mixins/filesListFilter.js

This file was deleted.

7 changes: 7 additions & 0 deletions packages/web-app-files/src/mixins/helpers/isSearchActive.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default {
computed: {
$_isSearchActive(): boolean {
return !!document.getElementById('files-global-search-options')
}
}
}
49 changes: 0 additions & 49 deletions packages/web-app-files/src/search/filter/index.ts

This file was deleted.

Loading