Commit 57c04cd6 authored by Alex Danilo's avatar Alex Danilo Committed by Chromium LUCI CQ

[progress center] Remove progress center groups

Progress center groups are not used, remove the code.

Move ProgressCenterItem array to progress_center_panel.js to replace
the equivalent from progress_center_item_group.js

Bug: 1027012
Change-Id: I7e9584aa8992ca0ece616bc7a046fb2da50f69a2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2568919
Commit-Queue: Alex Danilo <adanilo@chromium.org>
Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Cr-Commit-Position: refs/heads/master@{#832712}
parent 6a563da4
......@@ -221,10 +221,6 @@ IN_PROC_BROWSER_TEST_F(FileManagerJsTest, NavigationListModelTest) {
RunTestURL("foreground/js/navigation_list_model_unittest_gen.html");
}
IN_PROC_BROWSER_TEST_F(FileManagerJsTest, ProgressCenterItemGroupTest) {
RunTestURL("foreground/js/progress_center_item_group_unittest_gen.html");
}
IN_PROC_BROWSER_TEST_F(FileManagerJsTest, ProvidersModel) {
RunTestURL("foreground/js/providers_model_unittest_gen.html");
}
......
......@@ -71,7 +71,6 @@ js_type_check("closure_compile_module") {
":navigation_list_model",
":navigation_uma",
":path_component",
":progress_center_item_group",
":providers_model",
":quick_view_controller",
":quick_view_model",
......@@ -700,20 +699,6 @@ js_library("path_component") {
deps = [ "//ui/file_manager/base/js:volume_manager_types" ]
}
js_library("progress_center_item_group") {
deps = [
"//ui/file_manager/file_manager/common/js:progress_center_common",
"//ui/file_manager/file_manager/common/js:util",
]
}
js_unittest("progress_center_item_group_unittest") {
deps = [
":progress_center_item_group",
"//ui/file_manager/base/js:test_error_reporting",
]
}
js_library("providers_model") {
deps = [ "//ui/webui/resources/js:assert" ]
}
......@@ -914,7 +899,6 @@ js_test_gen_html("js_test_gen_html") {
":import_controller_unittest",
":list_thumbnail_loader_unittest",
":navigation_list_model_unittest",
":progress_center_item_group_unittest",
":providers_model_unittest",
":spinner_controller_unittest",
":task_controller_unittest",
......
......@@ -147,7 +147,6 @@
// <include src="navigation_list_model.js">
// <include src="navigation_uma.js">
// <include src="path_component.js">
// <include src="progress_center_item_group.js">
// <include src="quick_view_controller.js">
// <include src="quick_view_model.js">
// <include src="quick_view_uma.js">
......
......@@ -476,10 +476,7 @@ js_library("progress_center_panel") {
# The progress_center on the background page maintains a list of panels.
visibility += [ "//ui/file_manager/file_manager/background/*" ]
deps = [
"//ui/file_manager/file_manager/common/js:progress_center_common",
"//ui/file_manager/file_manager/foreground/js:progress_center_item_group",
]
deps = [ "//ui/file_manager/file_manager/common/js:progress_center_common" ]
externs_list = [ "//ui/file_manager/externs/progress_center_panel.js" ]
}
......
......@@ -15,18 +15,11 @@ class ProgressCenterPanel {
this.feedbackHost_ = document.querySelector('#progress-panel');
/**
* Item group for normal priority items.
* @type {ProgressCenterItemGroup}
* @private
* Items that are progressing, or completed.
* Key is item ID.
* @private {!Object<ProgressCenterItem>}
*/
this.normalItemGroup_ = new ProgressCenterItemGroup('normal', false);
/**
* Item group for low priority items.
* @type {ProgressCenterItemGroup}
* @private
*/
this.quietItemGroup_ = new ProgressCenterItemGroup('quiet', true);
this.items_ = {};
/**
* Callback to be called with the ID of the progress item when the cancel
......@@ -325,6 +318,7 @@ class ProgressCenterPanel {
if (item.type === 'copy' || item.type === 'move' ||
item.type === 'format') {
const donePanelItem = this.feedbackHost_.addPanelItem(item.id);
donePanelItem.id = item.id;
donePanelItem.panelType = donePanelItem.panelTypeDone;
donePanelItem.primaryText = primaryText;
if (util.isTransferDetailsEnabled()) {
......@@ -336,12 +330,14 @@ class ProgressCenterPanel {
donePanelItem.signalCallback = (signal) => {
if (signal === 'dismiss') {
this.feedbackHost_.removePanelItem(donePanelItem);
delete this.items_[donePanelItem.id];
}
};
// Delete after 4 seconds, doesn't matter if it's manually deleted
// before the timer fires, as removePanelItem handles that case.
setTimeout(() => {
this.feedbackHost_.removePanelItem(donePanelItem);
delete this.items_[donePanelItem.id];
}, 4000);
}
// Drop through to remove the progress panel.
......@@ -362,38 +358,59 @@ class ProgressCenterPanel {
}
}
/**
* Starts the item update and checks state changes.
* @param {!ProgressCenterItem} item Item containing updated information.
*/
updateItemState_(item) {
// Compares the current state and the new state to check if the update is
// valid or not.
const previousItem = this.items_[item.id];
switch (item.state) {
case ProgressItemState.ERROR:
if (previousItem &&
previousItem.state !== ProgressItemState.PROGRESSING) {
return;
}
this.items_[item.id] = item.clone();
break;
case ProgressItemState.PROGRESSING:
case ProgressItemState.COMPLETED:
if ((!previousItem && item.state === ProgressItemState.COMPLETED) ||
(previousItem &&
previousItem.state !== ProgressItemState.PROGRESSING)) {
return;
}
this.items_[item.id] = item.clone();
break;
case ProgressItemState.CANCELED:
if (!previousItem ||
previousItem.state !== ProgressItemState.PROGRESSING) {
return;
}
delete this.items_[item.id];
}
}
/**
* Updates an item to the progress center panel.
* @param {!ProgressCenterItem} item Item including new contents.
*/
updateItem(item) {
const targetGroup = this.getGroupForItem_(item);
// Update the item.
targetGroup.update(item);
this.updateItemState_(item);
// Update an open view item.
const newItem = targetGroup.getItem(item.id);
const newItem = this.items_[item.id] || null;
this.updateFeedbackPanelItem(item, newItem);
}
/**
* Requests all item groups to dismiss an error item.
* Called by background page when an error dialog is dismissed.
* @param {string} id Item id.
*/
dismissErrorItem(id) {
this.normalItemGroup_.dismissErrorItem(id);
this.quietItemGroup_.dismissErrorItem(id);
}
/**
* Obtains the group for the item.
* @param {ProgressCenterItem} item Progress item.
* @return {ProgressCenterItemGroup} Item group that should contain the item.
* @private
*/
getGroupForItem_(item) {
return item.quiet ? this.quietItemGroup_ : this.normalItemGroup_;
delete this.items_[id];
}
}
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