Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Put back default strings on dialogs
Browse files Browse the repository at this point in the history
But make them work by calling _t in render rather than
getDefaultProps().

Also sort out some 'Warning!' strings
  • Loading branch information
dbkr committed May 25, 2017
1 parent 9112fc2 commit 443ab1a
Show file tree
Hide file tree
Showing 30 changed files with 31 additions and 78 deletions.
15 changes: 1 addition & 14 deletions src/CallHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ function _setCallListeners(call) {
Modal.createDialog(ErrorDialog, {
title: _t('Call Timeout'),
description: _t('The remote side failed to pick up') + '.',
button: _t("OK"),
});
}
else if (oldState === "invite_sent") {
Expand Down Expand Up @@ -207,7 +206,6 @@ function _onAction(payload) {
Modal.createDialog(ErrorDialog, {
title: _t('Unable to capture screen'),
description: screenCapErrorString,
button: _t("OK"),
});
return;
}
Expand All @@ -228,7 +226,6 @@ function _onAction(payload) {
Modal.createDialog(ErrorDialog, {
title: _t('Existing Call'),
description: _t('You are already in a call') + '.',
button: _t("OK"),
});
return; // don't allow >1 call to be placed.
}
Expand All @@ -239,7 +236,6 @@ function _onAction(payload) {
Modal.createDialog(ErrorDialog, {
title: _t('VoIP is unsupported'),
description: _t('You cannot place VoIP calls in this browser') + '.',
button: _t("OK"),
});
return;
}
Expand All @@ -255,8 +251,6 @@ function _onAction(payload) {
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
Modal.createDialog(ErrorDialog, {
description: _t('You cannot place a call with yourself') + '.',
title: _t("Error"),
button: _t("OK"),
});
return;
}
Expand All @@ -283,16 +277,13 @@ function _onAction(payload) {
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
Modal.createDialog(ErrorDialog, {
description: _t('Conference calls are not supported in this client'),
title: _t("Error"),
button: _t("OK"),
});
}
else if (!MatrixClientPeg.get().supportsVoip()) {
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
Modal.createDialog(ErrorDialog, {
title: _t('VoIP is unsupported'),
description: _t('You cannot place VoIP calls in this browser') + '.',
button: _t("OK"),
});
}
else if (MatrixClientPeg.get().isRoomEncrypted(payload.room_id)) {
Expand All @@ -304,17 +295,14 @@ function _onAction(payload) {
// Therefore we disable conference calling in E2E rooms.
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
Modal.createDialog(ErrorDialog, {
title: _t("Error"),
button: _t("OK"),
description: _t('Conference calls are not supported in encrypted rooms'),
});
}
else {
var QuestionDialog = sdk.getComponent("dialogs.QuestionDialog");
Modal.createDialog(QuestionDialog, {
title: _t('Warning') + '!',
title: _t('Warning!'),
description: _t('Conference calling is in development and may not be reliable') + '.',
button: _t("OK"),
onFinished: confirm=>{
if (confirm) {
ConferenceHandler.createNewMatrixCall(
Expand All @@ -327,7 +315,6 @@ function _onAction(payload) {
Modal.createDialog(ErrorDialog, {
title: _t('Failed to set up conference call'),
description: _t('Conference call failed') + '. ' + ((err && err.message) ? err.message : ''),
button: _t("OK"),
});
});
}
Expand Down
1 change: 0 additions & 1 deletion src/ContentMessages.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,6 @@ class ContentMessages {
Modal.createDialog(ErrorDialog, {
title: _t('Upload Failed'),
description: desc,
button: _t("OK"),
});
}
}).finally(() => {
Expand Down
1 change: 0 additions & 1 deletion src/SlashCommands.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ const commands = {
Modal.createDialog(ErrorDialog, {
title: _t('/ddg is not a command'),
description: _t('To use it, just wait for autocomplete results to load and tab through them') + '.',
button: _t("OK"),
});
return success();
}),
Expand Down
3 changes: 0 additions & 3 deletions src/components/structures/MatrixChat.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,6 @@ module.exports = React.createClass({
Modal.createDialog(QuestionDialog, {
title: _t('Reject invitation'),
description: _t('Are you sure you want to reject the invitation?'),
button: "OK",
onFinished: (confirm) => {
if (confirm) {
// FIXME: controller shouldn't be loading a view :(
Expand All @@ -395,7 +394,6 @@ module.exports = React.createClass({
Modal.createDialog(ErrorDialog, {
title: _t('Failed to reject invitation'),
description: err.toString(),
button: _t("OK"),
});
});
}
Expand Down Expand Up @@ -895,7 +893,6 @@ module.exports = React.createClass({
Modal.createDialog(ErrorDialog, {
title: _t('Signed Out'),
description: _t('For security, this session has been signed out. Please sign in again.'),
button: _t("OK"),
});
dis.dispatch({
action: 'logout',
Expand Down
9 changes: 1 addition & 8 deletions src/components/structures/RoomView.js
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ module.exports = React.createClass({
if (!userHasUsedEncryption) {
const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog");
Modal.createDialog(QuestionDialog, {
title: _t("Warning") + "!",
title: _t("Warning!"),
hasCancelButton: false,
description: (
<div>
Expand All @@ -541,7 +541,6 @@ module.exports = React.createClass({
<p>{ _t("Encrypted messages will not be visible on clients that do not yet implement encryption") }.</p>
</div>
),
button: "OK",
});
}
if (localStorage) {
Expand Down Expand Up @@ -882,7 +881,6 @@ module.exports = React.createClass({
Modal.createDialog(ErrorDialog, {
title: _t("Failed to join room"),
description: msg,
button: _t("OK"),
});
}
}).done();
Expand Down Expand Up @@ -964,7 +962,6 @@ module.exports = React.createClass({
Modal.createDialog(ErrorDialog, {
title: _t('Failed to upload file'),
description: ((error && error.message) ? error.message : _t("Server may be unavailable, overloaded, or the file too big")),
button: _t("OK"),
});
});
},
Expand Down Expand Up @@ -1052,7 +1049,6 @@ module.exports = React.createClass({
Modal.createDialog(ErrorDialog, {
title: _t("Search failed"),
description: ((error && error.message) ? error.message : _t("Server may be unavailable, overloaded, or search timed out :(")),
button: _t("OK"),
});
}).finally(function() {
self.setState({
Expand Down Expand Up @@ -1180,7 +1176,6 @@ module.exports = React.createClass({
Modal.createDialog(ErrorDialog, {
title: _t("Failed to save settings"),
description: fails.map(function(result) { return result.reason; }).join("\n"),
button: _t("OK"),
});
// still editing room settings
}
Expand Down Expand Up @@ -1220,7 +1215,6 @@ module.exports = React.createClass({
Modal.createDialog(ErrorDialog, {
title: _t("Error"),
description: _t("Failed to forget room %(errCode)s", { errCode: errCode }),
button: _t("OK"),
});
});
},
Expand All @@ -1243,7 +1237,6 @@ module.exports = React.createClass({
Modal.createDialog(ErrorDialog, {
title: _t("Failed to reject invite"),
description: msg,
button: _t("OK"),
});

self.setState({
Expand Down
1 change: 0 additions & 1 deletion src/components/structures/TimelinePanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,6 @@ var TimelinePanel = React.createClass({
Modal.createDialog(ErrorDialog, {
title: _t("Failed to load timeline position"),
description: message,
button: _t("OK"),
onFinished: onFinished,
});
};
Expand Down
8 changes: 0 additions & 8 deletions src/components/structures/UserSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ module.exports = React.createClass({
Modal.createDialog(ErrorDialog, {
title: _t("Can't load user settings"),
description: ((error && error.message) ? error.message : _t("Server may be unavailable or overloaded")),
button: _t("OK"),
});
});
},
Expand Down Expand Up @@ -292,7 +291,6 @@ module.exports = React.createClass({
Modal.createDialog(ErrorDialog, {
title: _t("Failed to set avatar"),
description: ((err && err.message) ? err.message : _t("Operation failed")),
button: _t("OK")
});
});
},
Expand Down Expand Up @@ -335,7 +333,6 @@ module.exports = React.createClass({
Modal.createDialog(ErrorDialog, {
title: _t("Error"),
description: errMsg,
button: _t("OK"),
});
},

Expand All @@ -344,7 +341,6 @@ module.exports = React.createClass({
Modal.createDialog(ErrorDialog, {
title: _t("Success"),
description: _t("Your password was successfully changed. You will not receive push notifications on other devices until you log back in to them") + ".",
button: _t("OK"),
});
},

Expand Down Expand Up @@ -372,7 +368,6 @@ module.exports = React.createClass({
Modal.createDialog(ErrorDialog, {
title: _t("Invalid Email Address"),
description: _t("This doesn't appear to be a valid email address"),
button: _t("OK"),
});
return;
}
Expand All @@ -392,7 +387,6 @@ module.exports = React.createClass({
Modal.createDialog(ErrorDialog, {
title: _t("Unable to add email address"),
description: ((err && err.message) ? err.message : _t("Operation failed")),
button: _t("OK"),
});
});
ReactDOM.findDOMNode(this.refs.add_email_input).blur();
Expand All @@ -418,7 +412,6 @@ module.exports = React.createClass({
Modal.createDialog(ErrorDialog, {
title: _t("Unable to remove contact information"),
description: ((err && err.message) ? err.message : _t("Operation failed")),
button: _t("OK"),
});
}).done();
}
Expand Down Expand Up @@ -460,7 +453,6 @@ module.exports = React.createClass({
Modal.createDialog(ErrorDialog, {
title: _t("Unable to verify email address"),
description: ((err && err.message) ? err.message : _t("Operation failed")),
button: _t("OK"),
});
}
});
Expand Down
3 changes: 1 addition & 2 deletions src/components/structures/login/ForgotPassword.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ module.exports = React.createClass({
else {
var QuestionDialog = sdk.getComponent("dialogs.QuestionDialog");
Modal.createDialog(QuestionDialog, {
title: _t('Warning'),
title: _t('Warning!'),
description:
<div>
{ _t(
Expand Down Expand Up @@ -157,7 +157,6 @@ module.exports = React.createClass({
Modal.createDialog(ErrorDialog, {
title: title,
description: body,
button: _t("OK"),
});
},

Expand Down
4 changes: 0 additions & 4 deletions src/components/views/dialogs/ChatInviteDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,6 @@ module.exports = React.createClass({
Modal.createDialog(ErrorDialog, {
title: "Failed to invite",
description: ((err && err.message) ? err.message : "Operation failed"),
button: _t("OK"),
});
return null;
})
Expand All @@ -321,7 +320,6 @@ module.exports = React.createClass({
Modal.createDialog(ErrorDialog, {
title: "Failed to invite user",
description: ((err && err.message) ? err.message : "Operation failed"),
button: _t("OK"),
});
return null;
})
Expand All @@ -343,7 +341,6 @@ module.exports = React.createClass({
Modal.createDialog(ErrorDialog, {
title: "Failed to invite",
description: ((err && err.message) ? err.message : "Operation failed"),
button: _t("OK"),
});
return null;
})
Expand Down Expand Up @@ -403,7 +400,6 @@ module.exports = React.createClass({
Modal.createDialog(ErrorDialog, {
title: "Failed to invite the following users to the " + room.name + " room:",
description: errorList.join(", "),
button: _t("OK"),
});
}
return addrs;
Expand Down
10 changes: 7 additions & 3 deletions src/components/views/dialogs/ErrorDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ limitations under the License.

import React from 'react';
import sdk from '../../../index';
import { _t } from '../../../languageHandler';

export default React.createClass({
displayName: 'ErrorDialog',
Expand All @@ -44,6 +45,9 @@ export default React.createClass({
getDefaultProps: function() {
return {
focus: true,
title: null,
description: null,
button: null,
};
},

Expand All @@ -57,13 +61,13 @@ export default React.createClass({
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
return (
<BaseDialog className="mx_ErrorDialog" onFinished={this.props.onFinished}
title={this.props.title}>
title={this.props.title || _t('Error')}>
<div className="mx_Dialog_content">
{this.props.description}
{this.props.description || _t('An error has occurred.')}
</div>
<div className="mx_Dialog_buttons">
<button ref="button" className="mx_Dialog_primary" onClick={this.props.onFinished}>
{this.props.button}
{this.props.button || _t('OK')}
</button>
</div>
</BaseDialog>
Expand Down
3 changes: 2 additions & 1 deletion src/components/views/dialogs/InteractiveAuthDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import Matrix from 'matrix-js-sdk';
import React from 'react';

import sdk from '../../../index';
import { _t } from '../../../languageHandler';

import AccessibleButton from '../elements/AccessibleButton';

Expand Down Expand Up @@ -99,7 +100,7 @@ export default React.createClass({
return (
<BaseDialog className="mx_InteractiveAuthDialog"
onFinished={this.props.onFinished}
title={this.state.authError ? 'Error' : this.props.title}
title={this.state.authError ? 'Error' : (this.props.title || _t('Authentication'))}
>
{content}
</BaseDialog>
Expand Down
5 changes: 3 additions & 2 deletions src/components/views/dialogs/NeedToRegisterDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ limitations under the License.
import React from 'react';
import dis from '../../../dispatcher';
import sdk from '../../../index';
import { _t } from '../../../languageHandler';

module.exports = React.createClass({
displayName: 'NeedToRegisterDialog',
Expand All @@ -52,10 +53,10 @@ module.exports = React.createClass({
return (
<BaseDialog className="mx_NeedToRegisterDialog"
onFinished={this.props.onFinished}
title={this.props.title}
title={this.props.title || _t('Registration required')}
>
<div className="mx_Dialog_content">
{this.props.description}
{this.props.description || _t('A registered account is required for this action')}
</div>
<div className="mx_Dialog_buttons">
<button className="mx_Dialog_primary" onClick={this.props.onFinished} autoFocus={true}>
Expand Down
Loading

0 comments on commit 443ab1a

Please sign in to comment.