Skip to content
代码片段 群组 项目
提交 c248bbb6 编辑于 作者: Heinrich Lee Yu's avatar Heinrich Lee Yu
浏览文件

Merge branch 'add-data-to-search-context' into 'master'

No related branches found
No related tags found
无相关合并请求
...@@ -20,12 +20,12 @@ export default { ...@@ -20,12 +20,12 @@ export default {
}, },
mixins: [glFeatureFlagsMixin()], mixins: [glFeatureFlagsMixin()],
props: { props: {
groupInitialData: { groupInitialJson: {
type: Object, type: Object,
required: false, required: false,
default: () => ({}), default: () => ({}),
}, },
projectInitialData: { projectInitialJson: {
type: Object, type: Object,
required: false, required: false,
default: () => ({}), default: () => ({}),
...@@ -72,11 +72,11 @@ export default { ...@@ -72,11 +72,11 @@ export default {
</div> </div>
<div v-if="showFilters" class="gl-mb-4 gl-lg-mb-0 gl-lg-mx-2"> <div v-if="showFilters" class="gl-mb-4 gl-lg-mb-0 gl-lg-mx-2">
<label class="gl-display-block">{{ __('Group') }}</label> <label class="gl-display-block">{{ __('Group') }}</label>
<group-filter :initial-data="groupInitialData" /> <group-filter :initial-data="groupInitialJson" />
</div> </div>
<div v-if="showFilters" class="gl-mb-4 gl-lg-mb-0 gl-lg-mx-2"> <div v-if="showFilters" class="gl-mb-4 gl-lg-mb-0 gl-lg-mx-2">
<label class="gl-display-block">{{ __('Project') }}</label> <label class="gl-display-block">{{ __('Project') }}</label>
<project-filter :initial-data="projectInitialData" /> <project-filter :initial-data="projectInitialJson" />
</div> </div>
</div> </div>
<hr v-if="hasVerticalNav" class="gl-mt-5 gl-mb-0 gl-border-gray-100" /> <hr v-if="hasVerticalNav" class="gl-mt-5 gl-mb-0 gl-border-gray-100" />
......
...@@ -11,10 +11,18 @@ export const initTopbar = (store) => { ...@@ -11,10 +11,18 @@ export const initTopbar = (store) => {
return false; return false;
} }
let { groupInitialData, projectInitialData } = el.dataset; const {
groupInitialJson,
projectInitialJson,
elasticsearchEnabled,
defaultBranchName,
} = el.dataset;
groupInitialData = JSON.parse(groupInitialData); const groupInitialJsonParsed = JSON.parse(groupInitialJson);
projectInitialData = JSON.parse(projectInitialData); const projectInitialJsonParsed = JSON.parse(projectInitialJson);
const elasticsearchEnabledParsed = elasticsearchEnabled
? JSON.parse(elasticsearchEnabled)
: false;
return new Vue({ return new Vue({
el, el,
...@@ -22,8 +30,10 @@ export const initTopbar = (store) => { ...@@ -22,8 +30,10 @@ export const initTopbar = (store) => {
render(createElement) { render(createElement) {
return createElement(GlobalSearchTopbar, { return createElement(GlobalSearchTopbar, {
props: { props: {
groupInitialData, groupInitialJson: groupInitialJsonParsed,
projectInitialData, projectInitialJson: projectInitialJsonParsed,
elasticsearchEnabled: elasticsearchEnabledParsed,
defaultBranchName,
}, },
}); });
}, },
......
...@@ -32,7 +32,7 @@ def self.search_rate_limited_endpoints ...@@ -32,7 +32,7 @@ def self.search_rate_limited_endpoints
before_action only: :show do before_action only: :show do
push_frontend_feature_flag(:search_page_vertical_nav, current_user) push_frontend_feature_flag(:search_page_vertical_nav, current_user)
end end
before_action :elasticsearch_in_use, only: :show
rescue_from ActiveRecord::QueryCanceled, with: :render_timeout rescue_from ActiveRecord::QueryCanceled, with: :render_timeout
layout 'search' layout 'search'
...@@ -118,6 +118,11 @@ def autocomplete ...@@ -118,6 +118,11 @@ def autocomplete
def opensearch def opensearch
end end
def elasticsearch_in_use
search_service.respond_to?(:use_elasticsearch?) && search_service.use_elasticsearch?
end
strong_memoize_attr :elasticsearch_in_use
private private
# overridden in EE # overridden in EE
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
= render_if_exists 'search/form_elasticsearch', attrs: { class: 'mb-2 mb-sm-0 align-self-center' } = render_if_exists 'search/form_elasticsearch', attrs: { class: 'mb-2 mb-sm-0 align-self-center' }
.gl-mt-3 .gl-mt-3
#js-search-topbar{ data: { "group-initial-data": group_attributes.to_json, "project-initial-data": project_attributes.to_json } } #js-search-topbar{ data: { "group-initial-json": group_attributes.to_json, "project-initial-json": project_attributes.to_json, "elasticsearch-enabled": @elasticsearch_in_use.to_s, "default-branch-name": @project&.default_branch } }
- if @search_term - if @search_term
- if Feature.disabled?(:search_page_vertical_nav, current_user) - if Feature.disabled?(:search_page_vertical_nav, current_user)
= render 'search/category' = render 'search/category'
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册