Commit 66e84693 authored by Bryce Johnson's avatar Bryce Johnson

Fully freeze author token.

parent b6b46f2e
...@@ -338,9 +338,10 @@ class FilteredSearchManager { ...@@ -338,9 +338,10 @@ class FilteredSearchManager {
this.filteredSearchInput.value = ''; this.filteredSearchInput.value = '';
const removeElements = []; const removeElements = [];
const customValidator = this.customRemovalValidator || function (t) { return true };
[].forEach.call(this.tokensContainer.children, (t) => { [].forEach.call(this.tokensContainer.children, (t) => {
if (t.classList.contains('js-visual-token')) { if (t.classList.contains('js-visual-token') && customValidator(t)) {
removeElements.push(t); removeElements.push(t);
} }
}); });
...@@ -419,8 +420,18 @@ class FilteredSearchManager { ...@@ -419,8 +420,18 @@ class FilteredSearchManager {
}); });
} }
getAllParams() {
let params = gl.utils.getUrlParamsArray();
if (this.modifyUrlParams) {
params = this.modifyUrlParams(params);
}
return params;
}
loadSearchParamsFromURL() { loadSearchParamsFromURL() {
const params = gl.utils.getUrlParamsArray(); const params = this.getAllParams();
const usernameParams = this.getUsernameParams(); const usernameParams = this.getUsernameParams();
let hasFilteredSearch = false; let hasFilteredSearch = false;
...@@ -566,6 +577,7 @@ class FilteredSearchManager { ...@@ -566,6 +577,7 @@ class FilteredSearchManager {
getUsernameParams() { getUsernameParams() {
const usernamesById = {}; const usernamesById = {};
try { try {
const attribute = this.filteredSearchInput.getAttribute('data-username-params'); const attribute = this.filteredSearchInput.getAttribute('data-username-params');
JSON.parse(attribute).forEach((user) => { JSON.parse(attribute).forEach((user) => {
......
...@@ -3,10 +3,38 @@ export default class FilteredSearchServiceDesk extends gl.FilteredSearchManager ...@@ -3,10 +3,38 @@ export default class FilteredSearchServiceDesk extends gl.FilteredSearchManager
super('service_desk'); super('service_desk');
this.cantEdit = ['author']; this.cantEdit = ['author'];
this.bindCustomCondition();
}
bindCustomCondition() {
this.customRemovalValidator = function(token) {
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 this.cantEdit.indexOf(tokenName) === -1;
} }
modifyUrlParams(paramsArray) {
const support_bot_param = 'author_username=support-bot';
let replaced = false;
const modified = paramsArray.map((param) => {
const author_index = param.indexOf('author_username');
if (author_index !== -1) {
replaced = true;
return support_bot_param;
}
return param;
});
if (!replaced) {
modified.push(support_bot_param);
}
return modified;
}
} }
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