Skip to content

Commit

Permalink
chore(deprecation): fix unsafe components for embroider
Browse files Browse the repository at this point in the history
  • Loading branch information
anehx committed Jul 30, 2024
1 parent c756009 commit 7f3d018
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/analytics/addon/components/ca-field-form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@label={{t "caluma.analytics.edit.show-in-output"}}
@required={{true}}
@renderComponent={{component
(ensure-safe-component "ca-toggle-switch")
this.toggleComponent
value=f.model.showOutput
size="small"
onToggle=(mut f.model.showOutput)
Expand Down
3 changes: 3 additions & 0 deletions packages/analytics/addon/components/ca-field-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Changeset } from "ember-changeset";
import lookupValidator from "ember-changeset-validations";
import { enqueueTask } from "ember-concurrency";

import CaToggleSwitchComponent from "@projectcaluma/ember-analytics/components/ca-toggle-switch";
import saveAnalyticsField from "@projectcaluma/ember-analytics/tasks/save-analytics-field";
import FieldValidations from "@projectcaluma/ember-analytics/validations/field";

Expand All @@ -28,6 +29,8 @@ export default class CaFieldFormComponent extends Component {

@enqueueTask saveField = saveAnalyticsField;

toggleComponent = CaToggleSwitchComponent;

constructor(...args) {
super(...args);
this.field = Changeset(
Expand Down
6 changes: 1 addition & 5 deletions packages/analytics/addon/components/ca-filter-modal.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,4 @@
/>
</modal.footer>
</UkModal>
{{yield
(component
(ensure-safe-component "uk-button") onClick=(fn (mut this.visible) true)
)
}}
{{yield (component this.buttonComponent onClick=(fn (mut this.visible) true))}}
3 changes: 3 additions & 0 deletions packages/analytics/addon/components/ca-filter-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
import { queryManager } from "ember-apollo-client";
import { enqueueTask } from "ember-concurrency";
import UkButtonComponent from "ember-uikit/components/uk-button";

import saveAnalyticsField from "@projectcaluma/ember-analytics/tasks/save-analytics-field";

Expand All @@ -18,6 +19,8 @@ export default class CaFilterModalComponent extends Component {

@enqueueTask saveField = saveAnalyticsField;

buttonComponent = UkButtonComponent;

constructor(...args) {
super(...args);
this.filters = this.args.field?.filters ?? [];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { render, fillIn, blur, click, select } from "@ember/test-helpers";
import Component from "@glimmer/component";
import { hbs } from "ember-cli-htmlbars";
import { setupMirage } from "ember-cli-mirage/test-support";
import { setupIntl } from "ember-intl/test-support";
Expand Down Expand Up @@ -675,11 +676,13 @@ module("Integration | Component | cfb-form-editor/question", function (hooks) {
calumaOptions.registerComponentOverride({
label: "a widget override for all types",
component: "dummy-component-1",
componentClass: class extends Component {},
});
calumaOptions.registerComponentOverride({
label: "a widget override for float questions only",
component: "dummy-component-2",
types: ["FloatQuestion"],
componentClass: class extends Component {},
});

await render(hbs`<CfbFormEditor::Question @slug={{null}} />`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { setFlatpickrDate } from "ember-flatpickr/test-support/helpers";
import { setupIntl } from "ember-intl/test-support";
import { module, test } from "qunit";

import DummyOneComponent from "dummy/components/dummy-one";
import { setupRenderingTest } from "dummy/tests/helpers";

module("Integration | Component | cf-content", function (hooks) {
Expand Down Expand Up @@ -288,7 +289,10 @@ module("Integration | Component | cf-content", function (hooks) {

test("it allows for component overrides", async function (assert) {
const options = this.owner.lookup("service:calumaOptions");
options.registerComponentOverride({ component: "dummy-one" });
options.registerComponentOverride({
component: "dummy-one",
componentClass: DummyOneComponent,
});

await render(hbs`<CfContent @documentId={{this.document.id}} />`);

Expand Down
2 changes: 2 additions & 0 deletions packages/form/tests/integration/helpers/get-widget-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ module("Integration | Helper | get-widget", function (hooks) {
this.owner.lookup("service:calumaOptions").registerComponentOverride({
label: "Some Component",
component: "some-component",
componentClass: this.SomeComponent,
});

await render(hbs`{{component
Expand Down Expand Up @@ -73,6 +74,7 @@ module("Integration | Helper | get-widget", function (hooks) {
this.owner.lookup("service:calumaOptions").registerComponentOverride({
label: "Some Component",
component: "some-component",
componentClass: this.SomeComponent,
});

await render(hbs`{{component
Expand Down

0 comments on commit 7f3d018

Please sign in to comment.