PageToolbar.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  2. /*
  3. * Copyright 2019 Red Hat, Inc. and/or its affiliates.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. import * as React from "../../common/keycloak/web_modules/react.js";
  18. import { Dropdown, KebabToggle, Toolbar, ToolbarGroup, ToolbarItem } from "../../common/keycloak/web_modules/@patternfly/react-core.js";
  19. import { ReferrerDropdownItem } from "./widgets/ReferrerDropdownItem.js";
  20. import { ReferrerLink } from "./widgets/ReferrerLink.js";
  21. import { LogoutButton, LogoutDropdownItem } from "./widgets/Logout.js";
  22. export class PageToolbar extends React.Component {
  23. constructor(props) {
  24. super(props);
  25. _defineProperty(this, "hasReferrer", typeof referrerName !== 'undefined');
  26. _defineProperty(this, "onKebabDropdownToggle", isKebabDropdownOpen => {
  27. this.setState({
  28. isKebabDropdownOpen
  29. });
  30. });
  31. this.state = {
  32. isKebabDropdownOpen: false
  33. };
  34. }
  35. render() {
  36. const kebabDropdownItems = [];
  37. if (this.hasReferrer) {
  38. kebabDropdownItems.push(React.createElement(ReferrerDropdownItem, {
  39. key: "referrerDropdownItem"
  40. }));
  41. }
  42. kebabDropdownItems.push(React.createElement(LogoutDropdownItem, {
  43. key: "LogoutDropdownItem"
  44. }));
  45. return React.createElement(Toolbar, null, this.hasReferrer && React.createElement(ToolbarGroup, {
  46. key: "referrerGroup"
  47. }, React.createElement(ToolbarItem, {
  48. className: "pf-m-icons",
  49. key: "referrer"
  50. }, React.createElement(ReferrerLink, null))), React.createElement(ToolbarGroup, {
  51. key: "secondGroup"
  52. }, React.createElement(ToolbarItem, {
  53. className: "pf-m-icons",
  54. key: "logout"
  55. }, React.createElement(LogoutButton, null)), React.createElement(ToolbarItem, {
  56. key: "kebab",
  57. className: "pf-m-mobile"
  58. }, React.createElement(Dropdown, {
  59. isPlain: true,
  60. position: "right",
  61. toggle: React.createElement(KebabToggle, {
  62. id: "mobileKebab",
  63. onToggle: this.onKebabDropdownToggle
  64. }),
  65. isOpen: this.state.isKebabDropdownOpen,
  66. dropdownItems: kebabDropdownItems
  67. }))));
  68. }
  69. }
  70. //# sourceMappingURL=PageToolbar.js.map