From 7f3d01888b574537474f030f8597f3fb97bd6e48 Mon Sep 17 00:00:00 2001 From: Jonas Metzener Date: Tue, 30 Jul 2024 10:29:23 +0200 Subject: [PATCH] chore(deprecation): fix unsafe components for embroider --- packages/analytics/addon/components/ca-field-form.hbs | 2 +- packages/analytics/addon/components/ca-field-form.js | 3 +++ packages/analytics/addon/components/ca-filter-modal.hbs | 6 +----- packages/analytics/addon/components/ca-filter-modal.js | 3 +++ .../integration/components/cfb-form-editor/question-test.js | 3 +++ .../form/tests/integration/components/cf-content-test.js | 6 +++++- packages/form/tests/integration/helpers/get-widget-test.js | 2 ++ 7 files changed, 18 insertions(+), 7 deletions(-) diff --git a/packages/analytics/addon/components/ca-field-form.hbs b/packages/analytics/addon/components/ca-field-form.hbs index bc66df7b3..cee124d32 100644 --- a/packages/analytics/addon/components/ca-field-form.hbs +++ b/packages/analytics/addon/components/ca-field-form.hbs @@ -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) diff --git a/packages/analytics/addon/components/ca-field-form.js b/packages/analytics/addon/components/ca-field-form.js index 0114fea18..20600232f 100644 --- a/packages/analytics/addon/components/ca-field-form.js +++ b/packages/analytics/addon/components/ca-field-form.js @@ -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"; @@ -28,6 +29,8 @@ export default class CaFieldFormComponent extends Component { @enqueueTask saveField = saveAnalyticsField; + toggleComponent = CaToggleSwitchComponent; + constructor(...args) { super(...args); this.field = Changeset( diff --git a/packages/analytics/addon/components/ca-filter-modal.hbs b/packages/analytics/addon/components/ca-filter-modal.hbs index 6aa53cce0..7ca6c8e1e 100644 --- a/packages/analytics/addon/components/ca-filter-modal.hbs +++ b/packages/analytics/addon/components/ca-filter-modal.hbs @@ -69,8 +69,4 @@ /> -{{yield - (component - (ensure-safe-component "uk-button") onClick=(fn (mut this.visible) true) - ) -}} \ No newline at end of file +{{yield (component this.buttonComponent onClick=(fn (mut this.visible) true))}} \ No newline at end of file diff --git a/packages/analytics/addon/components/ca-filter-modal.js b/packages/analytics/addon/components/ca-filter-modal.js index a4ccf40c1..7c3bf1866 100644 --- a/packages/analytics/addon/components/ca-filter-modal.js +++ b/packages/analytics/addon/components/ca-filter-modal.js @@ -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"; @@ -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 ?? []; diff --git a/packages/form-builder/tests/integration/components/cfb-form-editor/question-test.js b/packages/form-builder/tests/integration/components/cfb-form-editor/question-test.js index b883b58a2..bed03ee82 100644 --- a/packages/form-builder/tests/integration/components/cfb-form-editor/question-test.js +++ b/packages/form-builder/tests/integration/components/cfb-form-editor/question-test.js @@ -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"; @@ -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``); diff --git a/packages/form/tests/integration/components/cf-content-test.js b/packages/form/tests/integration/components/cf-content-test.js index f04ab369e..143c067de 100644 --- a/packages/form/tests/integration/components/cf-content-test.js +++ b/packages/form/tests/integration/components/cf-content-test.js @@ -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) { @@ -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``); diff --git a/packages/form/tests/integration/helpers/get-widget-test.js b/packages/form/tests/integration/helpers/get-widget-test.js index 23f68aae6..711e8b8c1 100644 --- a/packages/form/tests/integration/helpers/get-widget-test.js +++ b/packages/form/tests/integration/helpers/get-widget-test.js @@ -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 @@ -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