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

Clean up JS.

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