@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".
67 lines • 3.58 kB
JavaScript
import _extends from "@babel/runtime/helpers/extends";
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
import _inherits from "@babel/runtime/helpers/inherits";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
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';
var COLLAPSED_LIST_SITE_COUNT = 3;
export var DropdownList = /*#__PURE__*/function (_React$Component) {
function DropdownList() {
var _this;
_classCallCheck(this, DropdownList);
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
_this = _callSuper(this, DropdownList, [].concat(args));
_defineProperty(_this, "state", {
isExpanded: false
});
_defineProperty(_this, "showDropdownList", function () {
_this.setState({
isExpanded: true
});
});
_defineProperty(_this, "hideDropdownList", function () {
_this.setState({
isExpanded: false
});
});
_defineProperty(_this, "getVisibleSites", function () {
return _this.state.isExpanded ? _this.props.accessibleSites : _this.props.accessibleSites.slice(0, COLLAPSED_LIST_SITE_COUNT);
});
return _this;
}
_inherits(DropdownList, _React$Component);
return _createClass(DropdownList, [{
key: "render",
value: function render() {
var accessibleSites = this.props.accessibleSites;
var isExpanded = this.state.isExpanded;
var visibleSites = this.getVisibleSites();
var footNote = visibleSites.length === accessibleSites.length && /*#__PURE__*/React.createElement(Styled.AccessibleSitesListFootnote, null, /*#__PURE__*/React.createElement(FormattedMessage, overviewMessages.paragraphLoseAccessFootnote));
var 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(function (url, idx) {
return /*#__PURE__*/React.createElement("li", {
key: idx
}, url);
})), footNote, toggleExpand);
}
}]);
}(React.Component);
export default DropdownList;