UNPKG

@atlaskit/focused-task-close-account

Version:

This package contains all of the UI components needed to assemble the focused tasks for deactivating and deleting users' accounts in accordance with the GDPR "Right to be forgotten".

52 lines 2.28 kB
import _extends from "@babel/runtime/helpers/extends"; import _defineProperty from "@babel/runtime/helpers/defineProperty"; import React from 'react'; import { FormattedMessage } from 'react-intl-next'; import Button from '@atlaskit/button'; import * as Styled from './styled'; import { overviewMessages, dropDownListMessages } from '../../messages'; const COLLAPSED_LIST_SITE_COUNT = 3; export class DropdownList extends React.Component { constructor(...args) { super(...args); _defineProperty(this, "state", { isExpanded: false }); _defineProperty(this, "showDropdownList", () => { this.setState({ isExpanded: true }); }); _defineProperty(this, "hideDropdownList", () => { this.setState({ isExpanded: false }); }); _defineProperty(this, "getVisibleSites", () => { return this.state.isExpanded ? this.props.accessibleSites : this.props.accessibleSites.slice(0, COLLAPSED_LIST_SITE_COUNT); }); } render() { const { accessibleSites } = this.props; const { isExpanded } = this.state; const visibleSites = this.getVisibleSites(); const footNote = visibleSites.length === accessibleSites.length && /*#__PURE__*/React.createElement(Styled.AccessibleSitesListFootnote, null, /*#__PURE__*/React.createElement(FormattedMessage, overviewMessages.paragraphLoseAccessFootnote)); const toggleExpand = accessibleSites.length > COLLAPSED_LIST_SITE_COUNT && /*#__PURE__*/React.createElement(Styled.ButtonWrapper, null, /*#__PURE__*/React.createElement(Button, { onClick: isExpanded ? this.hideDropdownList : this.showDropdownList, appearance: "link", spacing: "none" }, isExpanded ? /*#__PURE__*/React.createElement(FormattedMessage, dropDownListMessages.collapseButton) : /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, dropDownListMessages.expandButton, { values: { num: accessibleSites.length - 3 } })))); return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Styled.AccessibleSitesList, null, visibleSites.map((url, idx) => /*#__PURE__*/React.createElement("li", { key: idx }, url))), footNote, toggleExpand); } } export default DropdownList;