Merge pull request #4146 from k88hudson/bug1460377
Bug 1460377 - Hide Manage Section option for Web Extension sections and show Manage Extension
This commit is contained in:
Коммит
3599df34ae
|
@ -171,6 +171,7 @@ section_menu_action_remove_section=Remove Section
|
|||
section_menu_action_collapse_section=Collapse Section
|
||||
section_menu_action_expand_section=Expand Section
|
||||
section_menu_action_manage_section=Manage Section
|
||||
section_menu_action_manage_webext=Manage Extension
|
||||
section_menu_action_add_topsite=Add Top Site
|
||||
section_menu_action_move_up=Move Up
|
||||
section_menu_action_move_down=Move Down
|
||||
|
|
|
@ -51,6 +51,7 @@ for (const type of [
|
|||
"OPEN_LINK",
|
||||
"OPEN_NEW_WINDOW",
|
||||
"OPEN_PRIVATE_WINDOW",
|
||||
"OPEN_WEBEXT_SETTINGS",
|
||||
"PAGE_PRERENDERED",
|
||||
"PLACES_BOOKMARK_ADDED",
|
||||
"PLACES_BOOKMARK_REMOVED",
|
||||
|
|
|
@ -148,7 +148,7 @@ export class _CollapsibleSection extends React.PureComponent {
|
|||
render() {
|
||||
const isCollapsible = this.props.collapsed !== undefined;
|
||||
const {enableAnimation, isAnimating, maxHeight, menuButtonHover, showContextMenu} = this.state;
|
||||
const {id, eventSource, collapsed, disclaimer, title, extraMenuOptions, showPrefName, privacyNoticeURL, dispatch, isFirst, isLast} = this.props;
|
||||
const {id, eventSource, collapsed, disclaimer, title, extraMenuOptions, showPrefName, privacyNoticeURL, dispatch, isFirst, isLast, isWebExtension} = this.props;
|
||||
const disclaimerPref = `section.${id}.showDisclaimer`;
|
||||
const needsDisclaimer = disclaimer && this.props.Prefs.values[disclaimerPref];
|
||||
const active = menuButtonHover || showContextMenu;
|
||||
|
@ -186,7 +186,8 @@ export class _CollapsibleSection extends React.PureComponent {
|
|||
onUpdate={this.onMenuUpdate}
|
||||
isFirst={isFirst}
|
||||
isLast={isLast}
|
||||
dispatch={dispatch} />
|
||||
dispatch={dispatch}
|
||||
isWebExtension={isWebExtension} />
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -5,12 +5,13 @@ import React from "react";
|
|||
import {SectionMenuOptions} from "content-src/lib/section-menu-options";
|
||||
|
||||
const DEFAULT_SECTION_MENU_OPTIONS = ["MoveUp", "MoveDown", "Separator", "RemoveSection", "CheckCollapsed", "Separator", "ManageSection"];
|
||||
const WEBEXT_SECTION_MENU_OPTIONS = ["MoveUp", "MoveDown", "Separator", "CheckCollapsed", "Separator", "ManageWebExtension"];
|
||||
|
||||
export class _SectionMenu extends React.PureComponent {
|
||||
getOptions() {
|
||||
const {props} = this;
|
||||
|
||||
const propOptions = Array.from(DEFAULT_SECTION_MENU_OPTIONS);
|
||||
const propOptions = props.isWebExtension ? [...WEBEXT_SECTION_MENU_OPTIONS] : [...DEFAULT_SECTION_MENU_OPTIONS];
|
||||
// Prepend custom options and a separator
|
||||
if (props.extraOptions) {
|
||||
propOptions.splice(0, 0, ...props.extraOptions, "Separator");
|
||||
|
|
|
@ -154,7 +154,8 @@ export class Section extends React.PureComponent {
|
|||
Prefs={this.props.Prefs}
|
||||
isFirst={isFirst}
|
||||
isLast={isLast}
|
||||
dispatch={this.props.dispatch}>
|
||||
dispatch={this.props.dispatch}
|
||||
isWebExtension={this.props.isWebExtension}>
|
||||
|
||||
{!shouldShowEmptyState && (<ul className="section-list" style={{padding: 0}}>
|
||||
{realRows.map((link, index) => link &&
|
||||
|
|
|
@ -50,6 +50,11 @@ export const SectionMenuOptions = {
|
|||
action: ac.OnlyToMain({type: at.SETTINGS_OPEN}),
|
||||
userEvent: "MENU_MANAGE"
|
||||
}),
|
||||
ManageWebExtension: section => ({
|
||||
id: "section_menu_action_manage_webext",
|
||||
icon: "settings",
|
||||
action: ac.OnlyToMain({type: at.OPEN_WEBEXT_SETTINGS, data: section.id})
|
||||
}),
|
||||
AddTopSite: section => ({
|
||||
id: "section_menu_action_add_topsite",
|
||||
icon: "add",
|
||||
|
|
|
@ -85,6 +85,10 @@ this.AboutPreferences = class AboutPreferences {
|
|||
case at.SETTINGS_OPEN:
|
||||
action._target.browser.ownerGlobal.openPreferences("paneHome", {origin: "aboutHome"});
|
||||
break;
|
||||
// This is used to open the web extension settings page for an extension
|
||||
case at.OPEN_WEBEXT_SETTINGS:
|
||||
action._target.browser.ownerGlobal.BrowserOpenAddonsMgr(`addons://detail/${encodeURIComponent(action.data)}`);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -63,6 +63,18 @@ describe("<SectionMenu>", () => {
|
|||
assert.propertyVal(options[i++], "id", "section_menu_action_manage_section");
|
||||
assert.propertyVal(options, "length", i);
|
||||
});
|
||||
it("should show the correct default options for a web extension", () => {
|
||||
wrapper = shallowWithIntl(<SectionMenu {...DEFAULT_PROPS} isWebExtension={true} />);
|
||||
const {options} = wrapper.find(ContextMenu).props();
|
||||
let i = 0;
|
||||
assert.propertyVal(options[i++], "id", "section_menu_action_move_up");
|
||||
assert.propertyVal(options[i++], "id", "section_menu_action_move_down");
|
||||
assert.propertyVal(options[i++], "type", "separator");
|
||||
assert.propertyVal(options[i++], "id", "section_menu_action_collapse_section");
|
||||
assert.propertyVal(options[i++], "type", "separator");
|
||||
assert.propertyVal(options[i++], "id", "section_menu_action_manage_webext");
|
||||
assert.propertyVal(options, "length", i);
|
||||
});
|
||||
it("should show Collapse option for an expanded section if CheckCollapsed in options list", () => {
|
||||
wrapper = shallowWithIntl(<SectionMenu {...DEFAULT_PROPS} collapsed={false} />);
|
||||
const {options} = wrapper.find(ContextMenu).props();
|
||||
|
|
|
@ -40,6 +40,14 @@ describe("AboutPreferences Feed", () => {
|
|||
instance.onAction(action);
|
||||
assert.calledOnce(action._target.browser.ownerGlobal.openPreferences);
|
||||
});
|
||||
it("should call .BrowserOpenAddonsMgr with the extension id on OPEN_WEBEXT_SETTINGS", () => {
|
||||
const action = {type: at.OPEN_WEBEXT_SETTINGS, data: "foo", _target: {browser: {ownerGlobal: {BrowserOpenAddonsMgr: sinon.spy()}}}};
|
||||
instance.onAction(action);
|
||||
assert.calledWith(
|
||||
action._target.browser.ownerGlobal.BrowserOpenAddonsMgr,
|
||||
"addons://detail/foo"
|
||||
);
|
||||
});
|
||||
});
|
||||
describe("#observe", () => {
|
||||
it("should watch for about:preferences loading", () => {
|
||||
|
|
Загрузка…
Ссылка в новой задаче