Skip to content

Commit c2bc438

Browse files
committed
feat: support to duplicate favorites
Close #30
1 parent bd9d1c9 commit c2bc438

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

client/components/main/Main/ConnectionSelector/Config.jsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,18 @@ class Config extends React.Component {
5555
this.setProp(property, value);
5656
}
5757

58+
duplicate() {
59+
if (this.props.favorite) {
60+
const data = Object.assign(this.props.favorite.toJS(), this.state.data.toJS());
61+
delete data.key;
62+
this.props.onDuplicate(data);
63+
} else {
64+
const data = this.state.data.toJS();
65+
data.name = 'Quick Connect'
66+
this.props.onDuplicate(data);
67+
}
68+
}
69+
5870
save() {
5971
if (this.props.favorite && this.state.changed) {
6072
this.props.onSave(this.state.data.toJS());
@@ -141,6 +153,11 @@ class Config extends React.Component {
141153
</div>
142154
</div>
143155
<div className="nt-button-group nt-button-group--pull-right" style={ { width: 500, margin: '10px auto 0' } }>
156+
<button className="nt-button" style={
157+
{ float: 'left' }
158+
} onClick={() => {
159+
this.duplicate();
160+
}}>{ this.props.favorite ? 'Duplicate' : 'Add to Favorite' }</button>
144161
<button className="nt-button" style={ { display: this.state.changed ? 'inline-block' : 'none' } } onClick={() => {
145162
this.save();
146163
}}>Save Changes</button>

client/components/main/Main/ConnectionSelector/index.jsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ class ConnectionSelector extends React.Component {
3434
onSave={(data) => {
3535
store.dispatch(actions('updateFavorite', { key: selectedFavorite.get('key'), data }));
3636
}}
37+
onDuplicate={(data) => {
38+
store.dispatch(actions('addFavorite', data, () => {}));
39+
}}
3740
/>
3841
</div>
3942
</div>;

0 commit comments

Comments
 (0)