Adrià Vilanova Martínez | f19ea43 | 2024-01-23 20:20:52 +0100 | [diff] [blame] | 1 | // Copyright 2019 The Chromium Authors |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | import {LitElement, html, css} from 'lit-element'; |
| 6 | |
| 7 | import './mr-dropdown.js'; |
| 8 | |
| 9 | /** |
| 10 | * `<mr-account-dropdown>` |
| 11 | * |
| 12 | * Account dropdown menu for Monorail. |
| 13 | * |
| 14 | */ |
| 15 | export class MrAccountDropdown extends LitElement { |
| 16 | /** @override */ |
| 17 | static get styles() { |
| 18 | return css` |
| 19 | :host { |
| 20 | position: relative; |
| 21 | display: inline-block; |
| 22 | height: 100%; |
| 23 | font-size: inherit; |
| 24 | } |
| 25 | `; |
| 26 | } |
| 27 | |
| 28 | /** @override */ |
| 29 | render() { |
| 30 | return html` |
| 31 | <mr-dropdown |
| 32 | .text=${this.userDisplayName} |
| 33 | .items=${this.items} |
| 34 | .icon="arrow_drop_down" |
| 35 | ></mr-dropdown> |
| 36 | `; |
| 37 | } |
| 38 | |
| 39 | /** @override */ |
| 40 | static get properties() { |
| 41 | return { |
| 42 | userDisplayName: String, |
| 43 | logoutUrl: String, |
| 44 | loginUrl: String, |
| 45 | }; |
| 46 | } |
| 47 | |
| 48 | get items() { |
| 49 | return [ |
| 50 | {text: 'Switch accounts', url: this.loginUrl}, |
| 51 | {separator: true}, |
| 52 | {text: 'Profile', url: `/u/${this.userDisplayName}`}, |
Adrià Vilanova Martínez | 535e731 | 2021-10-17 00:48:12 +0200 | [diff] [blame] | 53 | {text: 'History', url: `/u/${this.userDisplayName}/updates`}, |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 54 | {text: 'Settings', url: '/hosting/settings'}, |
| 55 | {text: 'Saved queries', url: `/u/${this.userDisplayName}/queries`}, |
| 56 | {text: 'Hotlists', url: `/u/${this.userDisplayName}/hotlists`}, |
| 57 | {separator: true}, |
| 58 | {text: 'Sign out', url: this.logoutUrl}, |
| 59 | ]; |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | customElements.define('mr-account-dropdown', MrAccountDropdown); |