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 @@ -3,7 +3,7 @@ import Component from '@glimmer/component';
import IconCircle from '../../icons/icon-circle.gts';

interface Signature {
Element: SVGElement;
Element: SVGSVGElement;
}

// eslint-disable-next-line ember/no-empty-glimmer-component-classes
Expand Down
5 changes: 4 additions & 1 deletion packages/boxel-ui/addon/src/components/copy-button/index.gts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ interface Signature {
offset?: number;
placement?: MiddlewareState['placement'];
size?: BoxelButtonSize;
textToCopy: string;
textToCopy: string | null | undefined;
tooltipText?: string;
variant?: BoxelButtonKind;
width?: string;
Expand All @@ -31,6 +31,9 @@ export default class CopyButton extends Component<Signature> {
@tracked private recentlyCopied = false;

@action private async copyToClipboard() {
if (this.args.textToCopy == null) {
return;
}
try {
await navigator.clipboard.writeText(this.args.textToCopy);
this.recentlyCopied = true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import type { TemplateOnlyComponent } from '@ember/component/template-only';
import { hash } from '@ember/helper';

import type Component from '@glimmer/component';

import { CopyButton } from '@cardstack/boxel-ui/components';

import type { CodeData } from '@cardstack/host/lib/formatted-message/utils';
Expand All @@ -11,14 +13,17 @@ import ApplyCodePatchButton, {

import type { ComponentLike } from '@glint/template';

type AsComponentLike<C> =
C extends Component<infer Sig> ? ComponentLike<Sig> : never;

export interface CodeBlockActionsSignature {
Args: {
codeData?: Partial<CodeData>;
};
Blocks: {
default: [
{
copyCode: CopyButton;
copyCode: AsComponentLike<CopyButton>;
applyCodePatch: ComponentLike<ApplyCodePatchButtonSignature>;
},
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,9 @@ class HtmlGroupCodeBlock extends Component<HtmlGroupCodeBlockSignature> {

<codeBlock.actions as |actions|>
<actions.copyCode
@code={{this.extractReplaceCode @codeData.searchReplaceBlock}}
@textToCopy={{this.extractReplaceCode
@codeData.searchReplaceBlock
}}
/>
{{! This is just to show the ✅ icon to signalize that the code patch has been applied }}
<actions.applyCodePatch
Expand Down Expand Up @@ -325,7 +327,9 @@ class HtmlGroupCodeBlock extends Component<HtmlGroupCodeBlockSignature> {
/>

<codeBlock.actions as |actions|>
<actions.copyCode @code={{this.codeDiffResource.modifiedCode}} />
<actions.copyCode
@textToCopy={{this.codeDiffResource.modifiedCode}}
/>

<actions.applyCodePatch
@codeData={{@codeData}}
Expand Down Expand Up @@ -366,7 +370,7 @@ class HtmlGroupCodeBlock extends Component<HtmlGroupCodeBlockSignature> {
{{/if}}
<codeBlock.editor @code={{this.codeForEditor}} />
<codeBlock.actions as |actions|>
<actions.copyCode @code={{@codeData.code}} />
<actions.copyCode @textToCopy={{@codeData.code}} />
</codeBlock.actions>
{{/if}}
</CodeBlock>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export default class NewSessionSettings extends Component<Signature> {
@icon='close'
@variant='ghost'
@size='small'
@label='close new session options'
class='new-session-settings-close-button'
data-test-new-session-settings-close-button
{{on 'click' @onClose}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,23 @@ export default class SkillToggle extends Component<SkillToggleSignature> {
// Title for either skill source: `cardTitle` for a Skill card; for a skill
// markdown file, the title indexed from its first heading, falling back to
// the frontmatter name slug only when the file has no heading.
private get displayTitle(): string | undefined {
let card = this.card as
| {
cardTitle?: string;
title?: string;
name?: string;
frontmatter?: { name?: string };
}
| undefined;
private get displayTitle(): string {
let card = this.card as {
cardTitle?: string;
title?: string;
name?: string;
frontmatter?: { name?: string };
};
if (!card) {
return undefined;
return 'Untitled Skill';
}
return card.cardTitle ?? card.title ?? card.frontmatter?.name ?? card.name;
return (
card.cardTitle ??
card.title ??
card.frontmatter?.name ??
card.name ??
'Untitled Skill'
);
}

private get isCreating() {
Expand Down Expand Up @@ -172,7 +176,7 @@ export default class SkillToggle extends Component<SkillToggleSignature> {
</Pill>
<Switch
class='toggle'
@isEnabled={{@isEnabled}}
@isEnabled={{Boolean @isEnabled}}
@onChange={{@onToggle}}
@label={{this.displayTitle}}
data-test-skill-toggle='{{@cardId}}-{{if @isEnabled "on" "off"}}'
Expand Down
2 changes: 1 addition & 1 deletion packages/host/app/components/host-mode/card.gts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export default class HostModeCard extends Component<Signature> {
<CardContainer
{{this.restoreScroll this.card}}
class={{cn 'host-mode-card' is-primary=@isPrimary}}
displayBoundaries={{@displayBoundaries}}
@displayBoundaries={{@displayBoundaries}}
data-test-host-mode-card-loaded={{bool this.card}}
...attributes
>
Expand Down
2 changes: 1 addition & 1 deletion packages/host/app/components/matrix/register-user.gts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export default class RegisterUser extends Component<Signature> {
data-test-username-field
id='boxel-register-username'
@name='username'
autocomplete='username'
@autocomplete='username'
@state={{this.usernameInputState}}
@value={{this.username}}
@placeholder='Your username'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,7 @@ export default class CodeSubmode extends Component<Signature> {
</ResizablePanel>
{{else}}
<ResizablePanel
@defaultLengthFraction={{this.defaultPanelWidths.emptyCodeModePanel}}
@defaultSize={{this.defaultPanelWidths.emptyCodeModePanel}}
>
<InnerContainer
class='empty-container'
Expand Down
Loading