Skip to content

Commit

Permalink
feat: change partition option to checkbox (#1312)
Browse files Browse the repository at this point in the history
* feat: change partition option to checkbox

Co-authored-by: Jan Lehnardt <[email protected]>
  • Loading branch information
garbados and janl authored Sep 2, 2021
1 parent f0ded17 commit 03491f1
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 27 deletions.
1 change: 1 addition & 0 deletions app/addons/databases/assets/less/databases.less
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
.partitioned-db-options {
display: flex;
align-items: baseline;
padding-top: 1rem;
input {
margin: 0px 10px 0px 0px;
}
Expand Down
30 changes: 6 additions & 24 deletions app/addons/databases/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,7 @@ class AddDatabaseWidget extends React.Component {
this.onKeyUpInInput = this.onKeyUpInInput.bind(this);
this.onChange = this.onChange.bind(this);
this.onAddDatabase = this.onAddDatabase.bind(this);
this.onSetPartitioned = this.onSetPartitioned.bind(this);
this.onSetNotPartitioned = this.onSetNotPartitioned.bind(this);
this.onTogglePartitioned = this.onTogglePartitioned.bind(this);
}

getI18nText(key) {
Expand Down Expand Up @@ -355,14 +354,6 @@ class AddDatabaseWidget extends React.Component {
}

onAddDatabase() {
if (this.props.showPartitionedOption && this.state.partitionedSelected === undefined) {
FauxtonAPI.addNotification({
type: 'error',
msg: 'Please select either Partitioned or Non-partitioned',
clear: true
});
return;
}
const partitioned = this.props.showPartitionedOption ?
this.state.partitionedSelected :
undefined;
Expand All @@ -373,12 +364,8 @@ class AddDatabaseWidget extends React.Component {
);
}

onSetNotPartitioned() {
this.setState({ partitionedSelected: false });
}

onSetPartitioned() {
this.setState({ partitionedSelected: true });
onTogglePartitioned() {
this.setState({ partitionedSelected: !this.state.partitionedSelected });
}

partitionedOption() {
Expand All @@ -400,16 +387,11 @@ class AddDatabaseWidget extends React.Component {
<div className='partitioned-db-options'>
<input
id="partitioned-db"
type="radio"
type="checkbox"
checked={this.state.partitionedSelected === true}
onChange={this.onSetPartitioned} />
onChange={this.onTogglePartitioned}
/>
<label htmlFor="partitioned-db">Partitioned</label>
<input
id="non-partitioned-db"
type="radio"
checked={this.state.partitionedSelected === false}
onChange={this.onSetNotPartitioned} />
<label htmlFor="non-partitioned-db">Non-partitioned</label>
</div>
{partitionedDbHelp}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ module.exports = {
.clickWhenVisible('.add-new-database-btn')
.waitForElementVisible('#js-new-database-name', waitTime, false)
.setValue('#js-new-database-name', [newDatabaseName])
.clickWhenVisible('#non-partitioned-db', waitTime, false)
.clickWhenVisible('#js-create-database', waitTime, false)
.waitForElementNotPresent('.new-database-tray', waitTime, false)
.checkForDatabaseCreated(newDatabaseName, waitTime)
Expand Down Expand Up @@ -81,7 +80,6 @@ module.exports = {
.clickWhenVisible('.add-new-database-btn')
.waitForElementVisible('#js-new-database-name', waitTime, false)
.setValue('#js-new-database-name', [invalidDatabaseName])
.clickWhenVisible('#non-partitioned-db', waitTime, false)
.clickWhenVisible('#js-create-database', waitTime, false)
.waitForElementVisible('.Toastify__toast-container .Toastify__toast--error', waitTime, false)
.url(baseUrl + '/_all_dbs')
Expand Down
2 changes: 1 addition & 1 deletion i18n.json.default.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
"auth-change-password": "Your password has been updated.",
"auth-admin-creation-failed-prefix": "Could not create admin.",
"auth-passwords-not-matching": "Passwords do not match.",
"create-db-partitioned-help": "A partitioned database requires a partition key for every document, where the document _id format is '&lt;partition_key&gt;:&lt;doc_key&gt;'. A partition is a logical grouping of documents. Partition queries are often faster than global ones."
"create-db-partitioned-help": "This is an advanced feature. If you are unsure whether you need a partitioned database, you probably do not. A partitioned database requires a partition key for every document, where the document _id format is '&lt;partition_key&gt;:&lt;doc_key&gt;'. A partition is a logical grouping of documents. Partition queries are often faster than global ones."
}
}

0 comments on commit 03491f1

Please sign in to comment.