Commit 701ba4bc authored by Martin Wortschack's avatar Martin Wortschack

Add filtered search

- Adds the search bar to
the code analytics review page
parent 6b45f448
- type = local_assigns.fetch(:type) - type = local_assigns.fetch(:type)
- board = local_assigns.fetch(:board, nil) - board = local_assigns.fetch(:board, nil)
- show_sorting_dropdown = local_assigns.fetch(:show_sorting_dropdown, true)
- is_not_boards_modal_or_productivity_analytics = type != :boards_modal && type != :productivity_analytics - is_not_boards_modal_or_productivity_analytics = type != :boards_modal && type != :productivity_analytics
- block_css_class = is_not_boards_modal_or_productivity_analytics ? 'row-content-block second-block' : '' - block_css_class = is_not_boards_modal_or_productivity_analytics ? 'row-content-block second-block' : ''
- user_can_admin_list = board && can?(current_user, :admin_list, board.resource_parent) - user_can_admin_list = board && can?(current_user, :admin_list, board.resource_parent)
...@@ -169,5 +170,5 @@ ...@@ -169,5 +170,5 @@
- if @project - if @project
#js-add-issues-btn.prepend-left-10{ data: { can_admin_list: can?(current_user, :admin_list, @project) } } #js-add-issues-btn.prepend-left-10{ data: { can_admin_list: can?(current_user, :admin_list, @project) } }
#js-toggle-focus-btn #js-toggle-focus-btn
- elsif is_not_boards_modal_or_productivity_analytics - elsif is_not_boards_modal_or_productivity_analytics && show_sorting_dropdown
= render 'shared/issuable/sort_dropdown' = render 'shared/issuable/sort_dropdown'
import { __ } from '~/locale';
import FilteredSearchTokenKeys from '~/filtered_search/filtered_search_token_keys';
const tokenKeys = [
{
formattedKey: __('Milestone'),
key: 'milestone',
type: 'string',
param: 'title',
symbol: '%',
icon: 'clock',
tag: '%milestone',
},
{
formattedKey: __('Label'),
key: 'label',
type: 'array',
param: 'name[]',
symbol: '~',
icon: 'labels',
tag: '~label',
},
];
const CodeReviewAnalyticsFilteredSearchTokenKeys = new FilteredSearchTokenKeys(tokenKeys);
export default CodeReviewAnalyticsFilteredSearchTokenKeys;
<script>
export default {};
</script>
<template>
<div class="mt-2"></div>
</template>
import CodeReviewAnalyticsFilteredSearchTokenKeys from './code_review_analytics_filtered_search_token_keys';
import FilteredSearchManager from '~/filtered_search/filtered_search_manager';
export default class FilteredSearchCodeReviewAnalytics extends FilteredSearchManager {
constructor() {
super({
page: 'code_reviews',
isGroupDecendent: true,
stateFiltersSelector: '.issues-state-filters',
isGroup: true,
filteredSearchTokenKeys: CodeReviewAnalyticsFilteredSearchTokenKeys,
});
this.isHandledAsync = true;
}
}
import Vue from 'vue';
import CodeAnalyticsApp from './components/app.vue';
import FilteredSearchCodeReviewAnalytics from './filtered_search_code_review_analytics';
export default () => {
const container = document.getElementById('js-code-review-analytics');
if (!container) return;
// eslint-disable-next-line no-new
new Vue({
el: container,
mounted() {
this.filterManager = new FilteredSearchCodeReviewAnalytics();
this.filterManager.setup();
},
render(h) {
return h(CodeAnalyticsApp, {});
},
});
};
import initCodeReviewAnalyticsApp from 'ee/analytics/code_review_analytics';
document.addEventListener('DOMContentLoaded', () => {
initCodeReviewAnalyticsApp();
});
- if Feature.enabled?(:code_review_analytics) && can?(current_user, :read_code_review_analytics, @project) - if Feature.enabled?(:code_review_analytics) && can?(current_user, :read_code_review_analytics, @project)
- project_analytics_link = namespace_project_analytics_code_reviews_path(@project.namespace, @project) - project_analytics_link = project_analytics_code_reviews_path(@project)
= nav_link controller: :code_review do = nav_link controller: :code_review do
= link_to project_analytics_link, data: { qa_selector: 'project_analytics_link' } do = link_to project_analytics_link, data: { qa_selector: 'project_analytics_link' } do
......
- breadcrumb_title _("Code Review") - breadcrumb_title _("Code Review")
- page_title _("Code Review") - page_title _("Code Review")
.d-flex.align-items-center .mb-3
%h1.page-title %h3
= _('Code Review') = _('Code Review')
.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
#js-code-review-analytics{ data: { project: @project } } #js-code-review-analytics{ data: { project: @project } }
# frozen_string_literal: true
require 'spec_helper'
describe 'CodeReviewAnalytics', :js do
include FilteredSearchHelpers
let(:user) { create(:user) }
let(:project) { create(:project) }
before do
stub_licensed_features(code_review_analytics: true)
project.add_reporter(user)
sign_in(user)
end
context 'when the feature is enabled' do
before do
stub_feature_flags(code_review_analytics: true)
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
page.within('#js-dropdown-hint') do
expect(page).to have_content('Label')
expect(page).to have_content('Milestone')
end
end
end
end
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