Merge pull request #2525 from matrix-org/travis/rsettings/tab/advanced
Implement the Advanced tab of new room settingspull/21833/head
						commit
						028c420d56
					
				|  | @ -18,6 +18,7 @@ import React from 'react'; | |||
| import PropTypes from 'prop-types'; | ||||
| import {Tab, TabbedView} from "../../structures/TabbedView"; | ||||
| import {_t, _td} from "../../../languageHandler"; | ||||
| import AdvancedRoomSettingsTab from "../settings/tabs/AdvancedRoomSettingsTab"; | ||||
| import AccessibleButton from "../elements/AccessibleButton"; | ||||
| import dis from '../../../dispatcher'; | ||||
| import RolesRoomSettingsTab from "../settings/tabs/RolesRoomSettingsTab"; | ||||
|  | @ -79,7 +80,7 @@ export default class RoomSettingsDialog extends React.Component { | |||
|         tabs.push(new Tab( | ||||
|             _td("Advanced"), | ||||
|             "mx_RoomSettingsDialog_warningIcon", | ||||
|             <div>Advanced Test</div>, | ||||
|             <AdvancedRoomSettingsTab roomId={this.props.roomId} />, | ||||
|         )); | ||||
|         tabs.push(new Tab( | ||||
|             _td("Visit old settings"), | ||||
|  |  | |||
|  | @ -0,0 +1,104 @@ | |||
| /* | ||||
| Copyright 2019 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 {_t} from "../../../../languageHandler"; | ||||
| import MatrixClientPeg from "../../../../MatrixClientPeg"; | ||||
| import sdk from "../../../../index"; | ||||
| import AccessibleButton from "../../elements/AccessibleButton"; | ||||
| import Modal from "../../../../Modal"; | ||||
| 
 | ||||
| export default class AdvancedRoomSettingsTab extends React.Component { | ||||
|     static propTypes = { | ||||
|         roomId: PropTypes.string.isRequired, | ||||
|     }; | ||||
| 
 | ||||
|     constructor() { | ||||
|         super(); | ||||
| 
 | ||||
|         this.state = { | ||||
|             // This is eventually set to the value of room.getRecommendedVersion()
 | ||||
|             upgradeRecommendation: null, | ||||
|         }; | ||||
|     } | ||||
| 
 | ||||
|     componentWillMount() { | ||||
|         // we handle lack of this object gracefully later, so don't worry about it failing here.
 | ||||
|         MatrixClientPeg.get().getRoom(this.props.roomId).getRecommendedVersion().then((v) => { | ||||
|             this.setState({upgradeRecommendation: v}); | ||||
|         }); | ||||
|     } | ||||
| 
 | ||||
|     _upgradeRoom = (e) => { | ||||
|         const RoomUpgradeDialog = sdk.getComponent('dialogs.RoomUpgradeDialog'); | ||||
|         const room = MatrixClientPeg.get().getRoom(this.props.roomId); | ||||
|         Modal.createTrackedDialog('Upgrade Room Version', '', RoomUpgradeDialog, {room: room}); | ||||
|     }; | ||||
| 
 | ||||
|     _openDevtools = (e) => { | ||||
|         const DevtoolsDialog = sdk.getComponent('dialogs.DevtoolsDialog'); | ||||
|         Modal.createDialog(DevtoolsDialog, {roomId: this.props.roomId}); | ||||
|     }; | ||||
| 
 | ||||
|     render() { | ||||
|         const client = MatrixClientPeg.get(); | ||||
|         const room = client.getRoom(this.props.roomId); | ||||
| 
 | ||||
|         let unfederatableSection; | ||||
|         const createEvent = room.currentState.getStateEvents('m.room.create', ''); | ||||
|         if (createEvent && createEvent.getContent()['m.federate'] === false) { | ||||
|             unfederatableSection = <div>{_t('This room is not accessible by remote Matrix servers')}</div>; | ||||
|         } | ||||
| 
 | ||||
|         let roomUpgradeButton; | ||||
|         if (this.state.upgradeRecommendation && this.state.upgradeRecommendation.needsUpgrade) { | ||||
|             roomUpgradeButton = ( | ||||
|                 <AccessibleButton onClick={this._upgradeRoom} kind='primary'> | ||||
|                     {_t("Upgrade room to version %(ver)s", {ver: this.state.upgradeRecommendation.version})} | ||||
|                 </AccessibleButton> | ||||
|             ); | ||||
|         } | ||||
| 
 | ||||
|         return ( | ||||
|             <div className="mx_SettingsTab"> | ||||
|                 <div className="mx_SettingsTab_heading">{_t("Advanced")}</div> | ||||
|                 <div className='mx_SettingsTab_section mx_SettingsTab_subsectionText'> | ||||
|                     <span className='mx_SettingsTab_subheading'>{_t("Room information")}</span> | ||||
|                     <div> | ||||
|                         <span>{_t("Internal room ID:")}</span>  | ||||
|                         {this.props.roomId} | ||||
|                     </div> | ||||
|                     {unfederatableSection} | ||||
|                 </div> | ||||
|                 <div className='mx_SettingsTab_section mx_SettingsTab_subsectionText'> | ||||
|                     <span className='mx_SettingsTab_subheading'>{_t("Room version")}</span> | ||||
|                     <div> | ||||
|                         <span>{_t("Room version:")}</span>  | ||||
|                         {room.getVersion()} | ||||
|                     </div> | ||||
|                     {roomUpgradeButton} | ||||
|                 </div> | ||||
|                 <div className='mx_SettingsTab_section mx_SettingsTab_subsectionText'> | ||||
|                     <span className='mx_SettingsTab_subheading'>{_t("Developer options")}</span> | ||||
|                     <AccessibleButton onClick={this._openDevtools} kind='primary'> | ||||
|                         {_t("Open Devtools")} | ||||
|                     </AccessibleButton> | ||||
|                 </div> | ||||
|             </div> | ||||
|         ); | ||||
|     } | ||||
| } | ||||
|  | @ -430,6 +430,15 @@ | |||
|     "Upload profile picture": "Upload profile picture", | ||||
|     "Display Name": "Display Name", | ||||
|     "Save": "Save", | ||||
|     "This room is not accessible by remote Matrix servers": "This room is not accessible by remote Matrix servers", | ||||
|     "Upgrade room to version %(ver)s": "Upgrade room to version %(ver)s", | ||||
|     "Advanced": "Advanced", | ||||
|     "Room information": "Room information", | ||||
|     "Internal room ID:": "Internal room ID:", | ||||
|     "Room version": "Room version", | ||||
|     "Room version:": "Room version:", | ||||
|     "Developer options": "Developer options", | ||||
|     "Open Devtools": "Open Devtools", | ||||
|     "Flair": "Flair", | ||||
|     "General": "General", | ||||
|     "Room Addresses": "Room Addresses", | ||||
|  | @ -466,7 +475,6 @@ | |||
|     "matrix-react-sdk version:": "matrix-react-sdk version:", | ||||
|     "riot-web version:": "riot-web version:", | ||||
|     "olm version:": "olm version:", | ||||
|     "Advanced": "Advanced", | ||||
|     "Homeserver is": "Homeserver is", | ||||
|     "Identity Server is": "Identity Server is", | ||||
|     "Access Token:": "Access Token:", | ||||
|  | @ -505,7 +513,6 @@ | |||
|     "Muted Users": "Muted Users", | ||||
|     "Banned users": "Banned users", | ||||
|     "To send events of type <eventType/>, you must be a": "To send events of type <eventType/>, you must be a", | ||||
|     "This room is not accessible by remote Matrix servers": "This room is not accessible by remote Matrix servers", | ||||
|     "Roles & Permissions": "Roles & Permissions", | ||||
|     "Permissions": "Permissions", | ||||
|     "Unignore": "Unignore", | ||||
|  | @ -731,8 +738,6 @@ | |||
|     "To link to a room it must have <a>an address</a>.": "To link to a room it must have <a>an address</a>.", | ||||
|     "Guests cannot join this room even if explicitly invited.": "Guests cannot join this room even if explicitly invited.", | ||||
|     "Click here to fix": "Click here to fix", | ||||
|     "Upgrade room to version %(ver)s": "Upgrade room to version %(ver)s", | ||||
|     "Open Devtools": "Open Devtools", | ||||
|     "Who can access this room?": "Who can access this room?", | ||||
|     "Only people who have been invited": "Only people who have been invited", | ||||
|     "Anyone who knows the room's link, apart from guests": "Anyone who knows the room's link, apart from guests", | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 Travis Ralston
						Travis Ralston