feat: add option to set agent name(s) with RegEx

This commit is contained in:
Victor Westerlund 2025-10-13 16:47:47 +02:00
parent d0563e1edb
commit 660d67effb
Signed by: vlw
GPG key ID: D0AD730E1057DFC6
4 changed files with 36 additions and 4 deletions

View file

@ -9,4 +9,10 @@ body {
label {
user-select: none;
}
form {
hr {
opacity: .1;
}
}
}

View file

@ -19,6 +19,10 @@ document.querySelectorAll("input").forEach(async inputElement => {
// Fetch setting value from browser storage by input field name
const value = (await chrome.storage.sync.get([inputElement.name]))[inputElement.name];
if (!value) {
return;
}
switch (inputElement.type) {
case "checkbox":
return inputElement.checked = value === "true";

View file

@ -2,6 +2,7 @@ const CONFIG = {
AGENT_NAME : "agent_name",
DIM_NOT_ASSIGNED : "is_dim_not_assigned",
OPEN_TICKET_NEW_TAB : "is_open_ticket_new_tab",
AGENT_NAME_REGEX : "is_agent_name_regex",
MOVE_ASSIGNED_TO_TOP : "is_move_assigned_to_top",
// Resolve config value
@ -131,9 +132,16 @@ class FreshdeskFilters {
// Dim tickets not assigned to this agent is enabled
if (await CONFIG.get(CONFIG.DIM_NOT_ASSIGNED) === "true") {
tableRowElement.classList.remove(CLASSNAME.DIM_NOT_ASSIGNED);
// Check if this ticket is assigned to this agent
const isCurrentAgent = await CONFIG.get(CONFIG.AGENT_NAME_REGEX) !== "true"
// An agent name is explicitly defined
? ticketAgentName !== agentName
// Agent name(s) are defined with RegEx
: new RegExp(agentName).test(ticketAgentName);
// This ticket is not assigned to this agent
if (ticketAgentName !== AGENT_UNASSIGNED && ticketAgentName !== agentName) {
if (!isCurrentAgent && ticketAgentName !== AGENT_UNASSIGNED) {
tableRowElement.classList.add(CLASSNAME.DIM_NOT_ASSIGNED);
}
}

View file

@ -20,13 +20,27 @@
<h5>My name</h5>
<input type="text" name="agent_name" placeholder="Nisse Hult">
</label>
<label class="my-1">
<input type="checkbox" name="is_agent_name_regex">
Use Regular Expression
</label>
</div>
</div>
<hr>
<div class="row my-2 g-3">
<div>
<label class="my-1"><input type="checkbox" name="is_open_ticket_new_tab">Open tickets in a new tab</label>
<label class="my-1"><input type="checkbox" name="is_dim_not_assigned">Dim tickets that are not assigned to me</label>
<label class="my-1"><input type="checkbox" name="is_move_assigned_to_top">Move tickets assigned to me to the top</label>
<label class="my-1">
<input type="checkbox" name="is_open_ticket_new_tab">
Open tickets in a new tab
</label>
<label class="my-1">
<input type="checkbox" name="is_dim_not_assigned">
Dim tickets that are not assigned to me
</label>
<label class="my-1">
<input type="checkbox" name="is_move_assigned_to_top">
Move tickets assigned to me to the top
</label>
</div>
</div>
<div class="mt-3">