Commit f05028cd authored by Jeevan Shikaram's avatar Jeevan Shikaram Committed by Commit Bot

[App Management] Add uninstall button to app permission view.

This CL adds an uninstall button that allows a user to uninstall apps
from App Management.

Bug: 999431, 979531
Change-Id: Ib2e88f5e7bb7f0fac09067a38bfd139a7adf168c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1777465Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Commit-Queue: Jeevan Shikaram <jshikaram@chromium.org>
Auto-Submit: Jeevan Shikaram <jshikaram@chromium.org>
Cr-Commit-Position: refs/heads/master@{#692203}
parent 63c2945a
...@@ -20,7 +20,6 @@ js_type_check("closure_compile") { ...@@ -20,7 +20,6 @@ js_type_check("closure_compile") {
":main_view", ":main_view",
":permission_item", ":permission_item",
":permission_toggle", ":permission_toggle",
":permission_view_header",
":pin_to_shelf_item", ":pin_to_shelf_item",
":pwa_permission_view", ":pwa_permission_view",
":reducers", ":reducers",
...@@ -29,6 +28,7 @@ js_type_check("closure_compile") { ...@@ -29,6 +28,7 @@ js_type_check("closure_compile") {
":store_client", ":store_client",
":toggle_row", ":toggle_row",
":types", ":types",
":uninstall_button",
":util", ":util",
] ]
} }
...@@ -83,7 +83,6 @@ js_library("arc_permission_view") { ...@@ -83,7 +83,6 @@ js_library("arc_permission_view") {
":constants", ":constants",
":fake_page_handler", ":fake_page_handler",
":permission_item", ":permission_item",
":permission_view_header",
":pin_to_shelf_item", ":pin_to_shelf_item",
":store_client", ":store_client",
] ]
...@@ -146,13 +145,6 @@ js_library("permission_toggle") { ...@@ -146,13 +145,6 @@ js_library("permission_toggle") {
] ]
} }
js_library("permission_view_header") {
deps = [
":browser_proxy",
":store_client",
]
}
js_library("pin_to_shelf_item") { js_library("pin_to_shelf_item") {
deps = [ deps = [
":browser_proxy", ":browser_proxy",
...@@ -219,6 +211,14 @@ js_library("types") { ...@@ -219,6 +211,14 @@ js_library("types") {
] ]
} }
js_library("uninstall_button") {
deps = [
":store_client",
":util",
"//ui/webui/resources/js:cr",
]
}
js_library("util") { js_library("util") {
deps = [ deps = [
":constants", ":constants",
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
<link rel="import" href="browser_proxy.html"> <link rel="import" href="browser_proxy.html">
<link rel="import" href="icons.html"> <link rel="import" href="icons.html">
<link rel="import" href="permission_item.html"> <link rel="import" href="permission_item.html">
<link rel="import" href="permission_view_header.html">
<link rel="import" href="shared_style.html"> <link rel="import" href="shared_style.html">
<link rel="import" href="store_client.html"> <link rel="import" href="store_client.html">
<link rel="import" href="pin_to_shelf_item.html"> <link rel="import" href="pin_to_shelf_item.html">
......
...@@ -2,38 +2,11 @@ ...@@ -2,38 +2,11 @@
<link rel="import" href="shared_style.html"> <link rel="import" href="shared_style.html">
<link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html"> <link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html">
<link rel="import" href="chrome://resources/cr_elements/cr_icon_button/cr_icon_button.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html"> <link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html">
<dom-module id="app-management-permission-view-header"> <dom-module id="app-management-uninstall-button">
<template> <template>
<style include="app-management-shared-css"> <style include="app-management-shared-css">
:host {
align-items: center;
display: flex;
margin: 24px auto;
max-width: var(--card-max-width);
min-width: var(--card-min-width);
}
#permission-view-header-icon {
height: 26px;
margin-inline-end: 8px;
margin-inline-start: 24px;
width: 26px;
}
#app-title {
flex: 1;
font-size: 16px;
overflow: hidden;
text-overflow: ellipsis;
}
cr-icon-button {
margin: 0;
}
#uninstall-button { #uninstall-button {
background: white; background: white;
} }
...@@ -43,20 +16,17 @@ ...@@ -43,20 +16,17 @@
margin-inline-end: 12px; margin-inline-end: 12px;
} }
</style> </style>
<cr-icon-button class="icon-arrow-back" id="backButton" <!-- TODO(crbug.com/999632): rename polymer element IDs to camel case. -->
on-click="onClickBackButton_" aria-label="$i18n{back}"></cr-icon-button>
<img id="permission-view-header-icon" src="[[iconUrlFromId_(app_)]]">
<div class="page-title">[[app_.title]]</div>
<div id="uninstall-wrapper" title$="[[getUninstallButtonHoverText_(app_)]]"> <div id="uninstall-wrapper" title$="[[getUninstallButtonHoverText_(app_)]]">
<template is="dom-if" if="[[isPolicyApp_(app_)]]"> <template is="dom-if" if="[[isPolicyApp_(app_)]]">
<iron-icon id="policy-indicator" icon="cr:domain"></iron-icon> <iron-icon id="policy-indicator" icon="cr:domain"></iron-icon>
</template> </template>
<cr-button id="uninstall-button" on-click="onClickUninstallButton_" <cr-button id="uninstall-button" on-click="onClickUninstallButton_"
disabled$="[[getUninstallButtonDisableState_(app_)]]"> disabled$="[[getUninstallButtonDisableState_(app_)]]">
<!-- TODO(crbug.com/999636) rename uninstall to uninstallApp.-->
$i18n{uninstall} $i18n{uninstall}
</cr-button> </cr-button>
</div> </div>
</template> </template>
<script src="permission_view_header.js"></script> <script src="uninstall_button.js"></script>
</dom-module> </dom-module>
// Copyright 2018 The Chromium Authors. All rights reserved. // Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
Polymer({ Polymer({
is: 'app-management-permission-view-header', is: 'app-management-uninstall-button',
behaviors: [ behaviors: [
app_management.StoreClient, app_management.StoreClient,
], ],
properties: { properties: {
/** @type {App} */ /**
app_: { * @private {App}
type: Object, */
}, app_: Object,
}, },
attached: function() { attached: function() {
...@@ -21,12 +22,11 @@ Polymer({ ...@@ -21,12 +22,11 @@ Polymer({
}, },
/** /**
*
* Returns True if the uninstall button should be disabled due to app install * Returns True if the uninstall button should be disabled due to app install
* type. * type.
* *
* @param {App} app * @param {App} app
* @return {boolean} * @return {?boolean}
* @private * @private
*/ */
getUninstallButtonDisableState_: function(app) { getUninstallButtonDisableState_: function(app) {
...@@ -49,11 +49,11 @@ Polymer({ ...@@ -49,11 +49,11 @@ Polymer({
* Returns string to be shown as a tool tip over the uninstall button. * Returns string to be shown as a tool tip over the uninstall button.
* *
* @param {App} app * @param {App} app
* @return {string} * @return {?string}
* @private * @private
*/ */
getUninstallButtonHoverText_: function(app) { getUninstallButtonHoverText_: function(app) {
// TODO(crbug.com/957795) Replace strings and add them into i18n. // TODO(crbug.com/957795): Replace strings and add them into i18n.
switch (app.installSource) { switch (app.installSource) {
case InstallSource.kSystem: case InstallSource.kSystem:
return app.title + ' cannot be uninstalled as it is part of Chrome OS.'; return app.title + ' cannot be uninstalled as it is part of Chrome OS.';
...@@ -75,33 +75,13 @@ Polymer({ ...@@ -75,33 +75,13 @@ Polymer({
* Returns true if the app was installed by a policy * Returns true if the app was installed by a policy
* *
* @param {App} app * @param {App} app
* @returns {boolean} * @returns {?boolean}
* @private * @private
*/ */
isPolicyApp_: function(app) { isPolicyApp_: function(app) {
return app.installSource === InstallSource.kPolicy; return app.installSource === InstallSource.kPolicy;
}, },
/**
* @param {App} app
* @return {string}
* @private
*/
iconUrlFromId_: function(app) {
return app_management.util.getAppIcon(app);
},
/**
* @private
*/
onClickBackButton_: function() {
if (!window.history.state) {
this.dispatch(app_management.actions.changePage(PageType.MAIN));
} else {
window.history.back();
}
},
/** /**
* @private * @private
*/ */
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
<link rel="import" href="chrome://resources/cr_elements/cr_link_row/cr_link_row.html"> <link rel="import" href="chrome://resources/cr_elements/cr_link_row/cr_link_row.html">
<link rel="import" href="app_management_page/app_management_page.html"> <link rel="import" href="app_management_page/app_management_page.html">
<link rel="import" href="app_management_page/app_permission_view.html"> <link rel="import" href="app_management_page/app_permission_view.html">
<link rel="import" href="app_management_page/uninstall_button.html">
<link rel="import" href="../../route.html"> <link rel="import" href="../../route.html">
<link rel="import" href="../../settings_shared_css.html"> <link rel="import" href="../../settings_shared_css.html">
...@@ -29,6 +30,8 @@ ...@@ -29,6 +30,8 @@
<settings-subpage <settings-subpage
page-title="[[app_.title]]" page-title="[[app_.title]]"
title-icon="[[iconUrlFromId_(app_)]]"> title-icon="[[iconUrlFromId_(app_)]]">
<app-management-uninstall-button slot="subpage-title-extra">
</app-management-uninstall-button>
<app-management-app-permission-view> <app-management-app-permission-view>
</app-management-app-permission-view> </app-management-app-permission-view>
</settings-subpage> </settings-subpage>
......
...@@ -127,12 +127,6 @@ ...@@ -127,12 +127,6 @@
<structure name="IDR_OS_SETTINGS_APP_MANAGEMENT_PAGE_PERMISSION_TOGGLE_HTML" <structure name="IDR_OS_SETTINGS_APP_MANAGEMENT_PAGE_PERMISSION_TOGGLE_HTML"
file="chromeos/os_apps_page/app_management_page/permission_toggle.html" file="chromeos/os_apps_page/app_management_page/permission_toggle.html"
type="chrome_html" /> type="chrome_html" />
<structure name="IDR_OS_SETTINGS_APP_MANAGEMENT_PAGE_PERMISSION_VIEW_HEADER_JS"
file="chromeos/os_apps_page/app_management_page/permission_view_header.js"
type="chrome_html" />
<structure name="IDR_OS_SETTINGS_APP_MANAGEMENT_PAGE_PERMISSION_VIEW_HEADER_HTML"
file="chromeos/os_apps_page/app_management_page/permission_view_header.html"
type="chrome_html" />
<structure name="IDR_OS_SETTINGS_APP_MANAGEMENT_PAGE_PIN_TO_SHELF_ITEM_JS" <structure name="IDR_OS_SETTINGS_APP_MANAGEMENT_PAGE_PIN_TO_SHELF_ITEM_JS"
file="chromeos/os_apps_page/app_management_page/pin_to_shelf_item.js" file="chromeos/os_apps_page/app_management_page/pin_to_shelf_item.js"
type="chrome_html" /> type="chrome_html" />
...@@ -172,6 +166,12 @@ ...@@ -172,6 +166,12 @@
<structure name="IDR_OS_SETTINGS_APP_MANAGEMENT_PAGE_ICONS_HTML" <structure name="IDR_OS_SETTINGS_APP_MANAGEMENT_PAGE_ICONS_HTML"
file="chromeos/os_apps_page/app_management_page/icons.html" file="chromeos/os_apps_page/app_management_page/icons.html"
type="chrome_html" /> type="chrome_html" />
<structure name="IDR_OS_SETTINGS_APP_MANAGEMENT_PAGE_UNINSTALL_BUTTON_JS"
file="chromeos/os_apps_page/app_management_page/uninstall_button.js"
type="chrome_html" />
<structure name="IDR_OS_SETTINGS_APP_MANAGEMENT_PAGE_APP_UNINSTALL_BUTTON_HTML"
file="chromeos/os_apps_page/app_management_page/uninstall_button.html"
type="chrome_html" />
<structure name="IDR_OS_SETTINGS_MANAGE_A11Y_PAGE_JS" <structure name="IDR_OS_SETTINGS_MANAGE_A11Y_PAGE_JS"
file="a11y_page/manage_a11y_page.js" file="a11y_page/manage_a11y_page.js"
type="chrome_html" /> type="chrome_html" />
......
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