forked from mattermost/mattermost-webapp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MM-12330] Add "Unarchive Channel" option to archived channels menu (m…
…attermost#4458) Automatic Merge
- Loading branch information
Allen Lai
committed
Feb 27, 2020
1 parent
f536a6d
commit 299cfb1
Showing
11 changed files
with
428 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
components/unarchive_channel_modal/__snapshots__/unarchive_channel_modal.test.jsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`components/unarchive_channel_modal should match snapshot for unarchive_channel_modal 1`] = ` | ||
<Modal | ||
animation={true} | ||
aria-labelledby="unarchiveChannelModalLabel" | ||
autoFocus={true} | ||
backdrop={true} | ||
bsClass="modal" | ||
dialogClassName="a11y__modal" | ||
dialogComponentClass={[Function]} | ||
enforceFocus={true} | ||
id="unarchiveChannelModal" | ||
keyboard={true} | ||
manager={ | ||
ModalManager { | ||
"add": [Function], | ||
"containers": Array [], | ||
"data": Array [], | ||
"handleContainerOverflow": true, | ||
"hideSiblingNodes": true, | ||
"isTopModal": [Function], | ||
"modals": Array [], | ||
"remove": [Function], | ||
} | ||
} | ||
onExited={[MockFunction]} | ||
onHide={[Function]} | ||
renderBackdrop={[Function]} | ||
restoreFocus={true} | ||
role="dialog" | ||
show={true} | ||
> | ||
<ModalHeader | ||
bsClass="modal-header" | ||
closeButton={true} | ||
closeLabel="Close" | ||
> | ||
<ModalTitle | ||
bsClass="modal-title" | ||
componentClass="h1" | ||
id="unarchiveChannelModalLabel" | ||
> | ||
<FormattedMessage | ||
defaultMessage="Confirm UNARCHIVE Channel" | ||
id="unarchive_channel.confirm" | ||
values={Object {}} | ||
/> | ||
</ModalTitle> | ||
</ModalHeader> | ||
<ModalBody | ||
bsClass="modal-body" | ||
componentClass="div" | ||
> | ||
<div | ||
className="alert alert-danger" | ||
> | ||
<injectIntl(FormattedMarkdownMessage) | ||
defaultMessage="Are you sure you wish to unarchive the **{display_name}** channel?" | ||
id="unarchive_channel.viewArchived.question" | ||
values={ | ||
Object { | ||
"display_name": "testing", | ||
} | ||
} | ||
/> | ||
</div> | ||
</ModalBody> | ||
<ModalFooter | ||
bsClass="modal-footer" | ||
componentClass="div" | ||
> | ||
<button | ||
className="btn btn-link" | ||
onClick={[Function]} | ||
type="button" | ||
> | ||
<FormattedMessage | ||
defaultMessage="Cancel" | ||
id="unarchive_channel.cancel" | ||
values={Object {}} | ||
/> | ||
</button> | ||
<button | ||
autoFocus={true} | ||
className="btn btn-danger" | ||
data-dismiss="modal" | ||
id="unarchiveChannelModalDeleteButton" | ||
onClick={[Function]} | ||
type="button" | ||
> | ||
<FormattedMessage | ||
defaultMessage="Unarchive" | ||
id="unarchive_channel.del" | ||
values={Object {}} | ||
/> | ||
</button> | ||
</ModalFooter> | ||
</Modal> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. | ||
// See LICENSE.txt for license information. | ||
|
||
import {bindActionCreators} from 'redux'; | ||
import {connect} from 'react-redux'; | ||
import {unarchiveChannel} from 'mattermost-redux/actions/channels'; | ||
|
||
import UnarchiveChannelModal from './unarchive_channel_modal.jsx'; | ||
|
||
function mapDispatchToProps(dispatch) { | ||
return { | ||
actions: bindActionCreators({ | ||
unarchiveChannel, | ||
}, dispatch), | ||
}; | ||
} | ||
|
||
export default connect(null, mapDispatchToProps)(UnarchiveChannelModal); |
114 changes: 114 additions & 0 deletions
114
components/unarchive_channel_modal/unarchive_channel_modal.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. | ||
// See LICENSE.txt for license information. | ||
|
||
import PropTypes from 'prop-types'; | ||
import React from 'react'; | ||
import {Modal} from 'react-bootstrap'; | ||
import {FormattedMessage} from 'react-intl'; | ||
|
||
import Constants from 'utils/constants'; | ||
import FormattedMarkdownMessage from 'components/formatted_markdown_message'; | ||
|
||
export default class UnarchiveChannelModal extends React.PureComponent { | ||
static propTypes = { | ||
|
||
/** | ||
* Function called when modal is dismissed | ||
*/ | ||
onHide: PropTypes.func.isRequired, | ||
|
||
/** | ||
* channel data | ||
*/ | ||
channel: PropTypes.object.isRequired, | ||
|
||
actions: PropTypes.shape({ | ||
|
||
/** | ||
* Function called for deleting channel, | ||
*/ | ||
|
||
unarchiveChannel: PropTypes.func.isRequired, | ||
}), | ||
} | ||
|
||
constructor(props) { | ||
super(props); | ||
|
||
this.state = {show: true}; | ||
} | ||
|
||
handleUnarchive = () => { | ||
if (this.props.channel.id.length !== Constants.CHANNEL_ID_LENGTH) { | ||
return; | ||
} | ||
this.props.actions.unarchiveChannel(this.props.channel.id); | ||
this.onHide(); | ||
} | ||
|
||
onHide = () => { | ||
this.setState({show: false}); | ||
} | ||
|
||
render() { | ||
return ( | ||
<Modal | ||
dialogClassName='a11y__modal' | ||
show={this.state.show} | ||
onHide={this.onHide} | ||
onExited={this.props.onHide} | ||
role='dialog' | ||
aria-labelledby='unarchiveChannelModalLabel' | ||
id='unarchiveChannelModal' | ||
> | ||
<Modal.Header closeButton={true}> | ||
<Modal.Title | ||
componentClass='h1' | ||
id='unarchiveChannelModalLabel' | ||
> | ||
<FormattedMessage | ||
id='unarchive_channel.confirm' | ||
defaultMessage='Confirm UNARCHIVE Channel' | ||
/> | ||
</Modal.Title> | ||
</Modal.Header> | ||
<Modal.Body> | ||
<div className='alert alert-danger'> | ||
<FormattedMarkdownMessage | ||
id='unarchive_channel.viewArchived.question' | ||
defaultMessage={'Are you sure you wish to unarchive the **{display_name}** channel?'} | ||
values={{ | ||
display_name: this.props.channel.display_name, | ||
}} | ||
/> | ||
</div> | ||
</Modal.Body> | ||
<Modal.Footer> | ||
<button | ||
type='button' | ||
className='btn btn-link' | ||
onClick={this.onHide} | ||
> | ||
<FormattedMessage | ||
id='unarchive_channel.cancel' | ||
defaultMessage='Cancel' | ||
/> | ||
</button> | ||
<button | ||
type='button' | ||
className='btn btn-danger' | ||
data-dismiss='modal' | ||
onClick={this.handleUnarchive} | ||
autoFocus={true} | ||
id='unarchiveChannelModalDeleteButton' | ||
> | ||
<FormattedMessage | ||
id='unarchive_channel.del' | ||
defaultMessage='Unarchive' | ||
/> | ||
</button> | ||
</Modal.Footer> | ||
</Modal> | ||
); | ||
} | ||
} |
Oops, something went wrong.