Skip to content

Commit 32eee5e

Browse files
authored
Merge pull request #2795 from codecrafters-io/pk-branch-7
feat: add download button to copy prompt file contents
2 parents 0813f20 + b80433c commit 32eee5e

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

app/components/course-admin/code-example-page/evaluation-card/prompt-tab.hbs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
<TertiaryButton class="mb-4" {{on "click" this.handleCopyPromptButtonClick}}>
2+
Copy prompt
3+
</TertiaryButton>
4+
15
<div class="bg-gray-800 border border-gray-700 rounded overflow-y-auto relative flex-grow p-3">
26
{{#if @evaluation.promptFileContents}}
37
<pre class="font-mono text-xs text-white whitespace-pre-wrap"><code>{{ansi-to-html @evaluation.promptFileContents}}</code></pre>

app/components/course-admin/code-example-page/evaluation-card/prompt-tab.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { action } from '@ember/object';
12
import Component from '@glimmer/component';
23
import type CommunitySolutionEvaluationModel from 'codecrafters-frontend/models/community-solution-evaluation';
34

@@ -9,7 +10,16 @@ export interface Signature {
910
};
1011
}
1112

12-
export default class PromptTabComponent extends Component<Signature> {}
13+
export default class PromptTabComponent extends Component<Signature> {
14+
@action
15+
handleCopyPromptButtonClick() {
16+
if (this.args.evaluation.promptFileContents) {
17+
navigator.clipboard.writeText(this.args.evaluation.promptFileContents);
18+
} else {
19+
alert('Error, contact us at [email protected] if this keeps happening!');
20+
}
21+
}
22+
}
1323

1424
declare module '@glint/environment-ember-loose/registry' {
1525
export default interface Registry {

0 commit comments

Comments
 (0)