mirror of
				https://github.com/mozilla/gecko-dev.git
				synced 2025-11-04 02:09:05 +02:00 
			
		
		
		
	For starters, replace all newtab styles and functions. Since we're removing these styles, I conformed the asrouter admin to the reusable components team's design tokens. So, it now uses global system page styles. This is a pretty general overhaul since there are so many styles to replace. In addition to the style changes, I've added a new Filters UI and moved the groups table to the General tab. This allows us to remove the Message Groups tab since that functionality is now rolled into the Filters UI. The same with the Private Browsing tab: when you hit Show on a pb_newtab message, it will open a PB window and override the message. And you can filter by template now, so you can view only PB messages on the General tab. I also fixed spellchecking. Instead of spellchecking, which only works for natural languages, we just validate that the text is valid JSON. If it's not valid, we show a red border on the textarea. That way messages won't just mysteriously fail to show. I also moved a few elements around to conserve space. Now, everything should be able to fit on the screen of a default window size of 1500px. Finally, I removed some old cruft that was left over from when the admin interface was part of the newtab page. Differential Revision: https://phabricator.services.mozilla.com/D213865
		
			
				
	
	
		
			107 lines
		
	
	
	
		
			2.6 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			107 lines
		
	
	
	
		
			2.6 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
/* This Source Code Form is subject to the terms of the Mozilla Public
 | 
						|
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 | 
						|
 * You can obtain one at http://mozilla.org/MPL/2.0/. */
 | 
						|
 | 
						|
import { MESSAGE_TYPE_HASH as msg } from "../modules/ActorConstants.mjs";
 | 
						|
 | 
						|
export const ASRouterUtils = {
 | 
						|
  addListener(listener) {
 | 
						|
    if (globalThis.ASRouterAddParentListener) {
 | 
						|
      globalThis.ASRouterAddParentListener(listener);
 | 
						|
    }
 | 
						|
  },
 | 
						|
  removeListener(listener) {
 | 
						|
    if (globalThis.ASRouterRemoveParentListener) {
 | 
						|
      globalThis.ASRouterRemoveParentListener(listener);
 | 
						|
    }
 | 
						|
  },
 | 
						|
  sendMessage(action) {
 | 
						|
    if (globalThis.ASRouterMessage) {
 | 
						|
      return globalThis.ASRouterMessage(action);
 | 
						|
    }
 | 
						|
    throw new Error(`Unexpected call:\n${JSON.stringify(action, null, 3)}`);
 | 
						|
  },
 | 
						|
  blockById(id, options) {
 | 
						|
    return ASRouterUtils.sendMessage({
 | 
						|
      type: msg.BLOCK_MESSAGE_BY_ID,
 | 
						|
      data: { id, ...options },
 | 
						|
    });
 | 
						|
  },
 | 
						|
  modifyMessageJson(content) {
 | 
						|
    return ASRouterUtils.sendMessage({
 | 
						|
      type: msg.MODIFY_MESSAGE_JSON,
 | 
						|
      data: { content },
 | 
						|
    });
 | 
						|
  },
 | 
						|
  executeAction(button_action) {
 | 
						|
    return ASRouterUtils.sendMessage({
 | 
						|
      type: msg.USER_ACTION,
 | 
						|
      data: button_action,
 | 
						|
    });
 | 
						|
  },
 | 
						|
  unblockById(id) {
 | 
						|
    return ASRouterUtils.sendMessage({
 | 
						|
      type: msg.UNBLOCK_MESSAGE_BY_ID,
 | 
						|
      data: { id },
 | 
						|
    });
 | 
						|
  },
 | 
						|
  unblockAll() {
 | 
						|
    return ASRouterUtils.sendMessage({
 | 
						|
      type: msg.UNBLOCK_ALL,
 | 
						|
    });
 | 
						|
  },
 | 
						|
  resetGroupImpressions() {
 | 
						|
    return ASRouterUtils.sendMessage({
 | 
						|
      type: msg.RESET_GROUPS_STATE,
 | 
						|
    });
 | 
						|
  },
 | 
						|
  resetMessageImpressions() {
 | 
						|
    return ASRouterUtils.sendMessage({
 | 
						|
      type: msg.RESET_MESSAGE_STATE,
 | 
						|
    });
 | 
						|
  },
 | 
						|
  resetScreenImpressions() {
 | 
						|
    return ASRouterUtils.sendMessage({
 | 
						|
      type: msg.RESET_SCREEN_IMPRESSIONS,
 | 
						|
    });
 | 
						|
  },
 | 
						|
  blockBundle(bundle) {
 | 
						|
    return ASRouterUtils.sendMessage({
 | 
						|
      type: msg.BLOCK_BUNDLE,
 | 
						|
      data: { bundle },
 | 
						|
    });
 | 
						|
  },
 | 
						|
  unblockBundle(bundle) {
 | 
						|
    return ASRouterUtils.sendMessage({
 | 
						|
      type: msg.UNBLOCK_BUNDLE,
 | 
						|
      data: { bundle },
 | 
						|
    });
 | 
						|
  },
 | 
						|
  overrideMessage(id) {
 | 
						|
    return ASRouterUtils.sendMessage({
 | 
						|
      type: msg.OVERRIDE_MESSAGE,
 | 
						|
      data: { id },
 | 
						|
    });
 | 
						|
  },
 | 
						|
  editState(key, value) {
 | 
						|
    return ASRouterUtils.sendMessage({
 | 
						|
      type: msg.EDIT_STATE,
 | 
						|
      data: { [key]: value },
 | 
						|
    });
 | 
						|
  },
 | 
						|
  openPBWindow(content) {
 | 
						|
    ASRouterUtils.sendMessage({
 | 
						|
      type: "FORCE_PRIVATE_BROWSING_WINDOW",
 | 
						|
      data: { message: { content } },
 | 
						|
    });
 | 
						|
  },
 | 
						|
  sendTelemetry(ping) {
 | 
						|
    return ASRouterUtils.sendMessage({
 | 
						|
      type: msg.AS_ROUTER_TELEMETRY_USER_EVENT,
 | 
						|
      data: ping,
 | 
						|
    });
 | 
						|
  },
 | 
						|
  getPreviewEndpoint() {
 | 
						|
    return null;
 | 
						|
  },
 | 
						|
};
 |