summaryrefslogtreecommitdiff
path: root/chromium/ui/webui/resources/cr_components/chromeos/cellular_setup/cellular_setup.js
blob: e2c7b944ddae888185aa7caf7a312c38c939fffd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

/**
 * @fileoverview Root element for the cellular setup flow. This element wraps
 * the psim setup flow, esim setup flow, and setup flow selection page.
 */
Polymer({
  is: 'cellular-setup',

  behaviors: [I18nBehavior],

  properties: {
    /** @type {!cellular_setup.CellularSetupDelegate} */
    delegate: Object,

    /**
     * Title of the flow, shown at the top of the dialog. No title shown if the
     * string is empty.
     */
    flowTitle: {
      type: String,
      notify: true,
      value: '',
    },

    /**
     * Header for the flow, shown below the title. No header shown if the string
     * is empty.
     */
    flowHeader: {
      type: String,
      notify: true,
      value: '',
    },

    /**
     * Name of the currently displayed sub-page.
     * @private {!cellularSetup.CellularSetupPageName|null}
     */
    currentPageName: String,

    /**
     * Current user selected setup flow page name.
     * @private {!cellularSetup.CellularSetupPageName|null}
     */
    selectedFlow_: {
      type: String,
      value: null,
    },

    /**
     * Button bar button state.
     * @private {!cellularSetup.ButtonBarState}
     */
    buttonState_: {
      type: Object,
      notify: true,
    },

    /**
     * DOM Element corresponding to the visible page.
     *
     * @private {!PsimFlowUiElement|!EsimFlowUiElement}
     */
    currentPage_: {
      type: Object,
      observer: 'onPageChange_',
    },

    /**
     * Text for the button_bar's 'Forward' button.
     * @private {string}
     */
    forwardButtonLabel_: {
      type: String,
    }
  },

  listeners: {
    'backward-nav-requested': 'onBackwardNavRequested_',
    'retry-requested': 'onRetryRequested_',
    'forward-nav-requested': 'onForwardNavRequested_',
    'cancel-requested': 'onCancelRequested_',
    'focus-default-button': 'onFocusDefaultButton_',
  },


  /** @override */
  attached() {
    // By default eSIM flow is selected.
    if (!this.currentPageName) {
      this.currentPageName = cellularSetup.CellularSetupPageName.ESIM_FLOW_UI;
    }
  },

  /** @private */
  onPageChange_() {
    if (this.currentPage_) {
      this.flowTitle = '';
      this.currentPage_.initSubflow();
    }
  },

  /** @private */
  onBackwardNavRequested_() {
    this.currentPage_.navigateBackward();
  },

  onCancelRequested_() {
    this.fire('exit-cellular-setup');
  },

  /** @private */
  onRetryRequested_() {
    // TODO(crbug.com/1093185): Add try again logic.
  },

  /** @private */
  onForwardNavRequested_() {
    this.currentPage_.navigateForward();
  },

  /** @private */
  onFocusDefaultButton_() {
    this.$.buttonBar.focusDefaultButton();
  },

  /**
   * @param {string} currentPage
   * @private
   */
  shouldShowPsimFlow_(currentPage) {
    return currentPage === cellularSetup.CellularSetupPageName.PSIM_FLOW_UI;
  },

  /**
   * @param {string} currentPage
   * @private
   */
  shouldShowEsimFlow_(currentPage) {
    return currentPage === cellularSetup.CellularSetupPageName.ESIM_FLOW_UI;
  }
});