Skip to content

Commit 7aa7ea7

Browse files
authored
Merge pull request #809 from geneukum/update-table-of-contents-component-to-glimmer
Update table of contents component to glimmer
2 parents 5d71de4 + 3c4bb40 commit 7aa7ea7

File tree

5 files changed

+70
-78
lines changed

5 files changed

+70
-78
lines changed

app/components/table-of-contents.hbs

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<ol class='toc-level-0'>
2+
<li class='toc-level-0'>
3+
<a {{action 'toggle' 'modules'}} href='#' data-test-toc-title='packages'>Packages</a>
4+
<ol class='toc-level-1 modules selected'>
5+
{{#each @moduleIDs as |moduleID|}}
6+
7+
{{#if (not-eq moduleID '@ember/object/computed')}}
8+
<li class='toc-level-1' data-test-module={{moduleID}}>
9+
<LinkTo @route='project-version.modules.module' @models={{array @version moduleID}}>{{moduleID}}</LinkTo>
10+
</li>
11+
{{/if}}
12+
13+
{{/each}}
14+
</ol>
15+
</li>
16+
17+
{{#if @isShowingNamespaces}}
18+
<li class='toc-level-0'>
19+
<a {{action 'toggle' 'namespaces'}} href='#' data-test-toc-title='namespaces'>Namespaces</a>
20+
<ol class='toc-level-1 namespaces selected'>
21+
{{#each @namespaceIDs as |namespaceID|}}
22+
<li class='toc-level-1' data-test-namespace={{namespaceID}}>
23+
<LinkTo @route='project-version.namespaces.namespace' @models={{array @version namespaceID}}>{{namespaceID}}</LinkTo>
24+
</li>
25+
{{/each}}
26+
</ol>
27+
</li>
28+
{{/if}}
29+
30+
<li class='toc-level-0'>
31+
<a {{action 'toggle' 'classes'}} href='#' data-test-toc-title='classes'>Classes</a>
32+
<ol class='toc-level-1 classes selected'>
33+
{{#each @classesIDs as |classID|}}
34+
<li class='toc-level-1' data-test-class={{classID}}>
35+
<LinkTo @route='project-version.classes.class' @models={{array @version classID}}>{{classID}}</LinkTo>
36+
</li>
37+
{{/each}}
38+
</ol>
39+
</li>
40+
</ol>
41+
<label class='toc-private-toggle'>
42+
<Input @type='checkbox' @checked={{@showPrivateClasses}} class='private-deprecated-toggle' />
43+
Show Private / Deprecated
44+
</label>

app/components/table-of-contents.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { action } from '@ember/object';
2-
import Component from '@ember/component';
2+
import Component from '@glimmer/component';
33

44
export default class TableOfContents extends Component {
55
@action

app/templates/components/table-of-contents.hbs

-44
This file was deleted.

app/templates/project-version.hbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
</PowerSelect>
2929
</div>
3030

31-
<TableOfContents @projectId={{this.model.project.id}} @version={{this.urlVersion}} @classesIDs={{this.shownClassesIDs}} @moduleIDs={{this.shownModuleIDs}} @namespaceIDs={{this.shownNamespaceIDs}} @showPrivateClasses={{this.showPrivateClasses}} @isShowingNamespaces={{version-lt this.selectedProjectVersion.compactVersion "2.16"}} />
31+
<TableOfContents @version={{this.urlVersion}} @classesIDs={{this.shownClassesIDs}} @moduleIDs={{this.shownModuleIDs}} @namespaceIDs={{this.shownNamespaceIDs}} @showPrivateClasses={{this.showPrivateClasses}} @isShowingNamespaces={{version-lt this.selectedProjectVersion.compactVersion "2.16"}} />
3232
</aside>
3333
<section class="content">
3434
{{outlet}}

tests/integration/components/table-of-contents-test.js

+24-32
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,16 @@ module('Integration | Component | table of contents', function (hooks) {
1212

1313
test('it renders', async function (assert) {
1414
// Set any properties with this.set('myProperty', 'value');
15-
this.set('projectId', 'Ember');
1615
this.set('emberVersion', '2.4.3');
1716
this.set('classesIDs', CLASSES);
1817

1918
await render(hbs`
20-
{{
21-
table-of-contents showPrivateClasses=true
22-
projectid=projectId
23-
version=emberVersion
24-
classesIDs=classesIDs
25-
isShowingNamespaces=true
26-
}}
19+
<TableOfContents
20+
@showPrivateClasses={{true}}
21+
@version={{this.emberVersion}}
22+
@classesIDs={{this.classesIDs}}
23+
@isShowingNamespaces={{true}}
24+
/>
2725
`);
2826

2927
const contentTitle = document.querySelector(
@@ -41,18 +39,16 @@ module('Integration | Component | table of contents', function (hooks) {
4139

4240
test('Starts with underlying content visible', async function (assert) {
4341
// Set any properties with this.set('myProperty', 'value');
44-
this.set('projectId', 'Ember');
4542
this.set('emberVersion', '2.4.3');
4643
this.set('moduleIDs', MODULES);
4744

4845
await render(hbs`
49-
{{
50-
table-of-contents showPrivateClasses=true
51-
projectid=projectId
52-
version=emberVersion
53-
moduleIDs=moduleIDs
54-
isShowingNamespaces=true
55-
}}
46+
<TableOfContents
47+
@showPrivateClasses={{true}}
48+
@version={{this.emberVersion}}
49+
@moduleIDs={{this.moduleIDs}}
50+
@isShowingNamespaces={{true}}
51+
/>
5652
`);
5753

5854
const contentReference = '.toc-level-1';
@@ -73,18 +69,16 @@ module('Integration | Component | table of contents', function (hooks) {
7369

7470
test('Underlying content hides once clicked', async function (assert) {
7571
// Set any properties with this.set('myProperty', 'value');
76-
this.set('projectId', 'Ember');
7772
this.set('emberVersion', '2.4.3');
7873
this.set('moduleIDs', MODULES);
7974

8075
await render(hbs`
81-
{{
82-
table-of-contents showPrivateClasses=true
83-
projectid=projectId
84-
version=emberVersion
85-
moduleIDs=moduleIDs
86-
isShowingNamespaces=true
87-
}}
76+
<TableOfContents
77+
@showPrivateClasses={{true}}
78+
@version={{this.emberVersion}}
79+
@moduleIDs={{this.moduleIDs}}
80+
@isShowingNamespaces={{true}}
81+
/>
8882
`);
8983

9084
const contentTitle = document.querySelector(
@@ -109,18 +103,16 @@ module('Integration | Component | table of contents', function (hooks) {
109103

110104
test('Underlying content should be visible after 2 clicks', async function (assert) {
111105
// Set any properties with this.set('myProperty', 'value');
112-
this.set('projectId', 'Ember');
113106
this.set('emberVersion', '2.4.3');
114107
this.set('moduleIDs', MODULES);
115108

116109
await render(hbs`
117-
{{
118-
table-of-contents showPrivateClasses=true
119-
projectid=projectId
120-
version=emberVersion
121-
moduleIDs=moduleIDs
122-
isShowingNamespaces=true
123-
}}
110+
<TableOfContents
111+
@showPrivateClasses={{true}}
112+
@version={{this.emberVersion}}
113+
@moduleIDs={{this.moduleIDs}}
114+
@isShowingNamespaces={{true}}
115+
/>
124116
`);
125117

126118
const titleButton = document.querySelector(

0 commit comments

Comments
 (0)