From 78d9df240bb598d30bc94d3cb56e9317a7558706 Mon Sep 17 00:00:00 2001 From: Olympe Lespagnon Date: Tue, 4 Aug 2026 17:00:02 +0200 Subject: [PATCH 1/2] Groundwork: Add OSS::TogglableSection option to remove the switch --- addon/components/o-s-s/togglable-section.hbs | 4 ++- .../o-s-s/togglable-section.stories.js | 32 +++++++++++++++++-- addon/components/o-s-s/togglable-section.ts | 7 +++- tests/dummy/app/templates/index.hbs | 15 +++++++-- .../o-s-s/togglable-section-test.ts | 28 ++++++++++++++++ 5 files changed, 79 insertions(+), 7 deletions(-) diff --git a/addon/components/o-s-s/togglable-section.hbs b/addon/components/o-s-s/togglable-section.hbs index 23d4d6c5b..eeff9b0e9 100644 --- a/addon/components/o-s-s/togglable-section.hbs +++ b/addon/components/o-s-s/togglable-section.hbs @@ -21,7 +21,9 @@ {{#if (and (has-block "header-actions"))}} {{yield to="header-actions"}} {{/if}} - + {{#if this.isSwitchable}} + + {{/if}} {{#if (and (has-block "contents") @toggled)}}
diff --git a/addon/components/o-s-s/togglable-section.stories.js b/addon/components/o-s-s/togglable-section.stories.js index fd1cc269d..94e43b0f9 100644 --- a/addon/components/o-s-s/togglable-section.stories.js +++ b/addon/components/o-s-s/togglable-section.stories.js @@ -75,6 +75,16 @@ export default { type: 'boolean' } }, + switchable: { + description: 'Whether the toggle switch is displayed and the section can be toggled from the header', + table: { + type: { summary: 'boolean' }, + defaultValue: { summary: 'true' } + }, + control: { + type: 'boolean' + } + }, size: { description: 'Adjust the size of the component. Currently available options are `sm` and `md`. Defaults to `md`.', table: { @@ -119,6 +129,7 @@ const defaultArgs = { icon: '', size: undefined, disabled: undefined, + switchable: undefined, onChange: action('onChange') }; @@ -127,7 +138,7 @@ const Template = (args) => ({ + @disabled={{this.disabled}} @size={{this.size}} @switchable={{this.switchable}}> <:contents> Setting content @@ -141,7 +152,7 @@ const WithActionsNamedBlockTemplate = (args) => ({ + @disabled={{this.disabled}} @size={{this.size}} @switchable={{this.switchable}}> <:contents> Setting content @@ -153,8 +164,25 @@ const WithActionsNamedBlockTemplate = (args) => ({ context: args }); +const WithoutToggleTemplate = (args) => ({ + template: hbs` + + <:contents> + Setting content + + + `, + context: args +}); + export const Default = Template.bind({}); Default.args = defaultArgs; export const WithActionsNamedBlock = WithActionsNamedBlockTemplate.bind({}); WithActionsNamedBlock.args = defaultArgs; + +export const WithoutToggle = WithoutToggleTemplate.bind({}); +WithoutToggle.args = defaultArgs; diff --git a/addon/components/o-s-s/togglable-section.ts b/addon/components/o-s-s/togglable-section.ts index 3016ff975..b7f83aa95 100644 --- a/addon/components/o-s-s/togglable-section.ts +++ b/addon/components/o-s-s/togglable-section.ts @@ -5,6 +5,7 @@ import { action } from '@ember/object'; interface CampaignTogglableSectionArgs { title: string; toggled: boolean; + switchable?: boolean; iconUrl?: string; icon?: string; badgeIcon?: string; @@ -27,9 +28,13 @@ export default class CampaignTogglableSection extends Component Togglable section -
-
+
+
- +
+ +
diff --git a/tests/integration/components/o-s-s/togglable-section-test.ts b/tests/integration/components/o-s-s/togglable-section-test.ts index e7a44943b..140c69e27 100644 --- a/tests/integration/components/o-s-s/togglable-section-test.ts +++ b/tests/integration/components/o-s-s/togglable-section-test.ts @@ -176,6 +176,34 @@ module('Integration | Component | o-s-s/togglable-section', function (hooks) { }); }); + module('@Switchable behaviour', () => { + test('If @switchable is not passed, the toggle is rendered', async function (assert) { + await render( + hbs`` + ); + + assert.dom('.upf-toggle').exists(); + }); + + test('If @switchable is false, the toggle is not rendered', async function (assert) { + await render( + hbs`` + ); + + assert.dom('.upf-toggle').doesNotExist(); + }); + + test('If @switchable is false, clicking on the header does not call @onChange', async function (assert) { + this.onChange = sinon.stub(); + await render( + hbs`` + ); + + await click('.inner-header'); + assert.true(this.onChange.notCalled); + }); + }); + test('When `header-actions` named block is passed, the content is rendered in the header', async function (assert) { await render( hbs` From 56849bb7b7bed69954d09a5fced16d16211140d1 Mon Sep 17 00:00:00 2001 From: Olympe Lespagnon <80198185+olxmpe@users.noreply.github.com> Date: Wed, 5 Aug 2026 14:47:50 +0200 Subject: [PATCH 2/2] Update addon/components/o-s-s/togglable-section.ts Co-authored-by: Julien "HolyDeath" Vannier --- addon/components/o-s-s/togglable-section.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addon/components/o-s-s/togglable-section.ts b/addon/components/o-s-s/togglable-section.ts index b7f83aa95..a6cdbe1b0 100644 --- a/addon/components/o-s-s/togglable-section.ts +++ b/addon/components/o-s-s/togglable-section.ts @@ -29,7 +29,7 @@ export default class CampaignTogglableSection extends Component