'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _Page = require('./Page');

var _Page2 = _interopRequireDefault(_Page);

var _UserMenu = require('./UserMenu');

var _UserMenu2 = _interopRequireDefault(_UserMenu);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

class ProtectedPage extends _Page2.default {
  constructor() {
    super();

    this.selector = '.cspace-ui-Banner--common';
    this.navBarSelector = '.cspace-ui-NavBar--common';

    this.userMenu = new _UserMenu2.default();
  }

  getUserScreenName() {
    return this.userMenu.getUserScreenName();
  }

  getLogoutLink() {
    return this.userMenu.getLogoutLink();
  }

  isLoggedInAs(username) {
    return this.userMenu.isLoggedInAs(username);
  }

  isUserMenuVisible() {
    return this.userMenu.isVisible();
  }

  isVisible() {
    return super.isVisible() && this.isUserMenuVisible();
  }

  clickCreateNewLink() {
    browser.$(this.navBarSelector).$('a=Create New').click();
  }

  logout() {
    this.userMenu.logout();

    return this;
  }
}
exports.default = ProtectedPage;