Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert more components to be Glimmer components #203

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
50c1bce
Convert <AddonNote/> into a template-only Glimmer component
pgengler Oct 31, 2020
806aa35
Remove unused <AddonReviewForm/> component
pgengler Oct 31, 2020
d59d93d
Convert <AddonReview/> component to be a Glimmer component
pgengler Oct 31, 2020
84cfb15
Convert <AddonVersionItem/> to be a tagless Glimmer component
pgengler Oct 31, 2020
3433494
Add ember-concurrency-decorators addon and upgrade eslint-related dep…
pgengler Oct 31, 2020
b66fc7e
Convert <AddonSourceUsages/> to be a Glimmer component
pgengler Oct 31, 2020
f994198
Convert <AddonVersionList/> to be a Glimmer component
pgengler Oct 31, 2020
0e1daee
Convert <ExclusiveButtonGroup/> to be a tagless Glimmer component
pgengler Nov 1, 2020
3583ad1
Convert <ExclusiveButton/> to be a Glimmer component
pgengler Nov 1, 2020
f36e31c
Convert <AdminAddon/> to be a Glimmer component
pgengler Nov 1, 2020
8e50b40
Convert <BuildResultOutput/> to be a Glimmer component
pgengler Nov 1, 2020
f0bad2e
Convert <CategoryChooser/> to be a Glimmer component
pgengler Nov 1, 2020
922b4ec
Convert <CategoryFinder/> to be a Glimmer component
pgengler Nov 1, 2020
8a930b1
Replace <CommaSeparated/> with a new <CommaSeparatedList/> component
pgengler Nov 1, 2020
6e9d5f0
Convert <SvgIcon/>, <OfficialIcon/>, and <DependencyIcon/> to be Glim…
pgengler Nov 1, 2020
02a9b9d
Convert <EmberVersionCompatibilityList/> to be a Glimmer component
pgengler Nov 1, 2020
39b7999
Convert <EmberVersionCompatibility/> to be a Glimmer component
pgengler Nov 1, 2020
04c3026
Convert <EmberVersionItem/> to be a Glimmer component
pgengler Nov 1, 2020
f76b272
Convert <GravatarAvatar/> to be a Glimmer component
pgengler Nov 1, 2020
c48a318
Upgrade ember-cli-babel to 7.23.0
pgengler Nov 1, 2020
94d1b31
Remove fixed template files from template-lint 'pending' config
pgengler Nov 1, 2020
a7aea93
Make new linter failures be warnings, not errors
pgengler Nov 1, 2020
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
7 changes: 6 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ module.exports = {
'ember/avoid-leaking-state-in-ember-objects': 'off',
'ember/closure-actions': 'off',
'ember/use-brace-expansion': 'off',
'ember/no-jquery': 'error'
'ember/no-get': 'warn',
'ember/no-get-with-default': 'warn',
'ember/no-jquery': 'error',
'ember/no-private-routing-service': 'warn',
'ember/require-computed-property-dependencies': 'warn',
'ember/use-ember-data-rfc-395-imports': 'warn'
},
overrides: [
// tests
Expand Down
36 changes: 0 additions & 36 deletions .template-lintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,12 @@

module.exports = {
pending: [
{
"moduleId": "app/components/addon-review-form",
"only": [
"no-action"
]
},
{
"moduleId": "app/components/addon-source-usages",
"only": [
"no-action"
]
},
{
"moduleId": "app/components/addon-version-list",
"only": [
"no-action"
]
},
{
"moduleId": "app/components/admin-addon-review-form",
"only": [
"no-action"
]
},
{
"moduleId": "app/components/admin-addon",
"only": [
"no-action"
]
},
{
"moduleId": "app/components/code-search",
"only": [
Expand All @@ -50,18 +26,6 @@ module.exports = {
"no-action"
]
},
{
"moduleId": "app/components/ember-version-compatibility",
"only": [
"no-action"
]
},
{
"moduleId": "app/components/exclusive-button",
"only": [
"no-action"
]
},
{
"moduleId": "app/components/large-search",
"only": [
Expand Down
6 changes: 4 additions & 2 deletions app/components/addon-note.hbs
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
<legend>Note</legend>
<MarkdownToSanitizedHtml @markdown={{this.content}} @tables={{true}} @ghCodeBlocks={{true}} @tasklists={{true}} @simplifiedAutoLink={{true}} />
<fieldset class="note test-addon-note">
<legend>Note</legend>
<MarkdownToSanitizedHtml @markdown={{@content}} @tables={{true}} @ghCodeBlocks={{true}} @tasklists={{true}} @simplifiedAutoLink={{true}} />
</fieldset>
10 changes: 0 additions & 10 deletions app/components/addon-note.js

This file was deleted.

17 changes: 0 additions & 17 deletions app/components/addon-review-form.hbs

This file was deleted.

Empty file.
40 changes: 21 additions & 19 deletions app/components/addon-review.hbs
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
{{#if this.review}}
<p class="review-date">
Manually reviewed on {{moment-format this.review.createdAt "MMMM Do YYYY" allowEmpty=true}} for version {{this.review.version.version}}
</p>
<ol class="questions">
{{#each this.answeredQuestions as |question|}}
<li class="test-review-question">
<span class="question">{{question.text}}</span>
<span class="answer">{{question.answer}}</span>
</li>
{{/each}}
</ol>
<br>
{{#if this.review.review}}
<h6>Comments</h6>
<fieldset class="test-review-notes">
<MarkdownToHtml @markdown={{this.review.review}} />
</fieldset>
<div>
{{#if @review}}
<p class="review-date">
Manually reviewed on {{moment-format @review.createdAt "MMMM Do YYYY" allowEmpty=true}} for version {{@review.version.version}}
</p>
<ol class="questions">
{{#each this.answeredQuestions as |question|}}
<li class="test-review-question">
<span class="question">{{question.text}}</span>
<span class="answer">{{question.answer}}</span>
</li>
{{/each}}
</ol>
<br>
{{#if @review.review}}
<h6>Comments</h6>
<fieldset class="test-review-notes">
<MarkdownToHtml @markdown={{@review.review}} />
</fieldset>
{{/if}}
{{/if}}
{{/if}}
</div>
8 changes: 2 additions & 6 deletions app/components/addon-review.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import classic from 'ember-classic-decorator';
import { computed } from '@ember/object';
import { isEmpty } from '@ember/utils';
import Component from '@ember/component';
import Component from '@glimmer/component';
import { questions } from '../models/review';

const ANSWER_MAP = {
Expand All @@ -11,11 +9,9 @@ const ANSWER_MAP = {
4: 'Unknown'
};

@classic
export default class AddonReview extends Component {
@computed('review')
get answeredQuestions() {
let review = this.review;
let review = this.args.review;
return questions.filter(function(question) {
return !isEmpty(review.get(question.fieldName));
}).map(function(question) {
Expand Down
12 changes: 6 additions & 6 deletions app/components/addon-source-usages.hbs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<div class="usage-count">
<a href="#" {{action "toggleUsages"}} class="test-usage-count">
<a href="#" {{on "click" this.toggleUsages}} class="test-usage-count">
{{#if this.showUsages}}
{{svg-icon "expand-more"}}
<SvgIcon @icon="expand-more" />
{{else}}
{{svg-icon "chevron-right"}}
<SvgIcon @icon="chevron-right" />
{{/if}}
{{this.count}} {{pluralize this.count "usage"}}
{{@count}} {{pluralize @count "usage"}}
</a>
{{#if this.showUsages}}
{{#if this.usages}}
{{#each this.visibleUsages as |usage|}}
<div class="usage test-usage">
<a class="filename" href="{{clean-repo-url this.addon.repositoryUrl}}/tree/master/{{usage.filename}}#L{{usage.line_number}}">
<a class="filename" href="{{clean-repo-url @addon.repositoryUrl}}/tree/master/{{usage.filename}}#L{{usage.line_number}}">
{{usage.filename}}:{{usage.line_number}}
</a>
{{#each usage.lines as |line|}}
Expand All @@ -20,7 +20,7 @@
</div>
{{/each}}
{{#if this.moreUsages}}
<a href="#" {{action "viewMore"}} class="view-more">
<a href="#" {{on "click" this.viewMore}} class="view-more">
See more usages
</a>
{{/if}}
Expand Down
45 changes: 20 additions & 25 deletions app/components/addon-source-usages.js
Original file line number Diff line number Diff line change
@@ -1,49 +1,44 @@
import classic from 'ember-classic-decorator';
import { action, computed } from '@ember/object';
import { action } from '@ember/object';
import { inject as service } from '@ember/service';
import Component from '@ember/component';
import Component from '@glimmer/component';
import { isEmpty } from '@ember/utils';
import { task } from 'ember-concurrency';
import { dropTask } from 'ember-concurrency-decorators';
import { tracked } from '@glimmer/tracking';

@classic
export default class AddonSourceUsages extends Component {
visibleUsageCount = 25;
showUsages = false;
usages = null;
regex = false;
fileFilter = null;
@tracked showUsages = false;
@tracked usages = null;
@tracked visibleUsageCount = 25;

@service
codeSearch;
@service codeSearch;

@computed('visibleUsageCount', 'usages')
get visibleUsages() {
return this.usages.slice(0, this.visibleUsageCount);
}

@computed('visibleUsageCount', 'usages')
get moreUsages() {
return this.visibleUsageCount < this.get('usages.length');
return this.visibleUsageCount < this.usages.length;
}

@(task(function* () {
let usages = yield this.get('codeSearch.usages').perform(this.get('addon.id'), this.query, this.regex);
this.set('usages', filterByFilePath(usages, this.fileFilter));
}).drop())
fetchUsages;
@dropTask
*fetchUsages() {
let usages = yield this.codeSearch.usages.perform(this.args.addon.id, this.args.query, this.args.regex);
this.usages = filterByFilePath(usages, this.args.fileFilter);
}

@action
toggleUsages() {
this.toggleProperty('showUsages');
toggleUsages(event) {
event.preventDefault();
this.showUsages = !this.showUsages;
if (this.showUsages && this.usages === null) {
this.fetchUsages.perform();
}
}

@action
viewMore() {
let newUsageCount = this.visibleUsageCount + 25;
this.set('visibleUsageCount', newUsageCount);
viewMore(event) {
event.preventDefault();
this.visibleUsageCount = this.visibleUsageCount + 25;
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/components/addon-version-item.hbs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{moment-format this.version.released "YYYY-MMM-DD" allowEmpty=true}} <span class="version-number">{{this.version.version}}</span>
{{moment-format @version.released "YYYY-MMM-DD" allowEmpty=true}} <span class="version-number">{{@version.version}}</span>
7 changes: 0 additions & 7 deletions app/components/addon-version-item.js

This file was deleted.

2 changes: 1 addition & 1 deletion app/components/addon-version-list.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
</li>
{{/each}}
{{#if this.thereAreHiddenVersions}}
<a href="#" {{action "showAllVersions"}}>Show all versions</a>
<a href="#" {{on "click" this.showAllVersions}}>Show all versions</a>
{{/if}}
</ul>
33 changes: 15 additions & 18 deletions app/components/addon-version-list.js
Original file line number Diff line number Diff line change
@@ -1,47 +1,44 @@
import classic from 'ember-classic-decorator';
import { action, computed } from '@ember/object';
import { action } from '@ember/object';
import { inject as service } from '@ember/service';
import { gt } from '@ember/object/computed';
import Component from '@ember/component';
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';

@classic
export default class AddonVersionList extends Component {
showAll = false;
@tracked showAll = false;

@service
emberVersions;

@computed('versions', 'showAll')
get showingVersions() {
if (this.showAll) {
return this.versions;
return this.args.versions;
}
return (this.versions || []).slice(0, 10);
return (this.args.versions || []).slice(0, 10);
}

@computed('emberVersions.versions.[]', 'showingVersions.lastObject')
get emberVersionDataAfterOldestShowingAddonVersion() {
let oldestVersionDate = this.get('showingVersions.lastObject.released');
return this.get('emberVersions.versions').filter(version => version.released > oldestVersionDate);
let oldestVersion = this.showingVersions[this.showingVersions.length - 1];
let oldestVersionDate = oldestVersion ? oldestVersion.released : null;
return this.emberVersions.versions.filter(version => version.released > oldestVersionDate);
}

@computed('emberVersionDataAfterOldestShowingAddonVersion.[]', 'showingVersions.[]')
get versionsWithMeta() {
let versions = this.emberVersionDataAfterOldestShowingAddonVersion.map(version => ({ isEmber: true, version }));
versions = versions.concat(this.showingVersions.map(version => ({ isAddon: true, version })));
return versions.sortBy('version.released').reverse();
}

@gt('versions.length', 10)
moreThan10Versions;
get moreThan10Versions() {
return this.args.versions.length > 10;
}

@computed('moreThan10Versions', 'showAll')
get thereAreHiddenVersions() {
return this.moreThan10Versions && !this.showAll;
}

@action
showAllVersions() {
this.set('showAll', true);
showAllVersions(event) {
event.preventDefault();
this.showAll = true;
}
}
Loading