Skip to content

Commit 2a55eb0

Browse files
committed
refactor(test-results-bar): move tab logic into pane component
Remove the TopSection component and inline its tab rendering directly inside the Pane template. Move the tabs getter and handleTabClick action from TopSection.ts to pane.ts. This simplifies the test results bar by consolidating tab-related logic and markup, reducing component indirection and improving maintainability.
1 parent 30a4e94 commit 2a55eb0

File tree

4 files changed

+35
-62
lines changed

4 files changed

+35
-62
lines changed
Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
<div ...attributes>
2-
<CoursePage::TestResultsBar::TopSection
3-
@activeTabSlug={{@activeTabSlug}}
4-
@onActiveTabSlugChange={{@onActiveTabSlugChange}}
5-
@availableTabSlugs={{@availableTabSlugs}}
6-
class="mt-3 mb-3"
7-
/>
2+
<ul class="flex items-center gap-2 overflow-x-auto mt-3 mb-3">
3+
{{#each this.tabs as |tab|}}
4+
<TabHeader
5+
@size="small"
6+
@icon={{tab.icon}}
7+
@text={{tab.title}}
8+
@isActive={{eq tab.slug @activeTabSlug}}
9+
{{on "click" (fn this.handleTabClick tab)}}
10+
/>
11+
{{/each}}
12+
</ul>
813

914
{{yield}}
1015
</div>

app/components/course-page/test-results-bar/pane.ts

Lines changed: 24 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

34
interface Signature {
@@ -14,7 +15,29 @@ interface Signature {
1415
};
1516
}
1617

17-
export default class Pane extends Component<Signature> {}
18+
export default class Pane extends Component<Signature> {
19+
get tabs() {
20+
const allTabs = [
21+
{
22+
slug: 'logs',
23+
title: 'Logs',
24+
icon: 'terminal',
25+
},
26+
{
27+
slug: 'autofix',
28+
title: 'AI Hints',
29+
icon: 'sparkles',
30+
},
31+
];
32+
33+
return allTabs.filter((tab) => this.args.availableTabSlugs.includes(tab.slug));
34+
}
35+
36+
@action
37+
handleTabClick(tab: { slug: string }) {
38+
this.args.onActiveTabSlugChange(tab.slug);
39+
}
40+
}
1841

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

app/components/course-page/test-results-bar/top-section.hbs

Lines changed: 0 additions & 13 deletions
This file was deleted.

app/components/course-page/test-results-bar/top-section.ts

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)