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

Commit

Permalink
add TextSetting to view
Browse files Browse the repository at this point in the history
rename variables

update en translation

fix lint error

Fix message (#1375)

MM-10873 Preserve newlines in mobile view channel headers (#1376)

* MM-10873 Preserve newlines in mobile view channel headers

* Updated test snapshots

add new line

remove comment

remove yarn.lock

fix lint error

Update ids, variable names and descriptions to match server

update en.json with proper descriptions

Update getConfigFromState to allow 0 value for ConnMaxLifetimeMilliseconds

revert package-lock.json to master

Add parseIntNonNegative to allow 0 or larger values to ConnMaxLifetimeMilliseconds

Update order in getConfigFromState and getStateFromConfig

add new line back
  • Loading branch information
Jerry Kurian committed Jun 29, 2018
1 parent bc83528 commit ced2acd
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
13 changes: 13 additions & 0 deletions components/admin_console/admin_settings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,19 @@ export default class AdminSettings extends React.Component {
return n;
};

parseIntNonNegative = (str, defaultValue) => {
const n = parseInt(str, 10);

if (isNaN(n) || n < 0) {
if (defaultValue) {
return defaultValue;
}
return 0;
}

return n;
};

parseIntNonZero = (str, defaultValue) => {
const n = parseInt(str, 10);

Expand Down
23 changes: 22 additions & 1 deletion components/admin_console/database_settings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ export default class DatabaseSettings extends AdminSettings {

getConfigFromState(config) {
// driverName and dataSource are read-only from the UI

config.SqlSettings.MaxIdleConns = this.parseIntNonZero(this.state.maxIdleConns);
config.SqlSettings.MaxOpenConns = this.parseIntNonZero(this.state.maxOpenConns);
config.SqlSettings.AtRestEncryptKey = this.state.atRestEncryptKey;
config.SqlSettings.Trace = this.state.trace;
config.SqlSettings.QueryTimeout = this.parseIntNonZero(this.state.queryTimeout);
config.SqlSettings.ConnMaxLifetimeMilliseconds = this.parseIntNonNegative(this.state.connMaxLifetimeMilliseconds);

return config;
}
Expand All @@ -44,6 +45,7 @@ export default class DatabaseSettings extends AdminSettings {
atRestEncryptKey: config.SqlSettings.AtRestEncryptKey,
trace: config.SqlSettings.Trace,
queryTimeout: config.SqlSettings.QueryTimeout,
connMaxLifetimeMilliseconds: config.SqlSettings.ConnMaxLifetimeMilliseconds,
};
}

Expand Down Expand Up @@ -199,6 +201,25 @@ export default class DatabaseSettings extends AdminSettings {
onChange={this.handleChange}
setByEnv={this.isSetByEnv('SqlSettings.QueryTimeout')}
/>
<TextSetting
id='connMaxLifetimeMilliseconds'
label={
<FormattedMessage
id='admin.sql.connMaxLifetimeTitle'
defaultMessage='Maximum Connection Lifetime:'
/>
}
placeholder={Utils.localizeMessage('admin.sql.connMaxLifetimeExample', 'E.g.: "3600000"')}
helpText={
<FormattedMessage
id='admin.sql.connMaxLifetimeDescription'
defaultMessage='Maximum lifetime for a connection to the database in milliseconds.'
/>
}
value={this.state.connMaxLifetimeMilliseconds}
onChange={this.handleChange}
setByEnv={this.isSetByEnv('SqlSettings.ConnMaxLifetimeMilliseconds')}
/>
<GeneratedSetting
id='atRestEncryptKey'
label={
Expand Down
3 changes: 3 additions & 0 deletions i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1230,6 +1230,9 @@
"admin.sidebar.view_statistics": "Site Statistics",
"admin.sidebar.webrtc": "WebRTC (Beta)",
"admin.sidebarHeader.systemConsole": "System Console",
"admin.sql.connMaxLifetimeDescription": "Maximum lifetime (in milliseconds) for a connection to the database.",
"admin.sql.connMaxLifetimeExample": "E.g.: \"3600000\"",
"admin.sql.connMaxLifetimeTitle": "Maximum Connection Lifetime:",
"admin.sql.dataSource": "Data Source:",
"admin.sql.driverName": "Driver Name:",
"admin.sql.keyDescription": "32-character salt available to encrypt and decrypt sensitive fields in database.",
Expand Down

0 comments on commit ced2acd

Please sign in to comment.