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 832
Implement the Advanced tab of new room settings #2525
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2fe7f6f
Implement the Advanced tab of new room settings
turt2live e7ed4c1
Appease the linter
turt2live b3bb3af
Remove spurious void
turt2live cd54442
Merge branch 'experimental' into travis/rsettings/tab/advanced
turt2live da95bf9
Regen i18n due to merge
turt2live File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
104 changes: 104 additions & 0 deletions
104
src/components/views/settings/tabs/AdvancedRoomSettingsTab.js
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,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(): void { | ||
// 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> | ||
); | ||
} | ||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's this lone type annotation-like thing doing here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something my IDE autocompletes and I constantly forget to remove. I can remove it if wanted, and i should probably pay attention to what I'm overloading.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems a bit random to type only one method, so I guess I'd remove it... hopefully it's configurable in your IDE?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably. I write a lot of typescript and that's probably interfering with the jsx settings a bit. I'll just pay a bit more attention to it