Skip to content

Commit

Permalink
fix: Default parameter icon (#1069)
Browse files Browse the repository at this point in the history
  • Loading branch information
minghay authored Jun 19, 2024
1 parent 4fb6e6a commit 80776a8
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 3 deletions.
4 changes: 4 additions & 0 deletions app/components/pipeline/parameters/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
margin-top: auto;
margin-bottom: auto;
padding-left: 0.25rem;

&.fa-exclamation-triangle {
color: colors.$sd-warning;
}
}
}

Expand Down
7 changes: 7 additions & 0 deletions app/components/pipeline/parameters/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@
{{#if parameter.description}}
<FaIcon @icon="question-circle" @title={{parameter.description}}></FaIcon>
{{/if}}
{{#if (and
(not (is-array parameter.defaultValues))
(not (eq parameter.value parameter.defaultValues))
)
}}
<FaIcon @icon="exclamation-triangle" @title="Default value: {{parameter.defaultValues}}"></FaIcon>
{{/if}}
</label>
{{#if (is-array parameter.defaultValues)}}
<div class="dropdown-selection-container">
Expand Down
2 changes: 2 additions & 0 deletions app/components/pipeline/styles.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
@use 'nav/styles' as nav;
@use 'modal/toggle-job/styles' as toggle-job;
@use 'parameters/styles' as parameters;

@mixin styles {
@include nav.styles;
@include toggle-job.styles;
@include parameters.styles;
}
54 changes: 51 additions & 3 deletions tests/integration/components/pipeline/parameters/component-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ module('Integration | Component | pipeline/parameters', function (hooks) {
meta: {
parameters: {
bar: { value: 'barzy' },
foo: { value: 'foozy' },
foo: { value: 'foo' },
job1: { p1: { value: 'abc' }, p2: { value: 'xyz' } }
}
}
},
pipeline: {
parameters: {
bar: ['barbar', 'bazbaz'],
foo: { value: 'foofoo', description: 'awesome' }
foo: { value: 'foo', description: 'awesome' }
}
},
jobs: [
Expand Down Expand Up @@ -90,7 +90,7 @@ module('Integration | Component | pipeline/parameters', function (hooks) {
.hasText('barzy');
assert.dom(parameters[1].querySelector('label')).hasText('foo awesome');
assert.dom(parameters[1].querySelector('label svg')).exists({ count: 1 });
assert.dom(parameters[1].querySelector('input')).hasValue('foozy');
assert.dom(parameters[1].querySelector('input')).hasValue('foo');
});

test('it renders parameters job group expanded', async function (assert) {
Expand Down Expand Up @@ -278,4 +278,52 @@ module('Integration | Component | pipeline/parameters', function (hooks) {
})
);
});

test('it adds icon when input is not equal to default value', async function (assert) {
this.setProperties({
event: {
meta: {
parameters: {
foo: { value: 'foobar' }
}
}
},
pipeline: {
parameters: {
foo: { value: 'foobar' }
}
},
jobs: [],
onUpdateParameters: () => {}
});

await render(
hbs`<Pipeline::Parameters
@action="start"
@event={{this.event}}
@pipeline={{this.pipeline}}
@jobs={{this.jobs}}
@onUpdateParameters={{this.onUpdateParameters}}
/>`
);

assert
.dom(
'.parameter-list.expanded .parameter label svg.fa-exclamation-triangle'
)
.doesNotExist();

await fillIn('.parameter-list.expanded input', 'foofoofoo');

assert
.dom(
'.parameter-list.expanded .parameter label svg.fa-exclamation-triangle'
)
.exists({ count: 1 });
assert
.dom(
'.parameter-list.expanded .parameter label svg.fa-exclamation-triangle title'
)
.hasText('Default value: foobar');
});
});

0 comments on commit 80776a8

Please sign in to comment.