Initial unstyled mentions state notifier context menu

This commit is contained in:
wmwragg 2016-07-22 17:30:09 +01:00
parent 204e42494a
commit 2768cd2010
3 changed files with 108 additions and 46 deletions

View File

@ -35,7 +35,6 @@ module.exports.components['structures.RoomSubList'] = require('./components/stru
module.exports.components['structures.SearchBox'] = require('./components/structures/SearchBox'); module.exports.components['structures.SearchBox'] = require('./components/structures/SearchBox');
module.exports.components['structures.ViewSource'] = require('./components/structures/ViewSource'); module.exports.components['structures.ViewSource'] = require('./components/structures/ViewSource');
module.exports.components['views.elements.ImageView'] = require('./components/views/elements/ImageView'); module.exports.components['views.elements.ImageView'] = require('./components/views/elements/ImageView');
module.exports.components['views.elements.Label'] = require('./components/views/elements/Label');
module.exports.components['views.elements.Spinner'] = require('./components/views/elements/Spinner'); module.exports.components['views.elements.Spinner'] = require('./components/views/elements/Spinner');
module.exports.components['views.globals.GuestWarningBar'] = require('./components/views/globals/GuestWarningBar'); module.exports.components['views.globals.GuestWarningBar'] = require('./components/views/globals/GuestWarningBar');
module.exports.components['views.globals.MatrixToolbar'] = require('./components/views/globals/MatrixToolbar'); module.exports.components['views.globals.MatrixToolbar'] = require('./components/views/globals/MatrixToolbar');
@ -48,6 +47,7 @@ module.exports.components['views.messages.MessageTimestamp'] = require('./compon
module.exports.components['views.messages.SenderProfile'] = require('./components/views/messages/SenderProfile'); module.exports.components['views.messages.SenderProfile'] = require('./components/views/messages/SenderProfile');
module.exports.components['views.rooms.BottomLeftMenuTile'] = require('./components/views/rooms/BottomLeftMenuTile'); module.exports.components['views.rooms.BottomLeftMenuTile'] = require('./components/views/rooms/BottomLeftMenuTile');
module.exports.components['views.rooms.MessageContextMenu'] = require('./components/views/rooms/MessageContextMenu'); module.exports.components['views.rooms.MessageContextMenu'] = require('./components/views/rooms/MessageContextMenu');
module.exports.components['views.rooms.NotificationStateContextMenu'] = require('./components/views/rooms/NotificationStateContextMenu');
module.exports.components['views.rooms.RoomDNDView'] = require('./components/views/rooms/RoomDNDView'); module.exports.components['views.rooms.RoomDNDView'] = require('./components/views/rooms/RoomDNDView');
module.exports.components['views.rooms.RoomDropTarget'] = require('./components/views/rooms/RoomDropTarget'); module.exports.components['views.rooms.RoomDropTarget'] = require('./components/views/rooms/RoomDropTarget');
module.exports.components['views.rooms.RoomTooltip'] = require('./components/views/rooms/RoomTooltip'); module.exports.components['views.rooms.RoomTooltip'] = require('./components/views/rooms/RoomTooltip');

View File

@ -1,45 +0,0 @@
/*
Copyright 2015, 2016 OpenMarket Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
'use strict';
var React = require('react');
module.exports = React.createClass({
displayName: 'Label',
propTypes: {
label: React.PropTypes.string,
},
getInitialState: function() {
return({ label : "LABEL" });
},
onLabelClick: function() {
if (this.props.onFinished) this.props.onFinished();
},
render: function() {
return (
<div>
<div className="mx_ContextualMenu_field" onClick={ this.onLabelClick }>
LABEL
</div>
</div>
);
}
});

View File

@ -0,0 +1,107 @@
/*
Copyright 2015, 2016 OpenMarket Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
'use strict';
var q = require("q");
var React = require('react');
var MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg');
module.exports = React.createClass({
displayName: 'NotificationStateContextMenu',
propTypes: {
room: React.PropTypes.object.isRequired,
/* callback called when the menu is dismissed */
onFinished: React.PropTypes.func,
},
getInitialState: function() {
var areNotifsMuted = false;
var cli = MatrixClientPeg.get();
if (!cli.isGuest()) {
var roomPushRule = cli.getRoomPushRule("global", this.props.room.roomId);
if (roomPushRule) {
if (0 <= roomPushRule.actions.indexOf("dont_notify")) {
areNotifsMuted = true;
}
}
}
return {
areNotifsMuted: areNotifsMuted,
};
},
onAllClick: function() {
if (this.props.onFinished) {
this.setState({areNotifsMuted: false});
this._save(false);
this.props.onFinished();
}
},
onMuteClick: function() {
if (this.props.onFinished) {
this.setState({areNotifsMuted: true});
this._save(true);
this.props.onFinished();
}
},
_save: function( isMuted ) {
const roomId = this.props.room.roomId;
/*
if (this.state.areNotifsMuted !== originalState.areNotifsMuted) {
promises.push(MatrixClientPeg.get().setRoomMutePushRule(
"global", roomId, this.state.areNotifsMuted
));
}
*/
MatrixClientPeg.get().setRoomMutePushRule(
"global", roomId, isMuted
);
},
_onToggle: function(keyName, checkedValue, uncheckedValue, ev) {
console.log("Checkbox toggle: %s %s", keyName, ev.target.checked);
var state = {};
state[keyName] = ev.target.checked ? checkedValue : uncheckedValue;
this.setState(state);
},
render: function() {
var cli = MatrixClientPeg.get();
return (
<div>
{/*
<div className="mx_ContextualMenu_field">
<input type="checkbox" disabled={ cli.isGuest() }
onChange={this._onToggle.bind(this, "areNotifsMuted", true, false)}
defaultChecked={this.state.areNotifsMuted}/>
Mute notifications for this room
</div>
*/}
<div className="mx_ContextualMenu_field" onClick={ this.onAllClick }>
All notifications - { this.state.areNotifsMuted ? "OFF" : "ON" }
</div>
<div className="mx_ContextualMenu_field" onClick={ this.onMuteClick }>
Mute - { this.state.areNotifsMuted ? "ON" : "OFF" }
</div>
</div>
);
}
});