[visual_logging] Consistently use dot-kebab-case for action IDs.
We are using the action IDs directly as context for the `action` VE
type, for which we intent to use kebab-case (with optional dots).
Therefore we should enforce this for `ActionRegistration`s, and
also make all existing actions comply.
Bug: b:320205413
Change-Id: I514059909240a3e65fca8363a74a842cd07fc8d2
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/5198410
Reviewed-by: Danil Somsikov <[email protected]>
diff --git a/front_end/ui/legacy/ActionRegistration.ts b/front_end/ui/legacy/ActionRegistration.ts
index a77102c..4be2b66 100644
--- a/front_end/ui/legacy/ActionRegistration.ts
+++ b/front_end/ui/legacy/ActionRegistration.ts
@@ -4,7 +4,7 @@
import * as Common from '../../core/common/common.js';
import * as i18n from '../../core/i18n/i18n.js';
-import type * as Platform from '../../core/platform/platform.js';
+import * as Platform from '../../core/platform/platform.js';
import * as Root from '../../core/root/root.js';
import {Context} from './Context.js';
@@ -233,7 +233,10 @@
export function registerActionExtension(registration: ActionRegistration): void {
const actionId = registration.actionId;
if (registeredActions.has(actionId)) {
- throw new Error(`Duplicate Action id '${actionId}': ${new Error().stack}`);
+ throw new Error(`Duplicate action ID '${actionId}'`);
+ }
+ if (!Platform.StringUtilities.isExtendedKebabCase(actionId)) {
+ throw new Error(`Invalid action ID '${actionId}'`);
}
registeredActions.set(actionId, new Action(registration));
}