Commit 852ea20a authored by Bryce Johnson's avatar Bryce Johnson

Standardize filtered_search file.

parent 72772929
/* eslint-disable class-methods-use-this */
const AUTHOR_PARAM_KEY = 'author_username';
export default class FilteredSearchServiceDesk extends gl.FilteredSearchManager {
constructor() {
constructor(supportBotData) {
super('service_desk');
this.supportBotAttrs = JSON.parse(
document.querySelector('.service-desk-issues').dataset.supportBot,
);
this.supportBotData = supportBotData;
}
customRemovalValidator(token) {
const tokenValue = token.querySelector('.value-container');
return tokenValue ?
tokenValue.getAttribute('data-original-value') !== `@${this.supportBotAttrs.username}` : true;
tokenValue.getAttribute('data-original-value') !== `@${this.supportBotData.username}` : true;
}
canEdit(tokenName) {
......@@ -21,9 +21,8 @@ export default class FilteredSearchServiceDesk extends gl.FilteredSearchManager
}
modifyUrlParams(paramsArray) {
const authorParamKey = 'author_username';
const supportBotParamPair = `${authorParamKey}=${this.supportBotAttrs.username}`;
const onlyValidParams = paramsArray.filter(param => param.indexOf(authorParamKey) === -1);
const supportBotParamPair = `${AUTHOR_PARAM_KEY}=${this.supportBotData.username}`;
const onlyValidParams = paramsArray.filter(param => param.indexOf(AUTHOR_PARAM_KEY) === -1);
// unshift ensures author param is always first token element
onlyValidParams.unshift(supportBotParamPair);
......
import FilteredSearchServiceDesk from './filtered_search';
document.addEventListener('DOMContentLoaded', () => {
this.filteredSearchManager = new FilteredSearchServiceDesk();
const supportBotData = JSON.parse(
document.querySelector('.js-service-desk-issues').dataset.supportBot,
);
this.filteredSearchManager = new FilteredSearchServiceDesk(supportBotData);
this.filteredSearchManager.setup();
});
......@@ -16,7 +16,7 @@
- support_bot_attrs = User.support_bot.to_json(only: [:id, :name, :username, :avatar_url])
%div{ class: "#{container_class} service-desk-issues", data: { support_bot: support_bot_attrs } }
%div{ class: "#{container_class} js-service-desk-issues service-desk-issues", data: { support_bot: support_bot_attrs } }
.top-area
= render 'shared/issuable/nav', type: :issues
.nav-controls{ class: ("visible-xs" if show_new_nav?) }
......
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