Commit 0e75de4b authored by Bryce Johnson's avatar Bryce Johnson

Clean up JS.

parent 205a0775
...@@ -420,14 +420,11 @@ class FilteredSearchManager { ...@@ -420,14 +420,11 @@ class FilteredSearchManager {
}); });
} }
// allows for modifying params array when a param can't be included in the URL (e.g. Service Desk)
getAllParams() { getAllParams() {
let params = gl.utils.getUrlParamsArray(); let urlParams = gl.utils.getUrlParamsArray();
if (this.modifyUrlParams) { return this.modifyUrlParams ? this.modifyUrlParams(urlParams) : urlParams;
params = this.modifyUrlParams(params);
}
return params;
} }
loadSearchParamsFromURL() { loadSearchParamsFromURL() {
......
export default class FilteredSearchServiceDesk extends gl.FilteredSearchManager { export default class FilteredSearchServiceDesk extends gl.FilteredSearchManager {
constructor() { constructor() {
super('service_desk'); super('service_desk');
this.cantEdit = ['author'];
this.bindCustomCondition();
} }
bindCustomCondition() { customRemovalValidator(token) {
this.customRemovalValidator = function(token) { return token.querySelector('.value-container').getAttribute('data-original-value') !== '@support-bot';
const originalValue = token.querySelector('.value-container').getAttribute('data-original-value');
return originalValue !== '@support-bot';
}; };
}
canEdit(tokenName) { canEdit(tokenName) {
return this.cantEdit.indexOf(tokenName) === -1; return tokenName !== 'author';
} }
modifyUrlParams(paramsArray) { modifyUrlParams(paramsArray) {
const support_bot_param = 'author_username=support-bot'; const paramKey = 'author_username';
let replaced = false; // FIXME: Need to grab the value from a data attribute
const supportBotParamPair = `${paramKey}=support-bot`;
const modified = paramsArray.map((param) => { return paramsArray.map((param) => {
const author_index = param.indexOf('author_username'); return param.indexOf(paramKey) !== -1 ? param : supportBotParamPair;
if (author_index !== -1) {
replaced = true;
return support_bot_param;
}
return param;
}); });
if (!replaced) {
modified.push(support_bot_param);
}
return modified;
} }
} }
import FilteredSearchServiceDesk from './filtered_search'; import FilteredSearchServiceDesk from './filtered_search';
// bulk edit?
//
this.filteredSearchManager = new FilteredSearchServiceDesk(); this.filteredSearchManager = new FilteredSearchServiceDesk();
this.filteredSearchManager.setup(); this.filteredSearchManager.setup();
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