Skip to content

Commit f1866a1

Browse files
committed
Handle more lints, modernize a component and some tests
1 parent 9c4a14e commit f1866a1

14 files changed

Lines changed: 249 additions & 285 deletions

File tree

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
{{yield this.filteredData}}
1+
<div class="api-index-filter">
2+
{{yield this.filteredData}}
3+
</div>

app/components/api-index-filter.js

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
/* eslint-disable ember/no-computed-properties-in-native-classes */
2-
import { classNames } from '@ember-decorators/component';
3-
import { computed } from '@ember/object';
4-
import Component from '@ember/component';
1+
import Component from '@glimmer/component';
52
import sortBy from 'lodash.sortby';
63

7-
const filterDataComputedParams =
8-
'filterData.{showInherited,showProtected,showPrivate,showDeprecated}';
9-
104
/**
115
* @typedef Args
126
* @property {object} model
@@ -21,44 +15,41 @@ const filterDataComputedParams =
2115
/**
2216
* @extends Component<{ Args: Args, Blocks: Blocks }>
2317
*/
24-
@classNames('api-index-filter')
2518
export default class ApiIndexFilter extends Component {
26-
@computed('model.methods.[]', filterDataComputedParams)
2719
get filteredMethods() {
2820
return this.filterItems('methods');
2921
}
3022

31-
@computed('model.events.[]', filterDataComputedParams)
3223
get filteredEvents() {
3324
return this.filterItems('events');
3425
}
3526

36-
@computed('model.properties.[]', filterDataComputedParams)
3727
get filteredProperties() {
3828
return this.filterItems('properties');
3929
}
4030

4131
filterItems(itemType) {
4232
let items =
43-
this.model[itemType] === undefined ? [] : this.model[`${itemType}`];
44-
if (!this.filterData.showInherited) {
33+
this.args.model[itemType] === undefined
34+
? []
35+
: this.args.model[`${itemType}`];
36+
if (!this.args.filterData.showInherited) {
4537
items = items.filter((item) => item.inherited !== true);
4638
}
47-
if (!this.filterData.showProtected) {
39+
if (!this.args.filterData.showProtected) {
4840
items = items.filter((item) => item.access !== 'protected');
4941
}
50-
if (!this.filterData.showPrivate) {
42+
if (!this.args.filterData.showPrivate) {
5143
items = items.filter((item) => item.access !== 'private');
5244
}
53-
if (!this.filterData.showDeprecated) {
45+
if (!this.args.filterData.showDeprecated) {
5446
items = items.filter((item) => item.deprecated !== true);
5547
}
5648

5749
let sortedItems = sortBy(items, (item) => item.name);
5850
return this.filterMultipleInheritance(sortedItems);
5951
}
6052

61-
@computed('filteredMethods', 'filteredProperties', 'filteredEvents')
6253
get filteredData() {
6354
return {
6455
methods: this.filteredMethods,
@@ -103,8 +94,8 @@ export default class ApiIndexFilter extends Component {
10394
* @method findMostLocal
10495
*/
10596
findMostLocal(currentItem, nextItem) {
106-
let currentScope = this.model.file;
107-
let parentClassScope = this.model.get('parentClass').get('file');
97+
let currentScope = this.args.model.file;
98+
let parentClassScope = this.args.model.parentClass.get('file');
10899
if (currentScope === currentItem.file) {
109100
// if the item belongs to the class, keep it
110101
return currentItem;

app/components/api-search.gjs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@ import { on } from '@ember/modifier';
88
import Search from './search';
99

1010
const SearchResultGroupHeader = <template>
11-
<div class='search-results--group-header' ...attributes>
11+
<div class="search-results--group-header" ...attributes>
1212
{{yield}}
1313
</div>
1414
</template>;
1515

1616
const SearchResultLinkContents = <template>
17-
<span class='screen-reader-text'>{{@groupName}}</span>
17+
<span class="screen-reader-text">{{@groupName}}</span>
1818
{{htmlSafe @result._highlightResult.hierarchy.lvl2.value}}
1919
{{! Do these ever display in API Docs? }}
2020
{{#if @result._highlightResult.hierarchy.lvl3}}
21-
<span aria-hidden='true'> › </span>
21+
<span aria-hidden="true"> › </span>
2222
{{htmlSafe @result._highlightResult.hierarchy.lvl3.value}}
2323
{{/if}}
2424
{{#if @result._highlightResult.hierarchy.lvl4}}
25-
<span aria-hidden='true'> › </span>
25+
<span aria-hidden="true"> › </span>
2626
{{htmlSafe @result._highlightResult.hierarchy.lvl4.value}}
2727
{{/if}}
2828
</template>;
@@ -54,23 +54,23 @@ const SearchResult = class SearchResult extends Component {
5454
};
5555

5656
<template>
57-
<div class='search-results--result'>
58-
<div class='search-results--subcategory-column' aria-hidden='true'>
57+
<div class="search-results--result">
58+
<div class="search-results--subcategory-column" aria-hidden="true">
5959
{{#if (eq @groupPosition 0)}}
6060
{{@groupName}}
6161
{{/if}}
6262
</div>
63-
<div class='search-results--content'>
63+
<div class="search-results--content">
6464
{{#if @result.static}}
6565
<LinkTo
66-
@route='project-version.functions.function'
66+
@route="project-version.functions.function"
6767
@models={{array
6868
this.module
6969
this.version
7070
@result.class
7171
@result.name
7272
}}
73-
{{on 'click' @closeMenu}}
73+
{{on "click" @closeMenu}}
7474
data-test-search-result
7575
>
7676
<SearchResultLinkContents
@@ -79,7 +79,7 @@ const SearchResult = class SearchResult extends Component {
7979
/>
8080
</LinkTo>
8181
{{else}}
82-
<a href='{{this.urlForClass @result}}' data-test-search-result>
82+
<a href="{{this.urlForClass @result}}" data-test-search-result>
8383
<SearchResultLinkContents
8484
@result={{@result}}
8585
@groupName={{@groupName}}
@@ -141,7 +141,7 @@ const SearchResults = class SearchBox extends Component {
141141

142142
<template>
143143
{{#each-in this.groupedResults as |lvl0section _lvl0results|}}
144-
<SearchResultGroupHeader aria-hidden='true'>
144+
<SearchResultGroupHeader aria-hidden="true">
145145
{{lvl0section}}
146146
</SearchResultGroupHeader>
147147

app/components/scroll-to-top-button.gjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ function scrollToTopOfPageOnClick() {
2424

2525
<template>
2626
<button
27-
type='button'
27+
type="button"
2828
{{showOnScroll}}
29-
{{on 'click' scrollToTopOfPageOnClick}}
30-
class='scroll-to-top'
31-
alt='Scroll to top'
29+
{{on "click" scrollToTopOfPageOnClick}}
30+
class="scroll-to-top"
31+
alt="Scroll to top"
3232
></button>
3333
</template>

app/components/search.gjs

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -138,52 +138,52 @@ export default class Search extends Component {
138138

139139
<template>
140140
<div
141-
class='search-wrapper'
141+
class="search-wrapper"
142142
{{closeOnFocusOutside this.closeMenu.perform}}
143143
{{closeOnEscape this.closeMenu.perform this.isOpen}}
144144
{{closeOnClickOutside this.closeMenu.perform}}
145145
...attributes
146146
>
147147
<form
148-
role='search'
149-
{{on 'submit' this.submitSearch}}
148+
role="search"
149+
{{on "submit" this.submitSearch}}
150150
data-test-search-form
151151
>
152152
<label
153-
for='{{this.searchInputId}}'
154-
class='screen-reader-text'
153+
for="{{this.searchInputId}}"
154+
class="screen-reader-text"
155155
data-test-search-label
156156
>
157-
{{yield to='searchInputScreenReaderLabel'}}
157+
{{yield to="searchInputScreenReaderLabel"}}
158158
</label>
159159
<input
160-
class='search-input'
161-
id='{{this.searchInputId}}'
162-
type='search'
163-
{{on 'input' this.search.perform}}
164-
{{on 'focus' this.onfocus}}
165-
autocomplete='off'
166-
autocorrect='off'
167-
autocapitalize='off'
160+
class="search-input"
161+
id="{{this.searchInputId}}"
162+
type="search"
163+
{{on "input" this.search.perform}}
164+
{{on "focus" this.onfocus}}
165+
autocomplete="off"
166+
autocorrect="off"
167+
autocapitalize="off"
168168
spellcheck={{false}}
169-
placeholder='Search'
169+
placeholder="Search"
170170
aria-controls={{if this.isOpen this.resultsId}}
171171
aria-owns={{if this.isOpen this.resultsId}}
172-
aria-expanded={{if this.isOpen 'true' 'false'}}
172+
aria-expanded={{if this.isOpen "true" "false"}}
173173
data-test-search-input
174174
/>
175175
</form>
176176
{{#if this.isOpen}}
177177
<div
178-
id='{{this.resultsId}}'
179-
class='search-results'
180-
aria-label='Search Results'
178+
id="{{this.resultsId}}"
179+
class="search-results"
180+
aria-label="Search Results"
181181
data-test-search-dropdown
182182
>
183183
<div
184-
class='screen-reader-text'
185-
aria-live='polite'
186-
aria-atomic='true'
184+
class="screen-reader-text"
185+
aria-live="polite"
186+
aria-atomic="true"
187187
data-test-screen-reader
188188
>
189189
{{#if this.noResults}}
@@ -194,38 +194,38 @@ export default class Search extends Component {
194194
{{/if}}
195195
</div>
196196
{{#if this.searchService.search.isRunning}}
197-
<div class='search-results--searching'>
197+
<div class="search-results--searching">
198198
Searching...
199199
</div>
200200
{{else if this.noResults}}
201-
<div class='search-results--no-results' data-test-search-no-results>
201+
<div class="search-results--no-results" data-test-search-no-results>
202202
No Results Found.
203203
<p>Try searching the
204204
<a
205-
href='https://www.emberjs.com/deprecations/'
206-
target='_deprecations'
205+
href="https://www.emberjs.com/deprecations/"
206+
target="_deprecations"
207207
>deprecations guide</a>.</p>
208208
</div>
209209
{{else if this.queryIsPresent}}
210210
{{yield
211211
this.searchService.results
212212
this.closeMenu.perform
213-
to='results'
213+
to="results"
214214
}}
215215
{{else}}
216-
<div class='search-results--instructions'>
217-
{{yield to='instructions'}}
216+
<div class="search-results--instructions">
217+
{{yield to="instructions"}}
218218
</div>
219219
{{/if}}
220-
<div class='powered-by-algolia'>
220+
<div class="powered-by-algolia">
221221
<a
222-
href='https://www.algolia.com/'
223-
target='_blank'
224-
rel='noopener noreferrer'
222+
href="https://www.algolia.com/"
223+
target="_blank"
224+
rel="noopener noreferrer"
225225
>
226226
<img
227-
src='/assets/images/search-by-algolia.svg'
228-
alt='Search Powered by Algolia'
227+
src="/assets/images/search-by-algolia.svg"
228+
alt="Search Powered by Algolia"
229229
/>
230230
</a>
231231
</div>

app/controllers/project-version.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ export default class ProjectVersionController extends Controller {
7171
}
7272

7373
getRelationshipIDs(relationship) {
74-
// eslint-disable-next-line ember/classic-decorator-no-classic-methods
75-
const projectId = this.get('model.project.id');
74+
const projectId = this.model.project.id;
7675
const classes = this.model.hasMany(relationship);
7776
const sorted = A(classes.ids()).sort();
7877
//ids come in as ember-2.16.0-@ember/object/promise-proxy-mixin or ember-4.12.0-alpha.23-@ember/object/promise-proxy-mixin

app/controllers/project-version/classes/class.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,24 +58,22 @@ export default class ClassController extends Controller {
5858
@computed('legacyModuleMappings.mappings', 'model.{module,name}')
5959
get hasImportExample() {
6060
return this.legacyModuleMappings.hasClassMapping(
61-
this.get('model.name'),
62-
this.get('model.module'),
61+
this.model.name,
62+
this.model.module,
6363
);
6464
}
6565

6666
@computed('legacyModulemappings.mappings', 'model.{module,name}')
6767
get module() {
6868
return this.legacyModuleMappings.getModule(
69-
this.get('model.name'),
70-
this.get('model.module'),
69+
this.model.name,
70+
this.model.module,
7171
);
7272
}
7373

7474
@computed('metaStore.availableProjectVersions', 'model.project.id')
7575
get allVersions() {
76-
return this.get('metaStore.availableProjectVersions')[
77-
this.get('model.project.id')
78-
];
76+
return this.metaStore.availableProjectVersions[this.model.project.id];
7977
}
8078

8179
get parentName() {
@@ -84,6 +82,6 @@ export default class ClassController extends Controller {
8482

8583
@action
8684
updateFilter(filter) {
87-
this.toggleProperty(`filterData.${filter}`);
85+
this.filterData[filter] = !this.filterData[filter];
8886
}
8987
}

app/controllers/project-version/index.js

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

0 commit comments

Comments
 (0)