Commit 6d8e6723 authored by Martin Wortschack's avatar Martin Wortschack

Add skeleton for GlFilteredSearch

- Implement feature flag checks
and render legacy filtered search
when feature flag is disabled
parent dbf4a276
import Vue from 'vue'; import Vue from 'vue';
import store from './store'; import store from './store';
import CodeAnalyticsApp from './components/app.vue'; import CodeAnalyticsApp from './components/app.vue';
import FilteredSearchCodeReviewAnalytics from './filtered_search_code_review_analytics';
export default () => { export default () => {
const container = document.getElementById('js-code-review-analytics'); const container = document.getElementById('js-code-review-analytics');
...@@ -13,10 +12,6 @@ export default () => { ...@@ -13,10 +12,6 @@ export default () => {
new Vue({ new Vue({
el: container, el: container,
store, store,
created() {
this.filterManager = new FilteredSearchCodeReviewAnalytics();
this.filterManager.setup();
},
render(h) { render(h) {
return h(CodeAnalyticsApp, { return h(CodeAnalyticsApp, {
props: { props: {
......
<script> <script>
import { mapState, mapActions } from 'vuex'; import { mapState, mapActions } from 'vuex';
import { GlBadge, GlLoadingIcon, GlEmptyState, GlPagination } from '@gitlab/ui'; import { GlBadge, GlLoadingIcon, GlEmptyState, GlPagination } from '@gitlab/ui';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import MergeRequestTable from './merge_request_table.vue'; import MergeRequestTable from './merge_request_table.vue';
import FilteredSearchCodeReviewAnalytics from '../filtered_search_code_review_analytics';
export default { export default {
components: { components: {
...@@ -11,6 +13,7 @@ export default { ...@@ -11,6 +13,7 @@ export default {
GlEmptyState, GlEmptyState,
MergeRequestTable, MergeRequestTable,
}, },
mixins: [glFeatureFlagsMixin()],
props: { props: {
projectId: { projectId: {
type: Number, type: Number,
...@@ -41,8 +44,16 @@ export default { ...@@ -41,8 +44,16 @@ export default {
this.fetchMergeRequests(); this.fetchMergeRequests();
}, },
}, },
codeReviewAnalyticsHasNewSearch() {
return this.glFeatures.codeReviewAnalyticsHasNewSearch;
},
}, },
created() { created() {
if (!this.codeReviewAnalyticsHasNewSearch) {
this.filterManager = new FilteredSearchCodeReviewAnalytics();
this.filterManager.setup();
}
this.setProjectId(this.projectId); this.setProjectId(this.projectId);
this.fetchMergeRequests(); this.fetchMergeRequests();
}, },
...@@ -53,6 +64,11 @@ export default { ...@@ -53,6 +64,11 @@ export default {
</script> </script>
<template> <template>
<div>
<div
v-if="codeReviewAnalyticsHasNewSearch"
class="bg-secondary-50 p-3 border-top border-bottom"
></div>
<div class="mt-2"> <div class="mt-2">
<gl-loading-icon v-show="isLoading" size="md" class="mt-3" /> <gl-loading-icon v-show="isLoading" size="md" class="mt-3" />
<template v-if="!isLoading"> <template v-if="!isLoading">
...@@ -91,4 +107,5 @@ export default { ...@@ -91,4 +107,5 @@ export default {
</template> </template>
</template> </template>
</div> </div>
</div>
</template> </template>
...@@ -4,6 +4,9 @@ module Projects ...@@ -4,6 +4,9 @@ module Projects
module Analytics module Analytics
class CodeReviewsController < Projects::ApplicationController class CodeReviewsController < Projects::ApplicationController
before_action :authorize_read_code_review_analytics! before_action :authorize_read_code_review_analytics!
before_action do
push_frontend_feature_flag(:code_review_analytics_has_new_search)
end
def index def index
end end
......
...@@ -5,5 +5,6 @@ ...@@ -5,5 +5,6 @@
%h3 %h3
= _('Code Review') = _('Code Review')
%span.text-secondary= _('Review time is defined as the time it takes from first comment until merged.') %span.text-secondary= _('Review time is defined as the time it takes from first comment until merged.')
= render 'shared/issuable/search_bar', type: :issues_analytics, show_sorting_dropdown: false - if Feature.disabled?(:code_review_analytics_has_new_search)
= render 'shared/issuable/search_bar', type: :issues_analytics, show_sorting_dropdown: false
#js-code-review-analytics{ data: { project_id: @project.id, new_merge_request_url: namespace_project_new_merge_request_path(@project.namespace), empty_state_svg_path: image_path('illustrations/merge_requests.svg') } } #js-code-review-analytics{ data: { project_id: @project.id, new_merge_request_url: namespace_project_new_merge_request_path(@project.namespace), empty_state_svg_path: image_path('illustrations/merge_requests.svg') } }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
describe 'CodeReviewAnalytics', :js do describe 'CodeReviewAnalytics Filtered Search', :js do
include FilteredSearchHelpers include FilteredSearchHelpers
let(:user) { create(:user) } let(:user) { create(:user) }
...@@ -12,6 +12,11 @@ describe 'CodeReviewAnalytics', :js do ...@@ -12,6 +12,11 @@ describe 'CodeReviewAnalytics', :js do
stub_licensed_features(code_review_analytics: true) stub_licensed_features(code_review_analytics: true)
project.add_reporter(user) project.add_reporter(user)
end
context 'when the "new search" feature is disabled' do
before do
stub_feature_flags(code_review_analytics_has_new_search: false)
sign_in(user) sign_in(user)
...@@ -32,4 +37,21 @@ describe 'CodeReviewAnalytics', :js do ...@@ -32,4 +37,21 @@ describe 'CodeReviewAnalytics', :js do
expect(page).to have_content('Milestone') expect(page).to have_content('Milestone')
end end
end end
end
context 'when the "new search" feature is enabled' do
before do
stub_feature_flags(code_review_analytics_has_new_search: true)
sign_in(user)
visit project_analytics_code_reviews_path(project)
end
it 'does not render the filtered search bar' do
page.within('.content-wrapper .content') do
expect(page).not_to have_css('.issues-filters')
end
end
end
end end
...@@ -5,6 +5,12 @@ import CodeReviewAnalyticsApp from 'ee/analytics/code_review_analytics/component ...@@ -5,6 +5,12 @@ import CodeReviewAnalyticsApp from 'ee/analytics/code_review_analytics/component
import MergeRequestTable from 'ee/analytics/code_review_analytics/components/merge_request_table.vue'; import MergeRequestTable from 'ee/analytics/code_review_analytics/components/merge_request_table.vue';
import createState from 'ee/analytics/code_review_analytics/store/state'; import createState from 'ee/analytics/code_review_analytics/store/state';
jest.mock('ee/analytics/code_review_analytics/filtered_search_code_review_analytics', () =>
jest.fn().mockImplementation(() => ({
setup: jest.fn(),
})),
);
const localVue = createLocalVue(); const localVue = createLocalVue();
localVue.use(Vuex); localVue.use(Vuex);
...@@ -47,6 +53,11 @@ describe('CodeReviewAnalyticsApp component', () => { ...@@ -47,6 +53,11 @@ describe('CodeReviewAnalyticsApp component', () => {
newMergeRequestUrl: 'new_merge_request', newMergeRequestUrl: 'new_merge_request',
emptyStateSvgPath: 'svg', emptyStateSvgPath: 'svg',
}, },
provide: {
glFeatures: {
codeReviewAnalyticsHasNewSearch: false,
},
},
}); });
beforeEach(() => { beforeEach(() => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment