Skip to content

Commit 895790c

Browse files
anehxStephanH90
authored andcommitted
fix(config): remove usage of importSync for global component overrides
Closes #1215 Closes #1190 Closes #915 BREAKING CHANGE: This changes the the way that global overrides for `ember-validated-form` components are configured. For instructions on how to migrate, check the [migration to v8 guide](https://docs.adfinis.com/ember-validated-form/docs/migration-v8).
1 parent 7aa01b9 commit 895790c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+517
-752
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
- name: Lint
3131
run: pnpm lint
3232
- name: Run Tests
33-
run: pnpm ember try:each --skip-cleanup
33+
run: pnpm test:ember
3434

3535
floating:
3636
name: "Floating Dependencies"
@@ -47,7 +47,7 @@ jobs:
4747
- name: Install Dependencies
4848
run: pnpm install --no-lockfile
4949
- name: Run Tests
50-
run: pnpm ember try:each --skip-cleanup
50+
run: pnpm test:ember
5151

5252
try-scenarios:
5353
name: ${{ matrix.try-scenario }}
@@ -78,6 +78,4 @@ jobs:
7878
- name: Install Dependencies
7979
run: pnpm install --frozen-lockfile
8080
- name: Run Tests
81-
run: ./node_modules/.bin/ember try:each --skip-cleanup
82-
env:
83-
EMBER_SCENARIO: ${{ matrix.try-scenario }}
81+
run: ./node_modules/.bin/ember try:one ${{ matrix.try-scenario }}

CONTRIBUTING.md

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,9 @@
1313

1414
## Running tests
1515

16-
Since `ember-validated-form` uses build time configuration, there are various
17-
test scenarios which can't be tested in the same run as the build changes each
18-
time. The following scenarios exist and contain tests:
19-
20-
- `CUSTOM_COMPONENTS`, tests custom default components
21-
22-
In order to be sure that the written code works, the developer needs to make
23-
sure that each scenario succeeds. For that, `ember-try` was configured
24-
accordingly to test each of those scenarios:
25-
26-
- `ember try:each` – Runs the test suite on the current Ember version
27-
- `TEST_SCENARIO=[...] ember test --server` – Runs the test suite with the given scenario in "watch mode"
28-
- `EMBER_SCENARIO=[...] ember try:each` – Runs the test suite against multiple Ember versions
16+
- `pnpm test` – Runs the test suite on the current Ember version
17+
- `pnpm test:ember -- --server` – Runs the test suite in "watch mode"
18+
- `pnpm test:ember-compatibility` – Runs the test suite against multiple Ember versions
2919

3020
## Running the dummy application
3121

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
{{#if (has-block)}}
2-
<this.buttonComponent
3-
@onClick={{this.click}}
4-
@loading={{this.loading}}
5-
@disabled={{or @disabled this.loading}}
6-
@label={{@label}}
7-
@type={{@type}}
8-
...attributes
9-
>{{yield}}</this.buttonComponent>
10-
{{else}}
11-
<this.buttonComponent
12-
@onClick={{this.click}}
13-
@loading={{this.loading}}
14-
@disabled={{or @disabled this.loading}}
15-
@label={{@label}}
16-
@type={{@type}}
17-
...attributes
18-
/>
19-
{{/if}}
1+
{{#let
2+
(component
3+
(ensure-safe-component
4+
(or @buttonComponent (component "validated-button/button"))
5+
)
6+
onClick=this.click
7+
loading=this.loading
8+
disabled=(or @disabled this.loading)
9+
label=@label
10+
type=@type
11+
)
12+
as |ButtonComponent|
13+
}}
14+
{{#if (has-block)}}
15+
<ButtonComponent ...attributes>{{yield}}</ButtonComponent>
16+
{{else}}
17+
<ButtonComponent ...attributes />
18+
{{/if}}
19+
{{/let}}

addon/components/validated-button.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,11 @@ import Component from "@glimmer/component";
44
import { tracked } from "@glimmer/tracking";
55
import { resolve } from "rsvp";
66

7-
import passedOrDefault from "ember-validated-form/passed-or-default";
8-
97
const ON_CLICK = "on-click";
108
const ON_INVALID_CLICK = "on-invalid-click";
119
export default class ValidatedButtonComponent extends Component {
1210
@tracked _loading;
1311

14-
@passedOrDefault("button") buttonComponent;
15-
1612
get loading() {
1713
return this.args.loading || this._loading;
1814
}
Lines changed: 88 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,95 @@
1-
{{#if (has-block)}}
2-
<this.labelComponent
3-
@label={{@label}}
4-
@required={{this.required}}
5-
@isValid={{this.isValid}}
6-
@isInvalid={{this.isInvalid}}
7-
@inputId={{this.inputId}}
8-
/>
9-
10-
{{yield
11-
(hash
12-
value=this._val
13-
update=this.update
14-
setDirty=this.setDirty
15-
model=@model
16-
name=@name
17-
inputId=this.inputId
18-
isValid=this.isValid
19-
isInvalid=this.isInvalid
1+
{{#let
2+
(component
3+
(ensure-safe-component
4+
(or @labelComponent (component "validated-input/label"))
205
)
21-
}}
22-
23-
{{#if @hint}}
24-
<this.hintComponent @hint={{@hint}} id={{this.hintId}} />
25-
{{/if}}
6+
label=@label
7+
required=this.required
8+
isValid=this.isValid
9+
isInvalid=this.isInvalid
10+
inputId=this.inputId
11+
)
12+
(component
13+
(ensure-safe-component
14+
(or @errorComponent (component "validated-input/error"))
15+
)
16+
errors=this.errors
17+
id=this.errorId
18+
)
19+
(component
20+
(ensure-safe-component
21+
(or @hintComponent (component "validated-input/hint"))
22+
)
23+
hint=@hint
24+
id=this.hintId
25+
)
26+
as |LabelComponent ErrorComponent HintComponent|
27+
}}
28+
{{#if (has-block)}}
29+
<LabelComponent />
2630

27-
{{#if (and this.showValidity this.errors)}}
28-
<this.errorComponent @errors={{this.errors}} id={{this.errorId}} />
29-
{{/if}}
30-
{{else}}
31-
<this.renderComponent
32-
@type={{this.type}}
33-
@value={{this._val}}
34-
@inputId={{this.inputId}}
35-
@options={{@options}}
36-
@name={{@name}}
37-
@inputName={{@inputName}}
38-
@disabled={{@disabled}}
39-
@autofocus={{@autofocus}}
40-
@autocomplete={{@autocomplete}}
41-
@rows={{@rows}}
42-
@cols={{@cols}}
43-
@model={{@model}}
44-
@isValid={{this.isValid}}
45-
@isInvalid={{this.isInvalid}}
46-
@placeholder={{@placeholder}}
47-
@class={{@class}}
48-
@prompt={{@prompt}}
49-
@promptIsSelectable={{@promptIsSelectable}}
50-
@optionLabelPath={{@optionLabelPath}}
51-
@optionValuePath={{@optionValuePath}}
52-
@optionTargetPath={{@optionTargetPath}}
53-
@multiple={{@multiple}}
54-
@update={{this.update}}
55-
@setDirty={{this.setDirty}}
56-
@submitted={{@submitted}}
57-
@labelComponent={{component
58-
(ensure-safe-component this.labelComponent)
59-
label=@label
60-
required=@required
61-
isValid=this.isValid
62-
isInvalid=this.isInvalid
63-
inputId=this.inputId
64-
}}
65-
@hintComponent={{if
66-
@hint
67-
(component
68-
(ensure-safe-component this.hintComponent) hint=@hint id=this.hintId
31+
{{yield
32+
(hash
33+
value=this._val
34+
update=this.update
35+
setDirty=this.setDirty
36+
model=@model
37+
name=@name
38+
inputId=this.inputId
39+
isValid=this.isValid
40+
isInvalid=this.isInvalid
6941
)
7042
}}
71-
@errorComponent={{if
72-
(and this.showValidity this.errors)
43+
44+
{{#if @hint}}
45+
<HintComponent />
46+
{{/if}}
47+
48+
{{#if (and this.showValidity this.errors)}}
49+
<ErrorComponent />
50+
{{/if}}
51+
{{else}}
52+
{{#let
7353
(component
74-
(ensure-safe-component this.errorComponent)
75-
errors=this.errors
76-
id=this.errorId
54+
(ensure-safe-component
55+
(or @renderComponent (component "validated-input/render"))
56+
)
57+
type=this.type
58+
value=this._val
59+
inputId=this.inputId
60+
options=@options
61+
name=@name
62+
inputName=@inputName
63+
disabled=@disabled
64+
autofocus=@autofocus
65+
autocomplete=@autocomplete
66+
rows=@rows
67+
cols=@cols
68+
model=@model
69+
isValid=this.isValid
70+
isInvalid=this.isInvalid
71+
placeholder=@placeholder
72+
class=@class
73+
prompt=@prompt
74+
promptIsSelectable=@promptIsSelectable
75+
optionLabelPath=@optionLabelPath
76+
optionValuePath=@optionValuePath
77+
optionTargetPath=@optionTargetPath
78+
multiple=@multiple
79+
update=this.update
80+
setDirty=this.setDirty
81+
submitted=@submitted
82+
labelComponent=LabelComponent
83+
hintComponent=(if @hint HintComponent)
84+
errorComponent=(if (and this.showValidity this.errors) ErrorComponent)
7785
)
86+
as |RenderComponent|
7887
}}
79-
aria-invalid={{if this.isInvalid "true"}}
80-
aria-describedby={{if this.isInvalid this.errorId this.hintId}}
81-
...attributes
82-
/>
83-
{{/if}}
88+
<RenderComponent
89+
aria-invalid={{if this.isInvalid "true"}}
90+
aria-describedby={{if this.isInvalid this.errorId this.hintId}}
91+
...attributes
92+
/>
93+
{{/let}}
94+
{{/if}}
95+
{{/let}}

addon/components/validated-input.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import { isEmpty } from "@ember/utils";
44
import Component from "@glimmer/component";
55
import { tracked } from "@glimmer/tracking";
66

7-
import passedOrDefault from "ember-validated-form/passed-or-default";
8-
97
/**
108
* This component wraps form inputs.
119
*
@@ -35,11 +33,6 @@ export default class ValidatedInputComponent extends Component {
3533
@tracked type;
3634
@tracked validateBeforeSubmit;
3735

38-
@passedOrDefault("error") errorComponent;
39-
@passedOrDefault("hint") hintComponent;
40-
@passedOrDefault("label") labelComponent;
41-
@passedOrDefault("render") renderComponent;
42-
4336
constructor(...args) {
4437
super(...args);
4538

0 commit comments

Comments
 (0)