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

fix: Default parameter icon #1069

Merged
merged 2 commits into from
Jun 19, 2024
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
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');
});
});