Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,11 @@
data-test-code-editor-toolbar-menu-divider
></div>
{{/if}}
<CopyButton
@text={{@copyText}}
<Hds::Copy::Button
@text='Copy code'
Copy link
Collaborator Author

@hashicc hashicc Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@text is a different argument on Hds::Copy::Button (button text) than the ember-cli-clipboard CopyButton (the text to copy)

@textToCopy={{@copyText}}
@onSuccess={{this.copied}}
class='rose-code-editor-toolbar__copy-button'
data-test-code-editor-toolbar-copy-button
>
<Hds::Icon @name={{this.copyIconType}} @isInline={{true}} />
Copy code
</CopyButton>
/>
</div>
</div>
18 changes: 1 addition & 17 deletions addons/rose/addon/components/rose/code-editor/toolbar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,11 @@
*/

import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { action } from '@ember/object';
import { later } from '@ember/runloop';

export const COPY_ICON_TYPE = 'clipboard-copy';
export const COPIED_ICON_TYPE = 'clipboard-checked';

export default class RoseCodeEditorToolbarComponent extends Component {
@tracked copyIconType = COPY_ICON_TYPE;

@action
copied() {
let { onCopy } = this.args;
let originalIconType = this.copyIconType;

this.copyIconType = COPIED_ICON_TYPE;

if (onCopy) {
onCopy();
}
// eslint-disable-next-line ember/no-runloop
later(() => (this.copyIconType = originalIconType), 1000);
this.args.onCopy?.();
}
}
15 changes: 0 additions & 15 deletions addons/rose/app/styles/rose/components/code-editor/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,4 @@
height: sizing.rems(xl);
}
}

&__copy-button {
border: none;
background-color: inherit;
cursor: pointer;
color: var(--ui-gray-starker-2);
margin-right: sizing.rems(xs);
margin-left: sizing.rems(s);
height: sizing.rems(xl);
white-space: nowrap;

.hds-icon {
vertical-align: top;
}
}
}
2 changes: 1 addition & 1 deletion addons/rose/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
"codemirror": "5.65.7",
"ember-auto-import": "^2.10.0",
"ember-cli-babel": "^8.2.0",
"ember-cli-clipboard": "^1.2.1",
"ember-cli-htmlbars": "^6.3.0",
"ember-cli-sass": "^11.0.1",
"ember-focus-trap": "^1.0.1",
Expand Down Expand Up @@ -87,6 +86,7 @@
"prettier": "^3.3.3",
"qunit": "^2.22.0",
"qunit-dom": "^3.2.1",
"sinon": "^19.0.2",
"stylelint": "^15.11.0",
"stylelint-config-prettier-scss": "^0.0.1",
"stylelint-config-standard-scss": "^11.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { click, render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
import sinon from 'sinon';

module('Integration | Component | rose/code-editor/toolbar', function (hooks) {
setupRenderingTest(hooks);
Expand Down Expand Up @@ -43,6 +44,9 @@ module('Integration | Component | rose/code-editor/toolbar', function (hooks) {
});

test('it calls onCopy callback', async function (assert) {
// `writeText` could fail if the document is not in focus which is common during test runs
sinon.stub(window.navigator.clipboard, 'writeText').resolves();

const onCopy = () => {
this.set('called', true);
};
Expand All @@ -53,8 +57,9 @@ module('Integration | Component | rose/code-editor/toolbar', function (hooks) {
assert.dom(toolbarSelector).isVisible();
assert.dom(copyButtonSelector).isVisible();
assert.dom(menuDividerSelector).doesNotExist();

await click(copyButtonSelector);
assert.true(this.called);

sinon.restore();
});
});
99 changes: 3 additions & 96 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.