[Request Blocking]: Adding error strings in list widget input
Changes:
- adding empty and duplicate error text for the list widget input in request blocking tool
Images:
Empty input: https://imgur.com/69xlqNU
Duplicate input: https://imgur.com/JafEuiI
Bug: 963183
Change-Id: I8abee8224371d7aa5d4f1882741c072e746ebb2b
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/1992313
Reviewed-by: Robert Paveza <[email protected]>
Commit-Queue: Michael Liao <[email protected]>
diff --git a/front_end/network/BlockedURLsPane.js b/front_end/network/BlockedURLsPane.js
index be2ed7c..d97ac94 100644
--- a/front_end/network/BlockedURLsPane.js
+++ b/front_end/network/BlockedURLsPane.js
@@ -162,8 +162,16 @@
Common.UIString('Text pattern to block matching requests; use * for wildcard');
const fields = content.createChild('div', 'blocked-url-edit-row');
const validator = (item, index, input) => {
- const valid = !!input.value && !this._manager.blockedPatterns().find(pattern => pattern.url === input.value);
- return {valid};
+ let valid = true;
+ let errorMessage;
+ if (!input.value) {
+ errorMessage = ls`Pattern input cannot be empty.`;
+ valid = false;
+ } else if (this._manager.blockedPatterns().find(pattern => pattern.url === input.value)) {
+ errorMessage = ls`Pattern already exists.`;
+ valid = false;
+ }
+ return {valid, errorMessage};
};
const urlInput = editor.createInput('url', 'text', '', validator);
fields.createChild('div', 'blocked-url-edit-value').appendChild(urlInput);