Commit 186ae3d5 authored by Austin Tankiang's avatar Austin Tankiang Committed by Commit Bot

Hide Available Offline menu item in gear menu

There is an Available Offline toggle already on the toolbar, so this
menu item is superfluous.

Bug: 1145058
Change-Id: Ifa48b9e6c40d49be181f48b30c308cc0fbf1d329
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2526873
Commit-Queue: Austin Tankiang <austinct@chromium.org>
Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Cr-Commit-Position: refs/heads/master@{#826663}
parent 1e30c067
...@@ -92,6 +92,7 @@ class ActionsSubmenu { ...@@ -92,6 +92,7 @@ class ActionsSubmenu {
if (saveForOfflineAction || offlineNotNecessaryAction) { if (saveForOfflineAction || offlineNotNecessaryAction) {
const menuItem = this.addMenuItem_({}); const menuItem = this.addMenuItem_({});
menuItem.command = '#toggle-pinned'; menuItem.command = '#toggle-pinned';
menuItem.classList.toggle('hide-on-toolbar', true);
if (saveForOfflineAction) { if (saveForOfflineAction) {
delete remainingActions[ActionsModel.CommonActionId.SAVE_FOR_OFFLINE]; delete remainingActions[ActionsModel.CommonActionId.SAVE_FOR_OFFLINE];
} }
...@@ -103,9 +104,14 @@ class ActionsSubmenu { ...@@ -103,9 +104,14 @@ class ActionsSubmenu {
util.queryDecoratedElement('#toggle-pinned', cr.ui.Command) util.queryDecoratedElement('#toggle-pinned', cr.ui.Command)
.canExecuteChange(element); .canExecuteChange(element);
let hasCustomActions = false;
// Process all the rest as custom actions. // Process all the rest as custom actions.
Object.keys(remainingActions).forEach(key => { Object.keys(remainingActions).forEach(key => {
// Certain actions (e.g. 'pin-folder' to Directory tree) do not seem to
// have a title, and thus don't appear in the menu even though we add it
// to the DOM.
const action = remainingActions[key]; const action = remainingActions[key];
hasCustomActions = hasCustomActions || !!action.getTitle();
const options = {label: action.getTitle()}; const options = {label: action.getTitle()};
const menuItem = this.addMenuItem_(options); const menuItem = this.addMenuItem_(options);
...@@ -114,6 +120,10 @@ class ActionsSubmenu { ...@@ -114,6 +120,10 @@ class ActionsSubmenu {
}); });
}); });
// All actions that are not custom actions are hide-on-toolbar, so
// set hide-on-toolbar for the separator if there are no custom actions.
this.separator_.classList.toggle('hide-on-toolbar', !hasCustomActions);
this.separator_.hidden = !this.items_.length; this.separator_.hidden = !this.items_.length;
} }
} }
...@@ -519,8 +519,8 @@ testcase.driveBackupPhotos = async () => { ...@@ -519,8 +519,8 @@ testcase.driveBackupPhotos = async () => {
}; };
/** /**
* Verify that "Available Offline" is available from the gear menu for a drive * Verify that "Available Offline" is not available from the gear menu for a
* file before the context menu has been opened. * drive file.
*/ */
testcase.driveAvailableOfflineGearMenu = async () => { testcase.driveAvailableOfflineGearMenu = async () => {
const pinnedMenuQuery = '#file-context-menu:not([hidden]) ' + const pinnedMenuQuery = '#file-context-menu:not([hidden]) ' +
...@@ -545,17 +545,20 @@ testcase.driveAvailableOfflineGearMenu = async () => { ...@@ -545,17 +545,20 @@ testcase.driveAvailableOfflineGearMenu = async () => {
// Ensure gear button is available // Ensure gear button is available
await remoteCall.waitForElement(appId, '#selection-menu-button'); await remoteCall.waitForElement(appId, '#selection-menu-button');
// Click on gear menu and ensure "Available Offline" is shown. // Click on gear menu and ensure "Available Offline" is not shown.
chrome.test.assertTrue(await remoteCall.callRemoteTestUtil( chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
'fakeMouseClick', appId, ['#selection-menu-button'])); 'fakeMouseClick', appId, ['#selection-menu-button']));
// Check that "Available Offline" is shown in the menu. // Check that "Available Offline" is not shown in the menu. This element is
await remoteCall.waitForElement(appId, pinnedMenuQuery); // hidden via a display:none css rule, so check that.
const e = await remoteCall.waitForElementStyles(
appId, pinnedMenuQuery, ['display']);
chrome.test.assertEq('none', e.styles.display);
}; };
/** /**
* Verify that "Available Offline" is available from the gear menu for a drive * Verify that "Available Offline" is not available from the gear menu for a
* directory before the context menu has been opened. * drive directory.
*/ */
testcase.driveAvailableOfflineDirectoryGearMenu = async () => { testcase.driveAvailableOfflineDirectoryGearMenu = async () => {
const pinnedMenuQuery = '#file-context-menu:not([hidden]) ' + const pinnedMenuQuery = '#file-context-menu:not([hidden]) ' +
...@@ -580,12 +583,15 @@ testcase.driveAvailableOfflineDirectoryGearMenu = async () => { ...@@ -580,12 +583,15 @@ testcase.driveAvailableOfflineDirectoryGearMenu = async () => {
// Ensure gear button is available // Ensure gear button is available
await remoteCall.waitForElement(appId, '#selection-menu-button'); await remoteCall.waitForElement(appId, '#selection-menu-button');
// Click on gear menu and ensure "Available Offline" is shown. // Click on gear menu and ensure "Available Offline" is not shown.
chrome.test.assertTrue(await remoteCall.callRemoteTestUtil( chrome.test.assertTrue(await remoteCall.callRemoteTestUtil(
'fakeMouseClick', appId, ['#selection-menu-button'])); 'fakeMouseClick', appId, ['#selection-menu-button']));
// Check that "Available Offline" is shown in the menu. // Check that "Available Offline" is not shown in the menu. This element is
await remoteCall.waitForElement(appId, pinnedMenuQuery); // hidden via a display:none css rule, so check that.
const e = await remoteCall.waitForElementStyles(
appId, pinnedMenuQuery, ['display']);
chrome.test.assertEq('none', e.styles.display);
}; };
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment