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,42 +64,48 @@ export default { ...@@ -53,42 +64,48 @@ export default {
</script> </script>
<template> <template>
<div class="mt-2"> <div>
<gl-loading-icon v-show="isLoading" size="md" class="mt-3" /> <div
<template v-if="!isLoading"> v-if="codeReviewAnalyticsHasNewSearch"
<gl-empty-state class="bg-secondary-50 p-3 border-top border-bottom"
v-if="!totalItems" ></div>
:title="__(`You don't have any open merge requests`)" <div class="mt-2">
:primary-button-text="__('New merge request')" <gl-loading-icon v-show="isLoading" size="md" class="mt-3" />
:primary-button-link="newMergeRequestUrl" <template v-if="!isLoading">
:svg-path="emptyStateSvgPath" <gl-empty-state
> v-if="!totalItems"
<template #description> :title="__(`You don't have any open merge requests`)"
<div class="text-center"> :primary-button-text="__('New merge request')"
<p> :primary-button-link="newMergeRequestUrl"
{{ :svg-path="emptyStateSvgPath"
__( >
'Code Review Analytics displays a table of open merge requests considered to be in code review. There are currently no merge requests in review for this project and/or filters.', <template #description>
) <div class="text-center">
}} <p>
</p> {{
__(
'Code Review Analytics displays a table of open merge requests considered to be in code review. There are currently no merge requests in review for this project and/or filters.',
)
}}
</p>
</div>
</template>
</gl-empty-state>
<template v-else>
<div>
<span class="font-weight-bold">{{ __('Merge Requests in Review') }}</span>
<gl-badge pill>{{ totalItems }}</gl-badge>
</div> </div>
<merge-request-table />
<gl-pagination
v-model="currentPage"
:per-page="perPage"
:total-items="totalItems"
align="center"
class="w-100"
/>
</template> </template>
</gl-empty-state>
<template v-else>
<div>
<span class="font-weight-bold">{{ __('Merge Requests in Review') }}</span>
<gl-badge pill>{{ totalItems }}</gl-badge>
</div>
<merge-request-table />
<gl-pagination
v-model="currentPage"
:per-page="perPage"
:total-items="totalItems"
align="center"
class="w-100"
/>
</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,24 +12,46 @@ describe 'CodeReviewAnalytics', :js do ...@@ -12,24 +12,46 @@ 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
sign_in(user) context 'when the "new search" feature is disabled' do
before do
stub_feature_flags(code_review_analytics_has_new_search: false)
visit project_analytics_code_reviews_path(project) sign_in(user)
end
visit project_analytics_code_reviews_path(project)
end
it 'renders the filtered search bar correctly' do
page.within('.content-wrapper .content .issues-filters') do
expect(page).to have_css('.filtered-search-box')
end
end
it 'displays label and milestone in search hint' do
filtered_search.click
it 'renders the filtered search bar correctly' do page.within('#js-dropdown-hint') do
page.within('.content-wrapper .content .issues-filters') do expect(page).to have_content('Label')
expect(page).to have_css('.filtered-search-box') expect(page).to have_content('Milestone')
end
end end
end end
it 'displays label and milestone in search hint' do context 'when the "new search" feature is enabled' do
filtered_search.click before do
stub_feature_flags(code_review_analytics_has_new_search: true)
sign_in(user)
visit project_analytics_code_reviews_path(project)
end
page.within('#js-dropdown-hint') do it 'does not render the filtered search bar' do
expect(page).to have_content('Label') page.within('.content-wrapper .content') do
expect(page).to have_content('Milestone') expect(page).not_to have_css('.issues-filters')
end
end 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