Commit c74530e0 authored by Luciano Pacheco's avatar Luciano Pacheco Committed by Commit Bot

Remove directory tree menu item

This is dead code, since "Add service" migrated to "gear menu"
crrev.com/c/1139944.

Remove:
1. ADD_NEW_SERVICES_MENU constant from VolumeManagerCommon.RootType.
2. Style and icons specific for displaying "Add service" in the
directory tree.
3. Icons that was used for "Add service" in directory tree.
4. NavigationModelMenuItem and MenuItem types.

NOTE: Translation strings are still in use in the gear menu so we won't
remove them.

Bug: 869252
Change-Id: Ic6c0abf74dff6cf2ebf2821b88d930dcd1653bbf
Reviewed-on: https://chromium-review.googlesource.com/c/1260882Reviewed-by: default avatarJoel Hockey <joelhockey@chromium.org>
Commit-Queue: Luciano Pacheco <lucmult@chromium.org>
Cr-Commit-Position: refs/heads/master@{#596950}
parent bc6c28fc
......@@ -99,9 +99,6 @@ VolumeManagerCommon.RootType = {
// 'Offline'.
DRIVE_FAKE_ROOT: 'drive_fake_root',
// 'Add new services' menu item.
ADD_NEW_SERVICES_MENU: 'add_new_services_menu',
// Root for crostini 'Linux files'.
CROSTINI: 'crostini',
......@@ -144,7 +141,6 @@ VolumeManagerCommon.RootTypesForUMA = [
VolumeManagerCommon.RootType.MEDIA_VIEW,
VolumeManagerCommon.RootType.RECENT,
VolumeManagerCommon.RootType.DRIVE_FAKE_ROOT,
VolumeManagerCommon.RootType.ADD_NEW_SERVICES_MENU,
VolumeManagerCommon.RootType.CROSTINI,
VolumeManagerCommon.RootType.ANDROID_FILES,
VolumeManagerCommon.RootType.MY_FILES,
......
......@@ -442,12 +442,6 @@ cr-menu-item[command='#install-new-extension'] .icon.start {
url(../images/files/ui/2x/store.png) 2x);
}
.tree-row [menu-button-icon='add-new-services'] {
background-image: -webkit-image-set(
url(../images/volumes/add.png) 1x,
url(../images/volumes/2x/add.png) 2x);
}
[root-type-icon='recent'] {
background-image: -webkit-image-set(
url(../images/volumes/recent.png) 1x,
......
......@@ -1210,7 +1210,6 @@ FileManager.prototype = /** @struct */ {
VolumeManagerCommon.RootType.RECENT, true,
this.getSourceRestriction_())) :
null,
null, // TODO(crbug.com/869252) remove this null.
this.commandLineFlags_['disable-my-files-navigation']);
this.setupCrostini_();
this.ui_.initDirectoryTree(directoryTree);
......
......@@ -8,7 +8,6 @@
var NavigationModelItemType = {
SHORTCUT: 'shortcut',
VOLUME: 'volume',
MENU: 'menu',
RECENT: 'recent',
CROSTINI: 'crostini',
ENTRY_LIST: 'entry-list',
......@@ -119,45 +118,6 @@ NavigationModelVolumeItem.prototype = /** @struct */ {
get volumeInfo() { return this.volumeInfo_; }
};
/**
* Item of NavigationListModel for a menu button.
*
* @param {string} label Label on the menu button.
* @param {string} menu Selector for the menu element.
* @param {string} icon Name of an icon on the menu button.
* @constructor
* @extends {NavigationModelItem}
* @struct
*/
function NavigationModelMenuItem(label, menu, icon) {
NavigationModelItem.call(this, label, NavigationModelItemType.MENU);
/**
* @private {string}
* @const
*/
this.menu_ = menu;
/**
* @private {string}
* @const
*/
this.icon_ = icon;
}
NavigationModelMenuItem.prototype = /** @struct */ {
__proto__: NavigationModelItem.prototype,
/**
* @return {string}
*/
get menu() { return this.menu_; },
/**
* @return {string}
*/
get icon() { return this.icon_; }
};
/**
* Item of NavigationListModel for a fake item such as Recent or Linux files.
*
......@@ -186,7 +146,6 @@ NavigationModelFakeItem.prototype = /** @struct */ {
* @param {(!cr.ui.ArrayDataModel|!FolderShortcutsDataModel)} shortcutListModel
* The list of folder shortcut.
* @param {NavigationModelFakeItem} recentModelItem Recent folder.
* @param {NavigationModelMenuItem} addNewServicesItem Add new services item.
* @param {boolean=} opt_disableMyFilesNavigation true if should use the new
* navigation style, value should come from flag
* disable-my-files-navigation.
......@@ -194,7 +153,7 @@ NavigationModelFakeItem.prototype = /** @struct */ {
* @extends {cr.EventTarget}
*/
function NavigationListModel(
volumeManager, shortcutListModel, recentModelItem, addNewServicesItem,
volumeManager, shortcutListModel, recentModelItem,
opt_disableMyFilesNavigation) {
cr.EventTarget.call(this);
......@@ -224,12 +183,6 @@ function NavigationListModel(
*/
this.linuxFilesItem_ = null;
/**
* @private {NavigationModelMenuItem}
* @const
*/
this.addNewServicesItem_ = addNewServicesItem;
/**
* NavigationModel for MyFiles, since DirectoryTree expect it to be always the
* same reference we keep the initial reference for reuse.
......
......@@ -42,23 +42,18 @@ function testModel() {
var recentItem = new NavigationModelFakeItem(
'recent-label', NavigationModelItemType.RECENT,
{toURL: () => 'fake-entry://recent'});
var addNewServicesItem = new NavigationModelMenuItem(
'menu-button-label', '#add-new-services', 'menu-button-icon');
var model = new NavigationListModel(
volumeManager, shortcutListModel, recentItem, addNewServicesItem, true);
volumeManager, shortcutListModel, recentItem, true);
model.linuxFilesItem = new NavigationModelFakeItem(
'linux-files-label', NavigationModelItemType.CROSTINI,
{toURL: () => 'fake-entry://linux-files'});
assertEquals(6, model.length);
assertEquals(5, model.length);
assertEquals('drive', model.item(0).volumeInfo.volumeId);
assertEquals('downloads', model.item(1).volumeInfo.volumeId);
assertEquals('fake-entry://recent', model.item(2).entry.toURL());
assertEquals('fake-entry://linux-files', model.item(3).entry.toURL());
assertEquals('/root/shortcut', model.item(4).entry.fullPath);
assertEquals('menu-button-label', model.item(5).label);
assertEquals('#add-new-services', model.item(5).menu);
assertEquals('menu-button-icon', model.item(5).icon);
}
function testNoRecentOrLinuxFiles() {
......@@ -66,18 +61,13 @@ function testNoRecentOrLinuxFiles() {
var shortcutListModel = new MockFolderShortcutDataModel(
[new MockFileEntry(drive, '/root/shortcut')]);
var recentItem = null;
var addNewServicesItem = new NavigationModelMenuItem(
'menu-button-label', '#add-new-services', 'menu-button-icon');
var model = new NavigationListModel(
volumeManager, shortcutListModel, recentItem, addNewServicesItem, true);
volumeManager, shortcutListModel, recentItem, true);
assertEquals(4, model.length);
assertEquals(3, model.length);
assertEquals('drive', model.item(0).volumeInfo.volumeId);
assertEquals('downloads', model.item(1).volumeInfo.volumeId);
assertEquals('/root/shortcut', model.item(2).entry.fullPath);
assertEquals('menu-button-label', model.item(3).label);
assertEquals('#add-new-services', model.item(3).menu);
assertEquals('menu-button-icon', model.item(3).icon);
}
function testAddAndRemoveShortcuts() {
......@@ -85,9 +75,8 @@ function testAddAndRemoveShortcuts() {
var shortcutListModel = new MockFolderShortcutDataModel(
[new MockFileEntry(drive, '/root/shortcut')]);
var recentItem = null;
var addNewServicesItem = null;
var model = new NavigationListModel(
volumeManager, shortcutListModel, recentItem, addNewServicesItem, true);
volumeManager, shortcutListModel, recentItem, true);
assertEquals(3, model.length);
......@@ -120,9 +109,8 @@ function testAddAndRemoveVolumes() {
var shortcutListModel = new MockFolderShortcutDataModel(
[new MockFileEntry(drive, '/root/shortcut')]);
var recentItem = null;
var addNewServicesItem = null;
var model = new NavigationListModel(
volumeManager, shortcutListModel, recentItem, addNewServicesItem, true);
volumeManager, shortcutListModel, recentItem, true);
assertEquals(3, model.length);
......@@ -172,7 +160,6 @@ function testOrderAndNestItems() {
const recentItem = new NavigationModelFakeItem(
'recent-label', NavigationModelItemType.RECENT,
{toURL: () => 'fake-entry://recent'});
const addNewServicesItem = null;
const zipVolumeId = 'provided:dmboannefpncccogfdikhmhpmdnddgoe:' +
'~%2FDownloads%2Fazip_file%2Ezip:' +
'096eaa592ea7e8ffb9a27435e50dabd6c809c125';
......@@ -225,7 +212,7 @@ function testOrderAndNestItems() {
// Constructor already calls orderAndNestItems_.
const model = new NavigationListModel(
volumeManager, shortcutListModel, recentItem, addNewServicesItem, false);
volumeManager, shortcutListModel, recentItem, false);
// Check items order and that MTP/Archive/Removable respect the original
// order.
......
......@@ -116,17 +116,6 @@ var TREE_ITEM_INNER_HTML =
'</div>' +
'<div class="tree-children"></div>';
var MENU_TREE_ITEM_INNER_HTML =
'<div class="tree-row">' +
' <paper-ripple fit class="recenteringTouch"></paper-ripple>' +
' <span class="expand-icon"></span>' +
' <div class="button">' +
' <span class="icon item-icon"></span>' +
' <span class="label entry-name"></span>' +
' </div>' +
'</div>' +
'<div class="tree-children"></div>';
////////////////////////////////////////////////////////////////////////////////
// DirectoryItem
......@@ -1338,95 +1327,6 @@ ShortcutItem.prototype.activate = function() {
}.bind(this));
};
////////////////////////////////////////////////////////////////////////////////
// MenuItem
/**
* A TreeItem which represents a command button.
* Command items are displayed as top-level children of DirectoryTree.
*
* @param {!NavigationModelMenuItem} modelItem
* @param {!DirectoryTree} tree Current tree, which contains this item.
* @extends {cr.ui.TreeItem}
* @constructor
*/
function MenuItem(modelItem, tree) {
var item = new cr.ui.TreeItem();
// Get the original label id defined by TreeItem, before overwriting
// prototype.
var labelId = item.labelElement.id;
item.__proto__ = MenuItem.prototype;
if (window.IN_TEST) {
item.setAttribute('dir-type', 'MenuItem');
item.setAttribute('entry-label', modelItem.label);
}
item.parentTree_ = tree;
item.modelItem_ = modelItem;
item.innerHTML = MENU_TREE_ITEM_INNER_HTML;
item.labelElement.id = labelId;
item.label = modelItem.label;
item.menuButton_ = /** @type {!cr.ui.MenuButton} */(queryRequiredElement(
'.button', assert(item.firstElementChild)));
item.menuButton_.setAttribute('menu', item.modelItem_.menu);
cr.ui.MenuButton.decorate(item.menuButton_);
var icon = queryRequiredElement('.icon', item);
icon.setAttribute('menu-button-icon', item.modelItem_.icon);
return item;
}
MenuItem.prototype = {
__proto__: cr.ui.TreeItem.prototype,
get entry() {
return null;
},
get modelItem() {
return this.modelItem_;
},
get labelElement() {
return this.firstElementChild.querySelector('.label');
}
};
/**
* @param {!DirectoryEntry|!FakeEntry} entry
* @return {boolean} True if the parent item is found.
*/
MenuItem.prototype.searchAndSelectByEntry = function(entry) {
return false;
};
/**
* @override
*/
MenuItem.prototype.handleClick = function(e) {
this.activate();
DirectoryItemTreeBaseMethods.recordUMASelectedEntry.call(
this, e, VolumeManagerCommon.RootType.ADD_NEW_SERVICES_MENU, true);
};
/**
* @param {!DirectoryEntry} entry
*/
MenuItem.prototype.selectByEntry = function(entry) {
};
/**
* Executes the command.
*/
MenuItem.prototype.activate = function() {
// Dispatch an event to update the menu (if updatable).
var updateEvent = /** @type {MenuItemUpdateEvent} */ (new Event('update'));
updateEvent.menuButton = this.menuButton_;
this.menuButton_.menu.dispatchEvent(updateEvent);
this.menuButton_.showMenu();
};
////////////////////////////////////////////////////////////////////////////////
// FakeItem
......@@ -1645,10 +1545,6 @@ DirectoryTree.createDirectoryItem = function(modelItem, tree) {
return new ShortcutItem(
/** @type {!NavigationModelShortcutItem} */ (modelItem), tree);
break;
case NavigationModelItemType.MENU:
return new MenuItem(
/** @type {!NavigationModelMenuItem} */ (modelItem), tree);
break;
case NavigationModelItemType.RECENT:
return new FakeItem(
VolumeManagerCommon.RootType.RECENT,
......
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