Skip to content

Commit

Permalink
Merge pull request #6856 from owncloud/capability-based-searchbar
Browse files Browse the repository at this point in the history
[full-ci] Remove hideSearchBar config option in favor of capabilities
  • Loading branch information
kulmann authored May 3, 2022
2 parents 4d0b216 + b4457b8 commit 53ddc5a
Show file tree
Hide file tree
Showing 12 changed files with 104 additions and 204 deletions.
7 changes: 7 additions & 0 deletions changelog/unreleased/enhancement-capability-based-searchbar
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Enhancement: Capability-based searchbar rendering

We have removed the `hideSearchBar` configuration option and now always render a searchbar
if the backend announces the availability of search functionality using its capabilities.

https://github.com/owncloud/web/pull/6856
https://github.com/owncloud/web/issues/6806
1 change: 0 additions & 1 deletion dev/docker/ocis.web.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"scope": "openid profile email"
},
"options": {
"hideSearchBar": true,
"disablePreviews": true,
"displayResourcesLazy": false
},
Expand Down
1 change: 0 additions & 1 deletion docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ Please refer to the [build documentation for Web]({{< ref "./building.md" >}}).
Depending on the backend you are using, there are sample config files provided in the [config folder](https://github.com/owncloud/web/tree/master/config) of the ownCloud Web git repository. See below for available backends. Also, find some of the configuration details below.

#### Options
- `options.hideSearchBar` Lets you hide the search bar at the top of the screen for all users.
- `options.homeFolder` You can specify a folder that is used when the user navigates `home`. Navigating home gets triggered by clicking on the `All files`
menu item. The user will not be jailed in that directory. It simply serves as a default location. You can either provide a static location, or you can use
variables of the user object to come up with a user specific home path. This uses twig template variable style and allows you to pick a value or a
Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"@cucumber/messages": "^17.1.1",
"@cucumber/pretty-formatter": "^1.0.0-alpha.1",
"@noble/hashes": "^1.0.0",
"@playwright/test": "^1.19.2",
"@playwright/test": "^1.21.1",
"@rollup/plugin-alias": "^3.1.9",
"@rollup/plugin-commonjs": "^17.0.0",
"@rollup/plugin-html": "^0.2.4",
Expand All @@ -61,7 +61,7 @@
"@rollup/plugin-typescript": "^8.3.0",
"@types/jest": "^27.4.1",
"@types/jest-axe": "^3.5.3",
"@types/lodash-es": "^4.17.5",
"@types/lodash-es": "^4.17.6",
"@types/node": "^16.10.3",
"@types/node-fetch": "^2.6.0",
"@typescript-eslint/eslint-plugin": "^5.14.0",
Expand All @@ -80,14 +80,14 @@
"eslint-config-prettier": "^6.10.0",
"eslint-config-standard": "^16.0.3",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-jest": "^26.1.3",
"eslint-plugin-jest": "^26.1.5",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-promise": "^5.2.0",
"eslint-plugin-unused-imports": "^2.0.0",
"eslint-plugin-vue": "^7.13.0",
"eslint-plugin-vuejs-accessibility": "^0.7.1",
"focus-trap": "^6.4.0",
"focus-trap": "^6.9.0",
"focus-trap-vue": "^1.1.1",
"git-repo-info": "^2.1.1",
"jest": "^27.4.7",
Expand All @@ -101,7 +101,7 @@
"node-fetch": "^2.6.7",
"pino": "^7.9.2",
"pino-pretty": "^7.6.0",
"playwright": "^1.19.2",
"playwright": "^1.21.1",
"postcss": "^8.3.6",
"prettier": "^2.3.2",
"react": "^17.0.2",
Expand All @@ -126,8 +126,8 @@
"sync-fetch": "^0.3.1",
"ts-jest": "^27.1.3",
"ts-node": "^10.5.0",
"tslib": "^2.2.0",
"typescript": "^4.6.2",
"tslib": "^2.4.0",
"typescript": "^4.6.4",
"url-search-params-polyfill": "^8.0.0",
"vue-jest": "^3.0.7",
"vue-template-compiler": "^2.6.12",
Expand Down
5 changes: 1 addition & 4 deletions packages/web-app-files/src/search/sdk/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import List from './list'
import { EventBus } from 'web-pkg/src/event'
import { Store } from 'vuex'
import VueRouter from 'vue-router'
import get from 'lodash-es/get'

function $gettext(msg) {
return msg
Expand Down Expand Up @@ -54,8 +53,6 @@ export default class Provider extends EventBus implements SearchProvider {
}

public get available(): boolean {
const { hideSearchBar } = this.store.getters['Search/options']

return !get(this.store, 'state.config.options.hideSearchBar', hideSearchBar)
return this.store.getters.capabilities.dav.reports.includes('search-files')
}
}
40 changes: 15 additions & 25 deletions packages/web-app-files/tests/unit/search/sdk.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,18 @@ const localVue = createLocalVue()
localVue.use(Vuex)

const store = new Vuex.Store({
modules: {
Search: {
state: {
options: {
hideSearchBar: false
}
},
getters: {
options: (state) => {
return state.options
}
},
mutations: {
updateOptions(state, v) {
state.options = { ...state.options, hideSearchBar: v }
}
},
namespaced: true
}
getters: {
capabilities: jest.fn(() => ({
dav: {
reports: ['search-files']
}
}))
}
})

const storeWithoutFileSearch = new Vuex.Store({
getters: {
capabilities: jest.fn(() => ({ dav: { reports: [] } }))
}
})

Expand Down Expand Up @@ -72,12 +65,9 @@ describe('SDKProvider', () => {
expect('not-implemented').toBe('not-implemented')
})

it('is only available if enabled in options', () => {
const search = new SDKSearch(store, {} as unknown as VueRouter)
;[false, true, false].forEach((v) => {
store.commit('Search/updateOptions', v)
expect(search.available).toBe(!v)
})
it('is only available if announced via capabilities', () => {
const search = new SDKSearch(storeWithoutFileSearch, {} as unknown as VueRouter)
expect(search.available).toBe(false)
})

describe('SDKProvider previewSearch', () => {
Expand Down
2 changes: 0 additions & 2 deletions packages/web-app-search/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import SearchBar from './portals/SearchBar.vue'
import App from './App.vue'
import store from './store'
import List from './views/List.vue'
import { providerStore } from './service'
import { bus } from 'web-pkg/src/instance'
Expand All @@ -25,7 +24,6 @@ export default {
id: 'search',
icon: 'folder'
},
store,
routes: [
{
name: 'search',
Expand Down
6 changes: 0 additions & 6 deletions packages/web-app-search/src/store/index.ts

This file was deleted.

16 changes: 0 additions & 16 deletions packages/web-app-search/src/store/options.ts

This file was deleted.

9 changes: 0 additions & 9 deletions packages/web-app-search/tests/unit/store/options.spec.ts

This file was deleted.

4 changes: 2 additions & 2 deletions packages/web-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"focus-trap-vue": "^1.1.1",
"fuse.js": "^6.5.3",
"lodash-es": "^4.17.21",
"luxon": "^2.3.0",
"luxon": "^2.3.2",
"marked": "^4.0.12",
"oidc-client": "1.11.5",
"owncloud-design-system": "^13.1.0-rc.5",
Expand All @@ -33,7 +33,7 @@
"promise": "^8.0.3",
"qs": "^6.10.3",
"sanitize-html": "^2.7.0",
"semver": "^7.3.5",
"semver": "^7.3.7",
"tippy.js": "^6.3.7",
"utf8": "^3.0.0",
"uuid": "^8.3.2",
Expand Down
Loading

0 comments on commit 53ddc5a

Please sign in to comment.