ShowNavBarItemLabelsAction.ts 961 B

123456789101112131415161718192021222324252627282930
  1. /**
  2. * Licensed Materials - Property of IBM
  3. * IBM Cognos Products: BI
  4. * (C) Copyright IBM Corp. 2020
  5. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  6. */
  7. export default class ShowNavBarItemLabelsAction {
  8. public canExecute(context: any): boolean {
  9. if (context.glassContext.appController.currentAppView) {
  10. const navBar = this.getNavBar();
  11. return navBar !== null;
  12. }
  13. return false;
  14. }
  15. public doAction(): void {
  16. const navBar = this.getNavBar();
  17. if (navBar !== null) {
  18. navBar.classList.remove("narrow");
  19. }
  20. }
  21. private getNavBar = (): HTMLElement => {
  22. const navBar = document
  23. .querySelector(".appview.paneColumn:not(.hidden)")
  24. .getElementsByClassName("navbar");
  25. return navBar && navBar.length > 0 ? (navBar[0] as HTMLElement) : null;
  26. };
  27. }