Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Side by Side Diff: chrome/browser/resources/md_user_manager/import_supervised_user.js

Issue 1901853002: Import supervised user dialog (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@md-user-manager-confirmation-page
Patch Set: Addressed comments + rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 /**
6 * @fileoverview 'import-supervised-user' is a popup that allows user to select
7 * a supervised profile from a list of profiles to import on the current device.
8 */
9 (function() {
10 /**
11 * It means no supervised user is selected.
12 * @const {number}
13 */
14 var NO_USER_SELECTED = -1;
15
16 Polymer({
17 is: 'import-supervised-user',
18
19 behaviors: [
20 I18nBehavior,
21 ],
22
23 properties: {
24 /**
25 * True if the element is currently hidden. The element toggles this in
26 * order to display itself or hide itself once done.
27 * @private {boolean}
28 */
29 popupHidden_: {
30 type: Boolean,
31 value: true
32 },
33
34 /**
35 * The currently signed in user and the custodian.
36 * @private {?SignedInUser}
37 */
38 signedInUser_: {
39 type: Object,
40 value: function() { return null; }
41 },
42
43 /**
44 * The list of supervised users managed by signedInUser_.
45 * @private {!Array<!SupervisedUser>}
46 */
47 supervisedUsers_: {
48 type: Array,
49 value: function() { return []; }
50 },
51
52 /**
53 * Index of the selected supervised user.
54 * @private {number}
55 */
56 supervisedUserIndex_: {
57 type: Number,
58 value: NO_USER_SELECTED
59 }
60 },
61
62 /**
63 * Displays the popup.
64 * @param {(!SignedInUser|undefined)} signedInUser
65 * @param {!Array<!SupervisedUser>} supervisedUsers
66 */
67 show: function(signedInUser, supervisedUsers) {
68 this.supervisedUsers_ = supervisedUsers;
69 this.supervisedUsers_.sort(function(a, b) {
70 if (a.onCurrentDevice != b.onCurrentDevice)
71 return a.onCurrentDevice ? 1 : -1;
72 return a.name.localeCompare(b.name);
73 });
74
75 this.supervisedUserIndex_ = NO_USER_SELECTED;
76
77 this.signedInUser_ = signedInUser || null;
78 if (this.signedInUser_)
79 this.popupHidden_ = false;
80 },
81
82 /**
83 * Computed binding that returns the appropriate import message depending on
84 * whether or not there are any supervised users to import.
85 * @param {!Array<!SupervisedUser>} supervisedUsers
86 * @private
87 * @return {string}
88 */
89 getMessage_: function(supervisedUsers) {
90 return supervisedUsers.length > 0 ? this.i18n('supervisedUserImportText') :
91 this.i18n('noSupervisedUserImportText');
92 },
93
94 /**
95 * Computed binding that returns the appropriate class names for the HTML
96 * container of |supervisedUser| depending on whether it is on this device.
97 * @param {!SupervisedUser} supervisedUser
98 * @private
99 * @return {string}
100 */
101 getUserClassNames_: function(supervisedUser) {
102 var classNames = 'list-item';
103 if (!supervisedUser.onCurrentDevice)
104 classNames += ' selectable';
105 return classNames;
106 },
107
108 /**
109 * Hides the popup.
110 * @private
111 */
112 onCancelTap_: function() {
113 this.popupHidden_ = true;
114 },
115
116 /**
117 * Returns true if the 'Import' button should be enabled and false otherwise.
118 * @private
119 * @return {boolean}
120 */
121 isImportDisabled_: function(supervisedUserIndex) {
122 return supervisedUserIndex == NO_USER_SELECTED;
123 },
124
125 /**
126 * Called when the user clicks the 'Import' button. it proceeds with importing
127 * the supervised user.
128 * @private
129 */
130 onImportTap_: function() {
131 var supervisedUser = this.supervisedUsers_[this.supervisedUserIndex_];
132 if (this.signedInUser_ && supervisedUser) {
133 // Event is caught by create-profile.
134 this.fire('import', {supervisedUser: supervisedUser,
135 signedInUser: this.signedInUser_});
136 this.popupHidden_ = true;
137 }
138 }
139 });
140 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698