Skip to content

Commit

Permalink
move hideSearchBar option into search app
Browse files Browse the repository at this point in the history
  • Loading branch information
fschade committed Jun 29, 2021
1 parent 651a856 commit 028f222
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 7 deletions.
8 changes: 6 additions & 2 deletions packages/web-app-files/src/search/sdk/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { EventBus } from 'web-pkg/src/event'
export default class Provider extends EventBus implements SearchProvider {
public readonly id: string
public readonly label: string
public readonly available: boolean
public readonly previewSearch: SearchPreview
public readonly listSearch: SearchList
private readonly store: any
Expand All @@ -20,7 +19,6 @@ export default class Provider extends EventBus implements SearchProvider {
this.previewSearch = new Preview(store, router)
this.listSearch = new List(store)
this.store = store
this.available = true
this.router = router
}

Expand All @@ -42,4 +40,10 @@ export default class Provider extends EventBus implements SearchProvider {
public updateTerm(term: string): void {
/* not needed */
}

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

return !hideSearchBar
}
}
8 changes: 4 additions & 4 deletions packages/web-app-search/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
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 @@ -15,6 +16,7 @@ export default {
id: 'search',
icon: 'folder'
},
store,
routes: [
{
name: 'search',
Expand All @@ -31,9 +33,7 @@ export default {
]
}
],
mounted({ store, portal }) {
if (!store.getters.configuration.options.hideSearchBar) {
portal.open('runtime', 'header', 1, [SearchBar])
}
mounted({ portal }) {
portal.open('runtime', 'header', 1, [SearchBar])
}
}
1 change: 1 addition & 0 deletions packages/web-app-search/src/portals/SearchBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
</ul>
</div>
</div>
<div v-else><!-- no search provider available --></div>
</template>

<script>
Expand Down
4 changes: 4 additions & 0 deletions packages/web-app-search/src/store/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import merge from 'lodash-es/merge'
import options from './options'

export default merge({ namespaced: true }, options)
16 changes: 16 additions & 0 deletions packages/web-app-search/src/store/options.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const state = {
options: {
hideSearchBar: false
}
}

const getters = {
options: state => {
return state.options
}
}

export default {
state,
getters
}
1 change: 0 additions & 1 deletion packages/web-runtime/src/store/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ const state = {
},
options: {
defaultExtension: 'files',
hideSearchBar: false,
homeFolder: '',
disablePreviews: false,
previewFileExtensions: []
Expand Down

0 comments on commit 028f222

Please sign in to comment.