Skip to content

Commit

Permalink
Remove hideSearchBar config option in favor of capabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalwengerter committed May 2, 2022
1 parent f0ed9bd commit 95afd68
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 64 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
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.

0 comments on commit 95afd68

Please sign in to comment.