Skip to content

Commit

Permalink
UI - disable JSON toggle when data is not only strings (#4913)
Browse files Browse the repository at this point in the history
* disable JSON toggle when data is not only strings
* add tests
  • Loading branch information
meirish authored Jul 13, 2018
1 parent 558fbc8 commit bd9ba94
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ui/app/templates/components/secret-edit.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,16 @@
<div class="level-right is-marginless">
<div class="field is-horizontal is-flex-end is-single-line">
<div class="control is-flex">
<input data-test-secret-json-toggle=true id="json" type="checkbox" name="json" class="switch is-rounded is-success is-small" checked={{showAdvancedMode}} onchange={{action "toggleAdvanced" value="target.checked"}} />
<input
data-test-secret-json-toggle=true
id="json"
type="checkbox"
name="json"
class="switch is-rounded is-success is-small"
checked={{showAdvancedMode}}
onchange={{action "toggleAdvanced" value="target.checked"}}
disabled={{and (eq mode 'show') secretDataIsAdvanced}}
/>
<label for="json">JSON</label>
</div>
{{#if (and (not-eq mode 'create') (or capabilities.canUpdate capabilities.canDelete))}}
Expand Down
34 changes: 34 additions & 0 deletions ui/tests/integration/components/secret-edit-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';

moduleForComponent('secret-edit', 'Integration | Component | secret edit', {
integration: true,
});

test('it disables JSON toggle in show mode when is an advanced format', function(assert) {
this.set('mode', 'show');
this.set('key', {
secretData: {
int: 2,
null: null,
float: 1.234,
},
});

this.render(hbs`{{secret-edit mode=mode key=key }}`);
assert.dom('[data-test-secret-json-toggle]').isDisabled();
});

test('it does JSON toggle in show mode when is', function(assert) {
this.set('mode', 'show');
this.set('key', {
secretData: {
int: '2',
null: 'null',
float: '1.234',
},
});

this.render(hbs`{{secret-edit mode=mode key=key }}`);
assert.dom('[data-test-secret-json-toggle]').isNotDisabled();
});

0 comments on commit bd9ba94

Please sign in to comment.