This repository has been archived by the owner on Sep 11, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 828
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2122 from matrix-org/dbkr/room_upgrade
Support for room upgrades
- Loading branch information
Showing
11 changed files
with
280 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
Copyright 2018 New Vector 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. | ||
*/ | ||
|
||
.mx_RoomUpgradeDialog { | ||
padding-right: 70px; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
Copyright 2018 New Vector 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. | ||
*/ | ||
|
||
.mx_RoomUpgradeWarningBar { | ||
text-align: center; | ||
height: 176px; | ||
background-color: $event-selected-color; | ||
align-items: center; | ||
flex-direction: column; | ||
justify-content: center; | ||
display: flex; | ||
background-color: $preview-bar-bg-color; | ||
-webkit-align-items: center; | ||
padding-left: 20px; | ||
padding-right: 20px; | ||
} | ||
|
||
.mx_RoomUpgradeWarningBar_header { | ||
color: $warning-color; | ||
font-weight: bold; | ||
} | ||
|
||
.mx_RoomUpgradeWarningBar_body { | ||
color: $warning-color; | ||
} | ||
|
||
.mx_RoomUpgradeWarningBar_upgradelink { | ||
color: $warning-color; | ||
text-decoration: underline; | ||
} | ||
|
||
.mx_RoomUpgradeWarningBar_small { | ||
color: $greyed-fg-color; | ||
font-size: 70%; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/* | ||
Copyright 2018 New Vector 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. | ||
*/ | ||
|
||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import sdk from '../../../index'; | ||
import MatrixClientPeg from '../../../MatrixClientPeg'; | ||
import Modal from '../../../Modal'; | ||
import { _t } from '../../../languageHandler'; | ||
|
||
export default React.createClass({ | ||
displayName: 'RoomUpgradeDialog', | ||
|
||
propTypes: { | ||
room: PropTypes.object.isRequired, | ||
onFinished: PropTypes.func.isRequired, | ||
}, | ||
|
||
componentWillMount: function() { | ||
this._targetVersion = this.props.room.shouldUpgradeToVersion(); | ||
}, | ||
|
||
getInitialState: function() { | ||
return { | ||
busy: false, | ||
}; | ||
}, | ||
|
||
_onCancelClick: function() { | ||
this.props.onFinished(false); | ||
}, | ||
|
||
_onUpgradeClick: function() { | ||
this.setState({busy: true}); | ||
MatrixClientPeg.get().upgradeRoom(this.props.room.roomId, this._targetVersion).catch((err) => { | ||
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); | ||
Modal.createTrackedDialog('Failed to upgrade room', '', ErrorDialog, { | ||
title: _t("Failed to upgrade room"), | ||
description: ((err && err.message) ? err.message : _t("The room upgrade could not be completed")), | ||
}); | ||
}).finally(() => { | ||
this.setState({busy: false}); | ||
}); | ||
}, | ||
|
||
render: function() { | ||
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog'); | ||
const DialogButtons = sdk.getComponent('views.elements.DialogButtons'); | ||
const Spinner = sdk.getComponent('views.elements.Spinner'); | ||
|
||
let buttons; | ||
if (this.state.busy) { | ||
buttons = <Spinner />; | ||
} else { | ||
buttons = <DialogButtons | ||
primaryButton={_t( | ||
'Upgrade this room to version %(version)s', | ||
{version: this._targetVersion}, | ||
)} | ||
primaryButtonClass="danger" | ||
hasCancel={true} | ||
onPrimaryButtonClick={this._onUpgradeClick} | ||
focus={this.props.focus} | ||
onCancel={this._onCancelClick} | ||
/>; | ||
} | ||
|
||
return ( | ||
<BaseDialog className="mx_RoomUpgradeDialog" | ||
onFinished={this.onCancelled} | ||
title={_t("Upgrade Room Version")} | ||
contentId='mx_Dialog_content' | ||
onFinished={this.props.onFinished} | ||
hasCancel={true} | ||
> | ||
<p> | ||
{_t( | ||
"Upgrading this room requires closing down the current " + | ||
"instance of the room and creating a new room it its place. " + | ||
"To give room members the best possible experience, we will:", | ||
)} | ||
</p> | ||
<ol> | ||
<li>{_t("Create a new room with the same name, description and avatar")}</li> | ||
<li>{_t("Update any local room aliases to point to the new room")}</li> | ||
<li>{_t("Stop users from speaking in the old version of the room, and post a message advising users to move to the new room")}</li> | ||
<li>{_t("Put a link back to the old room at the start of the new room so people can see old messages")}</li> | ||
</ol> | ||
{buttons} | ||
</BaseDialog> | ||
); | ||
}, | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
Copyright 2018 New Vector 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. | ||
*/ | ||
|
||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import sdk from '../../../index'; | ||
import Modal from '../../../Modal'; | ||
|
||
import { _t } from '../../../languageHandler'; | ||
|
||
module.exports = React.createClass({ | ||
displayName: 'RoomUpgradeWarningBar', | ||
|
||
propTypes: { | ||
room: PropTypes.object.isRequired, | ||
}, | ||
|
||
onUpgradeClick: function() { | ||
const RoomUpgradeDialog = sdk.getComponent('dialogs.RoomUpgradeDialog'); | ||
Modal.createTrackedDialog('Upgrade Room Version', '', RoomUpgradeDialog, {room: this.props.room}); | ||
}, | ||
|
||
render: function() { | ||
const AccessibleButton = sdk.getComponent('elements.AccessibleButton'); | ||
return ( | ||
<div className="mx_RoomUpgradeWarningBar"> | ||
<div className="mx_RoomUpgradeWarningBar_header"> | ||
{_t("There is a known vulnerability affecting this room.")} | ||
</div> | ||
<div className="mx_RoomUpgradeWarningBar_body"> | ||
{_t("This room version is vulnerable to malicious modification of room state.")} | ||
</div> | ||
<p className="mx_RoomUpgradeWarningBar_upgradelink"> | ||
<AccessibleButton onClick={this.onUpgradeClick}> | ||
{_t("Click here to upgrade to the latest room version and ensure room integrity is protected.")} | ||
</AccessibleButton> | ||
</p> | ||
<div className="mx_RoomUpgradeWarningBar_small"> | ||
{_t("Only room administrators will see this warning")} | ||
</div> | ||
</div> | ||
); | ||
}, | ||
}); |
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