Press n or j to go to the next uncovered block, b, p or k for the previous block.
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 | 497x 497x 497x 497x 497x 497x 497x 497x 497x | /* * Copyright 2021 Harness Inc. All rights reserved. * Use of this source code is governed by the PolyForm Shield 1.0.0 license * that can be found in the licenses directory at the root of this repository, also available at * https://polyformproject.org/wp-content/uploads/2020/06/PolyForm-Shield-1.0.0.txt. */ import React from 'react' import { Position, Classes, PopoverInteractionKind } from '@blueprintjs/core' import cx from 'classnames' import { Container, Heading, Icon, Text, IconName, Popover } from '@wings-software/uicore' import { NavLink } from 'react-router-dom' import i18n from './AdminSelector.i18n' import css from './AdminSelector.module.scss' export interface AdminSelectorProps { selected?: boolean path: string } export const AdminSelector: React.FC<AdminSelectorProps> = ({ children, path }) => { return ( <Popover interactionKind={PopoverInteractionKind.CLICK} position={Position.RIGHT} modifiers={{ offset: { offset: -50 } }} minimal portalClassName={css.portal} fill={true} > <NavLink className={css.adminLink} activeClassName={css.active} to={path} onClick={e => e.preventDefault()}> {i18n.admin} </NavLink> <Container width={300} padding="medium"> <Heading level={2} font={{ weight: 'semi-bold' }} padding="small" margin={{ bottom: 'large' }}> {i18n.adminSelector} </Heading> <Container className={cx(css.grid, Classes.POPOVER_DISMISS)}>{children}</Container> </Container> </Popover> ) } export interface AdminSelectorLinkProps { to: string label: string iconName: IconName disabled?: boolean } export const AdminSelectorLink: React.FC<AdminSelectorLinkProps> = ({ to, label, iconName, disabled }) => { const handleLinkClick = (e: React.MouseEvent<HTMLAnchorElement, MouseEvent>): void => { if (disabled) e.preventDefault() // POPOVER_DISMISS does not work with <Link />, so we trigger click on parent // https://github.com/palantir/blueprint/issues/2820 const { parentElement } = e.target as HTMLAnchorElement parentElement?.click() } return ( <span className={Classes.POPOVER_DISMISS}> <NavLink className={css.link} to={to} onClick={handleLinkClick}> <Icon name={iconName} size={24} className={css.linkIcon} /> <Text inline style={{ paddingTop: 'var(--spacing-medium)' }} className={css.text}> {label} </Text> </NavLink> </span> ) } |