From d8bd57901e33a7057e26e782e295099ffcc0da89 Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Wed, 6 Sep 2017 23:04:13 -0700 Subject: Removing webapp --- webapp/components/multiselect/multiselect_list.jsx | 171 --------------------- 1 file changed, 171 deletions(-) delete mode 100644 webapp/components/multiselect/multiselect_list.jsx (limited to 'webapp/components/multiselect/multiselect_list.jsx') diff --git a/webapp/components/multiselect/multiselect_list.jsx b/webapp/components/multiselect/multiselect_list.jsx deleted file mode 100644 index 4e5878790..000000000 --- a/webapp/components/multiselect/multiselect_list.jsx +++ /dev/null @@ -1,171 +0,0 @@ -// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. - -import {cmdOrCtrlPressed} from 'utils/utils.jsx'; -import Constants from 'utils/constants.jsx'; -const KeyCodes = Constants.KeyCodes; - -import PropTypes from 'prop-types'; - -import React from 'react'; -import {FormattedMessage} from 'react-intl'; - -export default class MultiSelectList extends React.Component { - constructor(props) { - super(props); - - this.defaultOptionRenderer = this.defaultOptionRenderer.bind(this); - this.handleArrowPress = this.handleArrowPress.bind(this); - this.setSelected = this.setSelected.bind(this); - - this.toSelect = -1; - - this.state = { - selected: -1 - }; - } - - componentDidMount() { - document.addEventListener('keydown', this.handleArrowPress); - } - - componentWillUnmount() { - document.removeEventListener('keydown', this.handleArrowPress); - } - - componentWillReceiveProps(nextProps) { - this.setState({selected: this.toSelect}); - - const options = nextProps.options; - - if (options && options.length > 0 && this.toSelect >= 0) { - this.props.onSelect(options[this.toSelect]); - } - } - - componentDidUpdate() { - if (this.refs.list && this.refs.selected) { - const elemTop = this.refs.selected.getBoundingClientRect().top; - const elemBottom = this.refs.selected.getBoundingClientRect().bottom; - const listTop = this.refs.list.getBoundingClientRect().top; - const listBottom = this.refs.list.getBoundingClientRect().bottom; - if (elemBottom > listBottom) { - this.refs.selected.scrollIntoView(false); - } else if (elemTop < listTop) { - this.refs.selected.scrollIntoView(true); - } - } - } - - setSelected(selected) { - this.toSelect = selected; - } - - handleArrowPress(e) { - if (cmdOrCtrlPressed(e) && e.shiftKey) { - return; - } - - const options = this.props.options; - if (options.length === 0) { - return; - } - - let selected; - switch (e.keyCode) { - case KeyCodes.DOWN: - if (this.state.selected === -1) { - selected = 0; - break; - } - selected = Math.min(this.state.selected + 1, options.length - 1); - break; - case KeyCodes.UP: - if (this.state.selected === -1) { - selected = 0; - break; - } - selected = Math.max(this.state.selected - 1, 0); - break; - default: - return; - } - - e.preventDefault(); - this.setState({selected}); - this.props.onSelect(options[selected]); - } - - defaultOptionRenderer(option, isSelected, onAdd) { - var rowSelected = ''; - if (isSelected) { - rowSelected = 'more-modal__row--selected'; - } - - return ( -
onAdd(option)} - > - {option.label} -
- ); - } - - render() { - const options = this.props.options; - - if (options == null || options.length === 0) { - return ( -
-

- -

-
- ); - } - - let renderer; - if (this.props.optionRenderer) { - renderer = this.props.optionRenderer; - } else { - renderer = this.defaultOptionRenderer; - } - - const optionControls = options.map((o, i) => renderer(o, this.state.selected === i, this.props.onAdd)); - - return ( -
-
- {optionControls} -
-
- ); - } -} - -MultiSelectList.defaultProps = { - options: [], - perPage: 50, - onAction: () => null -}; - -MultiSelectList.propTypes = { - options: PropTypes.arrayOf(PropTypes.object), - optionRenderer: PropTypes.func, - page: PropTypes.number, - perPage: PropTypes.number, - onPageChange: PropTypes.func, - onAdd: PropTypes.func, - onSelect: PropTypes.func -}; -- cgit v1.2.3-1-g7c22