Skip to content

Commit

Permalink
feat!: upgrade to ember v5
Browse files Browse the repository at this point in the history
- set `inverse` & `async` on models
- upgraded `ember-cli`, `ember-data` and `ember-source` to `^5.0.0`
- use [fixed version](miragejs/ember-cli-mirage#2444) of `ember-cli-mirage`
  • Loading branch information
c0rydoras committed Oct 23, 2023
1 parent 3a6f697 commit e43fae1
Show file tree
Hide file tree
Showing 43 changed files with 1,869 additions and 1,313 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/frontend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Install Node
uses: actions/setup-node@v3
with:
node-version: 14.x
node-version: 16
cache: yarn
cache-dependency-path: ember/yarn.lock
- name: Install Dependencies
Expand All @@ -40,7 +40,7 @@ jobs:
- name: Install Node
uses: actions/setup-node@v3
with:
node-version: 14.x
node-version: 16
cache: yarn
cache-dependency-path: ember/yarn.lock
- name: Install Dependencies
Expand Down
12 changes: 0 additions & 12 deletions ember/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,25 +1,13 @@
# unconventional js
/blueprints/*/files/
/vendor/

# compiled output
/dist/
/tmp/

# dependencies
/bower_components/
/node_modules/

# misc
/coverage/
!.*
.*/
.eslintcache

# ember-try
/.node_modules.ember-try/
/bower.json.ember-try
/npm-shrinkwrap.json.ember-try
/package.json.ember-try
/package-lock.json.ember-try
/yarn.lock.ember-try
2 changes: 1 addition & 1 deletion ember/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ module.exports = {
settings: {
'import/internal-regex': '^outdated/',
},
extends: '@adfinis/eslint-config/ember-app',
extends: ['@adfinis/eslint-config/ember-app'],
};
8 changes: 0 additions & 8 deletions ember/.gitignore
Original file line number Diff line number Diff line change
@@ -1,28 +1,20 @@
# See https://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/dist/
/tmp/

# dependencies
/bower_components/
/node_modules/

# misc
/.env*
/.pnp*
/.sass-cache
/.eslintcache
/connect.lock
/coverage/
/libpeerconnection.log
/npm-debug.log*
/testem.log
/yarn-error.log

# ember-try
/.node_modules.ember-try/
/bower.json.ember-try
/npm-shrinkwrap.json.ember-try
/package.json.ember-try
/package-lock.json.ember-try
Expand Down
14 changes: 1 addition & 13 deletions ember/.prettierignore
Original file line number Diff line number Diff line change
@@ -1,25 +1,13 @@
# unconventional js
/blueprints/*/files/
/vendor/

# compiled output
/dist/
/tmp/

# dependencies
/bower_components/
/node_modules/

# misc
/coverage/
!.*
.eslintcache
.lint-todo/
.*/

# ember-try
/.node_modules.ember-try/
/bower.json.ember-try
/npm-shrinkwrap.json.ember-try
/package.json.ember-try
/package-lock.json.ember-try
/yarn.lock.ember-try
9 changes: 8 additions & 1 deletion ember/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
'use strict';

module.exports = {
singleQuote: true,
overrides: [
{
files: '*.{js,ts}',
options: {
singleQuote: true,
},
},
],
};
8 changes: 8 additions & 0 deletions ember/.stylelintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# unconventional files
/blueprints/*/files/

# compiled output
/dist/

# addons
/.node_modules.ember-try/
9 changes: 9 additions & 0 deletions ember/.stylelintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

module.exports = {
plugins: ['stylelint-prettier'],
extends: ['stylelint-prettier/recommended', 'stylelint-config-standard-scss'],
rules: {
'scss/at-extend-no-missing-placeholder': null,
},
};
2 changes: 1 addition & 1 deletion ember/.watchmanconfig
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"ignore_dirs": ["tmp", "dist"]
"ignore_dirs": ["dist"]
}
8 changes: 8 additions & 0 deletions ember/app/components/maintainer-table/component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Component from '@glimmer/component';

export default class MaintainerTableComponent extends Component {
get maintainers() {
// prevent sort-by helper from using deprecated .toArray
return this.args.maintainers?.slice();
}
}
2 changes: 1 addition & 1 deletion ember/app/components/maintainer-table/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</tr>
</thead>
<tbody>
{{#each (sort-by "isPrimary:desc" @maintainers) as |maintainer|}}
{{#each (sort-by "isPrimary:desc" this.maintainers) as |maintainer|}}
<tr>
<td>
{{#if maintainer.isPrimary}}
Expand Down
2 changes: 1 addition & 1 deletion ember/app/components/project-compact/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ export default class ProjectCompactComponent extends Component {
return stateIconDict[this.args.project.status];
}
get version() {
return this.args.project.versionedDependencies.slice()[0];
return this.args.project.versionedDependencies[0];
}
}
2 changes: 1 addition & 1 deletion ember/app/components/project-detailed/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default class ProjectDetailedComponent extends Component {
`/api/projects/${this.args.project.id}/sync`,
{
method: 'POST',
}
},
);
if (request.ok) {
this.notification.success('Project synced successfully');
Expand Down
32 changes: 13 additions & 19 deletions ember/app/components/project-form/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default class ProjectFormComponent extends Component {

@tracked project = emptyChangeset(
ProjectValidations,
this.args.project ?? this.store.createRecord('project')
this.args.project ?? this.store.createRecord('project'),
);
constructor(...args) {
Expand All @@ -26,14 +26,11 @@ export default class ProjectFormComponent extends Component {
}
}
async initUsers() {
this.maintainers = await this.project.maintainers.slice();
this.project.users = await Promise.all(
this.project.maintainers.map((m) => m.user)
);
this.project.primaryMaintainer = this.maintainers.find(
(m) => m.isPrimary
initUsers() {
this.maintainers = this.project.maintainers;
this.project.users = this.project.maintainers.map((m) => m.user);
this.project.primaryMaintainer = this.maintainers?.find(
(m) => m.isPrimary,
)?.user;
}
Expand All @@ -42,17 +39,13 @@ export default class ProjectFormComponent extends Component {
const project = await this.project.save();
this.maintainers
?.filter(
(m) => !this.project.users.map((u) => u.id).includes(m.user.get('id'))
)
?.filter((m) => !this.project.users.includes(m.user))
.forEach((m) => m.destroyRecord());
this.project.users.forEach((user) => {
const maintainer = this.maintainers?.find(
(m) => m.user.get('id') === user.id
);
const maintainer = this.maintainers?.find((m) => m.user.id === user.id);
if (maintainer) {
maintainer.isPrimary = user === this.primaryMaintainer;
maintainer.save();
maintainer.isPrimary = user.id === this.primaryMaintainer.id;
if (maintainer.hasDirtyAttributes) maintainer.save();
} else {
this.store
.createRecord('maintainer', {
Expand All @@ -74,8 +67,9 @@ export default class ProjectFormComponent extends Component {
get primaryMaintainer() {
return (
this.project.users.find((u) => u === this.project.primaryMaintainer) ??
this.project.users[0]
this.project.users.find(
(u) => u.id === this.project.primaryMaintainer?.id,
) ?? this.project.users[0]
);
}
Expand Down
9 changes: 4 additions & 5 deletions ember/app/components/validated-input/render/component.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { ensureSafeComponent } from '@embroider/util';
import Component from '@glimmer/component';
import getMessages from 'ember-changeset-validations/utils/get-messages';
import PowerSelect from 'ember-power-select/components/power-select';
import PowerSelectMultiple from 'ember-power-select/components/power-select-multiple';

export default class RenderComponent extends Component {
get selectComponent() {
return ensureSafeComponent(
this.args.multiple ? 'power-select-multiple' : 'power-select',
this
);
return this.args.multiple ? PowerSelectMultiple : PowerSelect;
}
get name() {
return getMessages().getDescriptionFor(this.args.name);
Expand Down
4 changes: 2 additions & 2 deletions ember/app/models/maintainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import Model, { attr, belongsTo } from '@ember-data/model';

export default class MaintainerModel extends Model {
@attr isPrimary;
@belongsTo('project') project;
@belongsTo('user') user;
@belongsTo('project', { inverse: 'maintainers', async: true }) project;
@belongsTo('user', { inverse: null, async: false }) user;
}
4 changes: 2 additions & 2 deletions ember/app/models/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ export default class ProjectModel extends Model {
@attr name;
@attr status;
@attr repo;
@hasMany('version') versionedDependencies;
@hasMany('maintainer') maintainers;
@hasMany('version', { inverse: null, async: false }) versionedDependencies;
@hasMany('maintainer', { inverse: 'project', async: false }) maintainers;

@tracked users;
@tracked primaryMaintainer;
Expand Down
2 changes: 1 addition & 1 deletion ember/app/models/release-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default class ReleaseVersionModel extends Model {
@attr status;
@attr latestPatchVersion;
@attr('django-date') endOfLife;
@belongsTo('dependency') dependency;
@belongsTo('dependency', { inverse: null, async: false }) dependency;

get releaseVersion() {
return `${this.majorVersion}.${this.minorVersion}`;
Expand Down
2 changes: 1 addition & 1 deletion ember/app/models/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Model, { attr, belongsTo } from '@ember-data/model';
export default class VersionModel extends Model {
@attr patchVersion;
@attr('django-date') releaseDate;
@belongsTo('releaseVersion') releaseVersion;
@belongsTo('releaseVersion', { inverse: null, async: false }) releaseVersion;

get name() {
return this.releaseVersion.get('dependency.name');
Expand Down
4 changes: 2 additions & 2 deletions ember/app/services/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const CONTENT_TYPE = 'application/vnd.api+json';
const cleanObject = (obj) =>
Object.fromEntries(
// eslint-disable-next-line no-unused-vars
Object.entries(obj).filter(([key, value]) => !isEmpty(value))
Object.entries(obj).filter(([key, value]) => !isEmpty(value)),
);

export default class FetchService extends Service {
Expand Down Expand Up @@ -42,7 +42,7 @@ export default class FetchService extends Service {

// throw an error containing a human readable message
throw new Error(
`Fetch request to URL ${response.url} returned ${response.status} ${response.statusText}:\n\n${body}`
`Fetch request to URL ${response.url} returned ${response.status} ${response.statusText}:\n\n${body}`,
);
}

Expand Down
4 changes: 4 additions & 0 deletions ember/app/styles/_responsive.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
--button-nav-button-padding: 0 10px;
}
}

@media only screen and (min-width: $breakpoint-small) {
:root {
--seperator-margin-bottom: 3px;
Expand All @@ -22,6 +23,7 @@
--detailed-heading-font-size: 1.9rem;
}
}

@media only screen and (min-width: $breakpoint-medium) {
:root {
--navbar-height: 70px;
Expand All @@ -35,6 +37,7 @@
--detailed-heading-font-size: 2.5rem;
}
}

@media only screen and (min-width: $breakpoint-large) {
:root {
--navbar-height: 80px;
Expand All @@ -43,6 +46,7 @@
--title-compact-font-size: 1.3rem;
}
}

/* Content Contaier */
.content-container {
@extend .uk-container;
Expand Down
5 changes: 2 additions & 3 deletions ember/app/styles/_variables.scss
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
$breakpoint-xsmall: 419px;

// uikit-colors
$colors: 'primary', 'danger', 'warning', 'success';
$colors: "primary", "danger", "warning", "success";

// Backgrounds
$ember-power-select-background-color: $form-background;
$ember-power-select-disabled-background-color: $form-disabled-background;
$ember-power-select-multiple-selection-background-color: $form-background;
$ember-power-select-highlighted-background: #5897fb;
$ember-power-select-selected-background: #dddddd;
$ember-power-select-selected-background: #ddd;

// Texts
$ember-power-select-text-color: $form-color;
Expand All @@ -20,7 +20,6 @@ $ember-power-select-focus-border-color: $form-focus-border;
$ember-power-select-default-border: $form-border-width solid $form-border;
$ember-power-select-default-focus-border: $form-border-width solid
$form-focus-border;

$ember-power-select-trigger-border: $ember-power-select-default-border;
$ember-power-select-active-trigger-border: $ember-power-select-default-border;
$ember-power-select-dropdown-border: $ember-power-select-default-border;
Expand Down
1 change: 1 addition & 0 deletions ember/app/styles/app.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* Ember supports plain CSS out of the box. More info: https://cli.emberjs.com/release/advanced-use/stylesheets/ */
Loading

0 comments on commit e43fae1

Please sign in to comment.