Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change create db interface to radio buttons #1363

Merged
merged 1 commit into from
Aug 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions app/addons/databases/__tests__/components.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

// 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
Expand Down Expand Up @@ -37,6 +38,13 @@ describe('AddDatabaseWidget', () => {
sinon.assert.calledWith(Actions.createNewDatabase, 'my-db');
});

it('creates a non-partitioned database', () => {
const el = mount(<Views.AddDatabaseWidget showPartitionedOption={true}/>);
el.setState({databaseName: 'my-db', partitionedSelected: false});
el.instance().onAddDatabase();
sinon.assert.calledWith(Actions.createNewDatabase, 'my-db', false);
});

it('creates a partitioned database', () => {
const el = mount(<Views.AddDatabaseWidget showPartitionedOption={true}/>);
el.setState({databaseName: 'my-db', partitionedSelected: true});
Expand Down
32 changes: 23 additions & 9 deletions app/addons/databases/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ class AddDatabaseWidget extends React.Component {
this.state = {
isPromptVisible: false,
databaseName: '',
partitionedSelected: undefined
partitionedSelected: false
};

this.onTrayToggle = this.onTrayToggle.bind(this);
Expand Down Expand Up @@ -374,7 +374,7 @@ class AddDatabaseWidget extends React.Component {
}
const partitionedDbHelp = this.props.partitionedDbHelpText ? (
<Accordion className='partitioned-db-help'>
<AccordionItem title='What is a Partitioned Database?'>
<AccordionItem title='Which should I chose?'>
<p dangerouslySetInnerHTML={{__html: this.props.partitionedDbHelpText}} />
</AccordionItem>
</Accordion>
Expand All @@ -385,13 +385,26 @@ class AddDatabaseWidget extends React.Component {
Partitioning
</label>
<div className='partitioned-db-options'>
<input
id="partitioned-db"
type="checkbox"
checked={this.state.partitionedSelected === true}
onChange={this.onTogglePartitioned}
/>
<label htmlFor="partitioned-db">Partitioned</label>
<form>
<label htmlFor="non-partitioned-option">
<input
id="non-partitioned-option"
type="radio"
checked={this.state.partitionedSelected === false}
onChange={this.onTogglePartitioned}
/>
Non-partitioned - recommended for most workloads
</label>
<label htmlFor="partitioned-option">
<input
id="partitioned-option"
type="radio"
checked={this.state.partitionedSelected === true}
onChange={this.onTogglePartitioned}
/>
Partitioned
</label>
</form>
</div>
{partitionedDbHelp}
</div>
Expand Down Expand Up @@ -561,3 +574,4 @@ export default {
JumpToDatabaseWidget: JumpToDatabaseWidget,
DatabasePagination: DatabasePagination
};

Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

// 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
Expand Down Expand Up @@ -51,10 +52,11 @@ module.exports = {
.clickWhenVisible('.add-new-database-btn')
.waitForElementVisible('#js-new-database-name', waitTime, false)
.setValue('#js-new-database-name', [newDatabaseName])
.clickWhenVisible('#partitioned-option', waitTime, false)
.clickWhenVisible('#js-create-database', waitTime, false)
.waitForElementNotPresent('.new-database-tray', waitTime, false)
.checkForDatabaseCreated(newDatabaseName, waitTime)
.url(baseUrl + '/#/_all_dbs')
.url(baseUrl + '/_all_dbs')
.waitForElementVisible('html', waitTime, false)
.getText('html', function (result) {
var data = result.value,
Expand All @@ -80,6 +82,7 @@ module.exports = {
.clickWhenVisible('.add-new-database-btn')
.waitForElementVisible('#js-new-database-name', waitTime, false)
.setValue('#js-new-database-name', [invalidDatabaseName])
.clickWhenVisible('#partitioned-option', waitTime, false)
.clickWhenVisible('#js-create-database', waitTime, false)
.waitForElementVisible('.Toastify__toast-container .Toastify__toast--error', waitTime, false)
.url(baseUrl + '/_all_dbs')
Expand All @@ -94,3 +97,4 @@ module.exports = {
.end();
}
};