Skip to content

Commit

Permalink
refactor: use embroider (#1283)
Browse files Browse the repository at this point in the history
* refactor: use embroider

* Update pnpm-lock.yaml

* remove ember-css-modules (they don't work w embroider)

* Update pnpm-lock.yaml

* bump qunit dom

* bump ember file upload

* fix nih base case test

* run fix lint

* fix rest of acceptance tests

* one test left

* fix tests
  • Loading branch information
jaredgalanis authored Jul 10, 2024
1 parent 82ab15e commit 6f27814
Show file tree
Hide file tree
Showing 56 changed files with 8,333 additions and 9,026 deletions.
2 changes: 2 additions & 0 deletions app/components/external-repo-review/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { action } from '@ember/object';
import ENV from 'pass-ui/config/environment';

class VisitableRepo {
@tracked visited;
Expand Down Expand Up @@ -47,6 +48,7 @@ export default class ExternalRepoReviewComponent extends Component {
@action
openWeblinkAlert(repo) {
swal({
target: ENV.APP.rootElement,
title: 'Notice!',
text: 'You are being sent to an external site. This will open a new tab.',
showCancelButton: true,
Expand Down
2 changes: 1 addition & 1 deletion app/components/find-journal/index.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{! template-lint-disable no-action }}
<PowerSelect
@triggerClass={{if (eq @journalClass "is-invalid") (local-class "is-invalid") (local-class "is-valid")}}
@triggerClass={{if (eq @journalClass "is-invalid") "is-invalid"}}
@search={{perform this.searchJournals}}
@searchEnabled={{true}}
@selected={{@value}}
Expand Down
2 changes: 1 addition & 1 deletion app/components/grant-link-cell/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
the Grants table to display cells containing grant-related data that should
also link to the grant details page
}}
<LinkTo @route="grants.detail" @model={{@record.grant.id}} local-class="award-number">
<LinkTo @route="grants.detail" @model={{@record.grant.id}} class="award-number">
{{get @record @column.propertyName}}
</LinkTo>
9 changes: 8 additions & 1 deletion app/components/metadata-form/index.hbs
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
<div id="schemaForm" class="alpaca-form form-group" data-test-metadata-form></div>
<div
id="schemaForm"
class="alpaca-form form-group"
data-test-metadata-form
{{did-insert this.setupMetadataForm}}
{{did-update this.setupMetadataForm @schema}}
>
</div>
42 changes: 13 additions & 29 deletions app/components/metadata-form/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
/* eslint-disable ember/no-classic-components, ember/no-classic-classes, ember/require-tagless-components, ember/no-component-lifecycle-hooks, ember/no-get */
import Component from '@ember/component';
import _ from 'lodash';
import { get } from '@ember/object';
import Component from '@glimmer/component';
import stripEmptyArrays from 'pass-ui/util/strip-empty-arrays';
import { action } from '@ember/object';

export default Component.extend({
didRender() {
this._super(...arguments);
const that = this;
const originalForm = get(this, 'schema');
export default class MetadataForm extends Component {
@action
setupMetadataForm() {
const componentContext = this;
const originalForm = this.args.schema;
const newForm = JSON.parse(JSON.stringify(originalForm));
if (!originalForm.options) {
newForm.options = {};
Expand All @@ -20,21 +19,21 @@ export default Component.extend({
title: 'Back',
styles: 'pull-left btn btn-outline-primary',
click() {
that.previousForm(that.stripEmptyArrays(this.getValue()));
componentContext.args.previousForm(stripEmptyArrays(this.getValue()));
},
},
Abort: {
label: 'Cancel',
styles: 'pull-left btn btn-outline-danger ml-2',
click() {
that.cancel();
componentContext.args.cancel();
},
},
Next: {
label: 'Next',
styles: 'pull-right btn btn-primary next',
click() {
that.nextForm(that.stripEmptyArrays(this.getValue()));
componentContext.args.nextForm(stripEmptyArrays(this.getValue()));
},
},
},
Expand All @@ -44,20 +43,5 @@ export default Component.extend({

$('#schemaForm').empty();
$('#schemaForm').alpaca(newForm);
},

/**
* Remove empty array values from a JSON object. Keys that have a value of an empty
* array will be removed. Does not dive into object values.
*
* @param {JSONObject} object
*/
stripEmptyArrays(object) {
Object.keys(object)
.filter((key) => Array.isArray(object[key]) && object[key].length === 0)
.forEach((key) => {
delete object[key];
});
return object;
},
});
}
}
2 changes: 1 addition & 1 deletion app/components/oap-compliance-cell/index.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{#if this.isStalled}}
<div class="text-center">
<p><i local-class="fa-circle" class="fas fa-circle mr-1"></i>
<p><i class="fas fa-circle mr-1"></i>
<span class="test">stalled (<a href="#">?</a>)</span></p>
</div>
{{else}}
Expand Down
2 changes: 2 additions & 0 deletions app/components/submission-action-cell/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { action, get } from '@ember/object';
import { inject as service } from '@ember/service';
import Component from '@glimmer/component';
import swal from 'sweetalert2';
import ENV from 'pass-ui/config/environment';

export default class SubmissionActionCell extends Component {
@service currentUser;
Expand Down Expand Up @@ -32,6 +33,7 @@ export default class SubmissionActionCell extends Component {
@action
deleteSubmission(submission) {
swal({
target: ENV.APP.rootElement,
text: 'Are you sure you want to delete this draft submission? This cannot be undone.',
confirmButtonText: 'Delete',
confirmButtonColor: '#DC3545',
Expand Down
8 changes: 4 additions & 4 deletions app/components/submission-repo-details/index.hbs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{{! template-lint-disable link-rel-noopener no-curly-component-invocation no-implicit-this }}
<li>
<div class="card float-left col-5 mr-3 mb-0">
<div local-class="sub-status" class="card-body">
<div local-class="card-title" class="row card-title">
<div class="card-body sub-status">
<div class="row card-title">
{{#if @repo.url}}
<a href={{@repo.url}} target="_blank">{{@repo.name}}</a>
{{else}}
Expand All @@ -16,7 +16,7 @@
<div class="col">
{{#if this.tooltip}}
<span class="{{this.status}}" tooltip-position="left" tooltip="{{this.tooltip}}">
<i local-class="deposit-status-icon" class="fas fa-info-circle"></i>
<i class="fas fa-info-circle deposit-status-icon"></i>
{{#if (eq this.status "not-submitted")}}
n&#47;a
{{else}}
Expand All @@ -25,7 +25,7 @@
</span>
{{else}}
<span class="{{this.status}}">
<i local-class="deposit-status-icon" class="fas fa-circle"></i>
<i class="fas fa-circle deposit-status-icon"></i>
{{this.status}}
</span>
{{/if}}
Expand Down
2 changes: 2 additions & 0 deletions app/components/workflow-basics/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { inject as service } from '@ember/service';
import { task, timeout } from 'ember-concurrency';
import { scheduleOnce } from '@ember/runloop';
import { dropTask } from 'ember-concurrency-decorators';
import ENV from 'pass-ui/config/environment';

const DEBOUNCE_MS = 250;

Expand Down Expand Up @@ -197,6 +198,7 @@ export default class WorkflowBasics extends Component {
let hasGrants = get(this, 'submission.grants') && get(this, 'submission.grants.length') > 0;
if (hasGrants) {
let result = swal({
target: ENV.APP.rootElement,
type: 'warning',
title: 'Are you sure?',
html: 'Changing the submitter will also <strong>remove any grants</strong> currently attached to your submission. Are you sure you want to proceed?',
Expand Down
4 changes: 2 additions & 2 deletions app/components/workflow-files/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/* eslint-disable ember/no-computed-properties-in-native-classes, ember/no-get, ember/require-computed-property-dependencies */
import Component from '@glimmer/component';
import { action, get } from '@ember/object';
import { action } from '@ember/object';
import { inject as service } from '@ember/service';
import { task } from 'ember-concurrency-decorators';
import ENV from 'pass-ui/config/environment';
import { tracked } from '@glimmer/tracking';

export default class WorkflowFiles extends Component {
@service store;
Expand Down Expand Up @@ -51,6 +50,7 @@ export default class WorkflowFiles extends Component {
@action
deleteExistingFile(file) {
swal({
target: ENV.APP.rootElement,
title: 'Are you sure?',
text: 'If you delete this file, it will be gone forever.',
type: 'warning',
Expand Down
2 changes: 2 additions & 0 deletions app/components/workflow-metadata/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import _ from 'lodash';
import { inject as service } from '@ember/service';
import swal from 'sweetalert2';
import { task } from 'ember-concurrency-decorators';
import ENV from 'pass-ui/config/environment';

/**
* The schema service is invoked to retrieve appropriate metadata forms.
Expand Down Expand Up @@ -137,6 +138,7 @@ export default class WorkflowMetadata extends Component {
console.log(metadataSchema.getErrors());

swal({
target: ENV.APP.rootElement,
type: 'error',
title: 'Form Validation Error',
html: this.validationErrorMsg(metadataSchema.getErrors()),
Expand Down
16 changes: 8 additions & 8 deletions app/components/workflow-review/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<div class="text-muted">
Please review the information below
</div>
<table local-class="review-step-table" class="table table-responsive-sm table-bordered w-100">
<table id="#review-step-table" class="table table-responsive-sm table-bordered w-100">
<tbody>
{{#if this.mustVisitWeblink}}
<ExternalRepoReview
Expand All @@ -39,7 +39,7 @@
{{/if}}

<tr>
<td local-class="max-width">
<td class="max-width">
Repositories
</td>
<td>
Expand Down Expand Up @@ -95,7 +95,7 @@
Files
</td>
<td>
<table local-class="files-table" class="w-100">
<table class="files-table w-100">
<thead>
<tr>
<th scope="col">File Type</th>
Expand All @@ -115,15 +115,15 @@
<tr>
<td data-label="icon">
{{#if (eq file.mimeType "png")}}
<i local-class="line-height-35 text-gray fa-30" class="fas fa-file-image"></i>
<i class="fas fa-file-image line-height-35 text-gray fa-30"></i>
{{else if (eq file.mimeType "vnd.openxmlformats-officedocument.presentationml.presentation")}}
<i local-class="line-height-35 text-gray fa-30" class="fas fa-file-powerpoint"></i>
<i class="fas fa-file-powerpoint line-height-35 text-gray fa-30"></i>
{{else if (eq file.mimeType "msword")}}
<i local-class="line-height-35 text-gray fa-30" class="fas fa-file-word"></i>
<i class="fas fa-file-word line-height-35 text-gray fa-30"></i>
{{else if (eq file.mimeType "pdf")}}
<i local-class="line-height-35 text-gray fa-30" class="fas fa-file-pdf"></i>
<i class="fas fa-file-pdf line-height-35 text-gray fa-30"></i>
{{else}}
<i local-class="line-height-35 text-gray fa-30" class="far fa-file"></i>
<i class="far fa-file line-height-35 text-gray fa-30"></i>
{{/if}}
</td>
<td class="workflow-review-file-name" data-label="name" data-test-workflow-review-file-name>
Expand Down
6 changes: 6 additions & 0 deletions app/components/workflow-review/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { inject as service } from '@ember/service';
import { task } from 'ember-concurrency-decorators';
import { later } from '@ember/runloop';
import _ from 'lodash';
import ENV from 'pass-ui/config/environment';

/**
* Present the user with a summary of all information known about the current in-progress
Expand Down Expand Up @@ -122,6 +123,7 @@ export default class WorkflowReview extends Component {

const result = yield swal
.mixin({
target: ENV.APP.rootElement,
confirmButtonText: 'Next &rarr;',
input: 'radio',
inputOptions: {
Expand Down Expand Up @@ -168,6 +170,7 @@ export default class WorkflowReview extends Component {
}

const result = yield swal({
target: ENV.APP.rootElement,
title: 'Confirm submission',
html: swalMsg, // eslint-disable-line
confirmButtonText: 'Confirm',
Expand Down Expand Up @@ -213,6 +216,7 @@ export default class WorkflowReview extends Component {
}
});
swal({
target: ENV.APP.rootElement,
title: 'Your submission cannot be submitted.',
html: `You declined to agree to the deposit agreement(s) for ${JSON.stringify(
reposUserDidNotAgreeToDeposit.map((repo) => repo.id),
Expand All @@ -227,6 +231,7 @@ export default class WorkflowReview extends Component {
} else {
// no repositories associated with the submission
swal({
target: ENV.APP.rootElement,
title: 'Your submission cannot be submitted.',
html: 'No repositories are associated with this submission. \n Return to the submission and edit it to include a repository.',
confirmButtonText: 'Ok',
Expand Down Expand Up @@ -260,6 +265,7 @@ export default class WorkflowReview extends Component {
@action
openWeblinkAlert(repo) {
swal({
target: ENV.APP.rootElement,
title: 'Notice!',
text: 'You are being sent to an external site. This will open a new tab.',
showCancelButton: true,
Expand Down
7 changes: 7 additions & 0 deletions app/controllers/submissions/detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ export default class SubmissionsDetail extends Controller {
@action
async openWeblinkAlert(repo) {
let value = await swal({
target: ENV.APP.rootElement,
title: 'Notice!',
text: 'You are being sent to an external site. This will open a new tab.',
showCancelButton: true,
Expand Down Expand Up @@ -334,6 +335,7 @@ export default class SubmissionsDetail extends Controller {

const result = await swal
.mixin({
target: ENV.APP.rootElement,
input: 'checkbox',
inputPlaceholder: "I agree to the above statement on today's date ",
confirmButtonText: 'Next &rarr;',
Expand Down Expand Up @@ -372,6 +374,7 @@ export default class SubmissionsDetail extends Controller {
}

let result = await swal({
target: ENV.APP.rootElement,
title: 'Confirm submission',
html: swalMsg, // eslint-disable-line
confirmButtonText: 'Confirm',
Expand Down Expand Up @@ -409,6 +412,7 @@ export default class SubmissionsDetail extends Controller {
}
});
let result = await swal({
target: ENV.APP.rootElement,
title: 'Your submission cannot be submitted.',
html: `You declined to agree to the deposit agreement(s) for ${JSON.stringify(
reposUserDidNotAgreeToDeposit.map((repo) => repo.id),
Expand All @@ -428,6 +432,7 @@ export default class SubmissionsDetail extends Controller {
} else {
// no repositories associated with the submission
let result = await swal({
target: ENV.APP.rootElement,
title: 'Your submission cannot be submitted.',
html: 'No repositories are associated with this submission. \n You can either (a) cancel the submission or (b) return to the submission and edit it to include a repository.',
confirmButtonText: 'Cancel submission',
Expand All @@ -453,6 +458,7 @@ export default class SubmissionsDetail extends Controller {
}

let result = await swal({
target: ENV.APP.rootElement,
title: 'Are you sure?',
text: 'If you cancel this submission, it will not be able to be resumed.',
confirmButtonText: 'Yes, cancel this submission',
Expand All @@ -471,6 +477,7 @@ export default class SubmissionsDetail extends Controller {
@action
async deleteSubmission(submission) {
let result = await swal({
target: ENV.APP.rootElement,
text: 'Are you sure you want to delete this draft submission? This cannot be undone.',
confirmButtonText: 'Delete',
confirmButtonColor: '#DC3545',
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/submissions/new.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { tracked } from '@glimmer/tracking';
import { action, get, set } from '@ember/object';
import { inject as service } from '@ember/service';
import _ from 'lodash';
import ENV from 'pass-ui/config/environment';

export default class SubmissionsNew extends Controller {
queryParams = ['grant', 'submission', 'covid'];
Expand Down Expand Up @@ -134,6 +135,7 @@ export default class SubmissionsNew extends Controller {
const ignoreList = this.searchHelper;

let result = await swal({
target: ENV.APP.rootElement,
title: 'Discard Draft',
text: "This will abort the current submission and discard progress you've made. This cannot be undone.",
confirmButtonText: 'Abort',
Expand Down
Loading

0 comments on commit 6f27814

Please sign in to comment.