Skip to content

Commit

Permalink
Merge branch 'release/20.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
fabmiz committed May 26, 2020
2 parents bbfe7fc + aa0c0e1 commit bbf339d
Show file tree
Hide file tree
Showing 133 changed files with 1,125 additions and 697 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- yarn lint:es
- yarn lint:ts
- yarn lint:style
#- yarn lint:template
- yarn lint:template
- yarn test:node-tests
- yarn build:test
script:
Expand Down
19 changes: 18 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [20.4.0] - 2020-05-26
### Changed
- link to institutions
- wording of OSFInstitutions
- config to use `isTruthy`
- draft-registration card component to remove progress-bar

### Added
- newline to "Read more" link
- logging API error messages
- CI template linting
- log API draft-registration submission error

### Fixed
- file links issue on overview page

## [20.3.1] - 2020-03-26
### Fixed
- `active` schemas filter parameter.
Expand Down Expand Up @@ -1576,7 +1592,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Added
- Quick Files

[Unreleased]: https://github.com/CenterForOpenScience/ember-osf-web/compare/20.3.1...develop
[Unreleased]: https://github.com/CenterForOpenScience/ember-osf-web/compare/20.4.0...develop
[20.4.0]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/20.4.0
[20.3.1]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/20.3.1
[20.3.0]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/20.3.0
[20.2.1]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/20.2.1
Expand Down
28 changes: 13 additions & 15 deletions app/application/-components/verify-email-modal/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Toast from 'ember-toastr/services/toast';

import UserEmail from 'ember-osf-web/models/user-email';
import CurrentUser from 'ember-osf-web/services/current-user';
import captureException, { getApiErrorMessage } from 'ember-osf-web/utils/capture-exception';

interface TranslationKeys {
header: string;
Expand Down Expand Up @@ -119,14 +120,24 @@ export default class VerifyEmailModal extends Component {
this.unverifiedEmails.shiftObject();
}

this.showMessage(successMessageLevel, successKey, userEmail);
this.toast[successMessageLevel](
this.intl.t(
this.translationKeys[successKey],
{ email: userEmail.emailAddress, htmlSafe: true },
),
);

// Close the modal and open another one (if needed) because it's confusing for the text to change in place
this.set('shouldShowModal', false);
yield timeout(300);
this.set('shouldShowModal', true);
} catch (e) {
this.showMessage('error', errorKey, userEmail);
const errorMessage = this.intl.t(
this.translationKeys[errorKey],
{ email: userEmail.emailAddress, htmlSafe: true },
);
captureException(e, { errorMessage });
this.toast.error(getApiErrorMessage(e), errorMessage);
throw e;
}
});
Expand All @@ -136,19 +147,6 @@ export default class VerifyEmailModal extends Component {
this.loadEmailsTask.perform();
}

showMessage(
level: MessageLevel,
key: keyof TranslationKeys,
userEmail: UserEmail,
) {
this.toast[level](
this.intl.t(
this.translationKeys[key],
{ email: userEmail.emailAddress, htmlSafe: true },
),
);
}

@action
verify() {
this.verifyTask.perform(EmailActions.Verify);
Expand Down
8 changes: 3 additions & 5 deletions app/application/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,17 @@
{{#unless this.disableHeader}}
{{#if this.theme.isProvider}}
<style>
{{! template-lint-disable bare-strings }}
{{!-- template-lint-disable no-bare-strings --}}
@import url('{{this.theme.stylesheet}}');
{{! template-lint-enable bare-strings }}
{{!-- template-lint-enable no-bare-strings --}}
</style>
<div id='branded-navbar'></div>
{{else}}
<OsfHeader />
{{/if}}
{{/unless}}
{{#if this.shouldShowVerifyEmailModals}}
{{! template-lint-disable no-implicit-this }}
{{application/-components/verify-email-modal}}
{{! template-lint-enable no-implicit-this }}
<Application::-Components::VerifyEmailModal />
{{/if}}
{{!--
NOTE: the global Application__page class is used in registries
Expand Down
13 changes: 9 additions & 4 deletions app/guid-file/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ import { timeout } from 'ember-concurrency';
import { task } from 'ember-concurrency-decorators';
import config from 'ember-get-config';
import Intl from 'ember-intl/services/intl';
import Toast from 'ember-toastr/services/toast';

import mimeTypes from 'ember-osf-web/const/mime-types';
import File from 'ember-osf-web/models/file';
import User from 'ember-osf-web/models/user';
import Analytics from 'ember-osf-web/services/analytics';
import CurrentUser from 'ember-osf-web/services/current-user';
import captureException, { getApiErrorMessage } from 'ember-osf-web/utils/capture-exception';
import pathJoin from 'ember-osf-web/utils/path-join';
import Toast from 'ember-toastr/services/toast';
import $ from 'jquery';
import mime from 'mime-types';

Expand Down Expand Up @@ -141,8 +143,9 @@ export default class GuidFile extends Controller {
const message: string = this.intl.t('file_detail.delete_success');
return this.toast.success(message);
} catch (e) {
const message: string = this.intl.t('file_detail.delete_fail');
return this.toast.error(message);
const errorMessage: string = this.intl.t('file_detail.delete_fail');
captureException(e, { errorMessage });
return this.toast.error(getApiErrorMessage(e), errorMessage);
}
}

Expand All @@ -163,7 +166,9 @@ export default class GuidFile extends Controller {
await this.file.updateContents(text);
return this.toast.success(this.intl.t('file_detail.save_success'));
} catch (e) {
return this.toast.error(this.intl.t('file_detail.save_fail'));
const errorMessage = this.intl.t('file_detail.save_fail');
captureException(e, { errorMessage });
return this.toast.error(getApiErrorMessage(e), errorMessage);
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/guid-file/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
{{/if}}
<div class='btn-group m-l-xs m-t-xs'>
<OsfButton
data-analytics-name={{if (not this.canEdit) 'Download'}}
data-analytics-name={{unless this.canEdit 'Download'}}
data-test-download-button
@bubble={{true}}
@type='primary'
Expand Down
7 changes: 5 additions & 2 deletions app/guid-user/quickfiles/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Node from 'ember-osf-web/models/node';
import User from 'ember-osf-web/models/user';
import Analytics from 'ember-osf-web/services/analytics';
import CurrentUser from 'ember-osf-web/services/current-user';
import captureException, { getApiErrorMessage } from 'ember-osf-web/utils/capture-exception';

export default class UserQuickfiles extends Controller {
@service analytics!: Analytics;
Expand Down Expand Up @@ -41,8 +42,10 @@ export default class UserQuickfiles extends Controller {
createProject = task(function *(this: UserQuickfiles, node: Node) {
try {
return yield node.save();
} catch (ex) {
this.toast.error(this.intl.t('move_to_project.could_not_create_project'));
} catch (e) {
const errorMessage = this.intl.t('move_to_project.could_not_create_project');
captureException(e, { errorMessage });
this.toast.error(getApiErrorMessage(e), errorMessage);
return undefined;
}
});
Expand Down
1 change: 0 additions & 1 deletion app/home/-components/testimonials/template.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{{! template-lint-disable no-bare-strings }}
<section
data-test-testimonials-container
local-class='container'
Expand Down
3 changes: 2 additions & 1 deletion app/institutions/index/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
<div local-class='Institutions__header-logo'></div>
<p class='lead'>
{{t 'institutions.description'}}
<br>
<OsfLink
data-test-read-more-link
data-analytics-name='Read more'
local-class='Institutions__block__link'
@href='https://cos.io/our-products/osf-institutions/'
@href='https://cos.io/institutions/'
>
{{t 'institutions.read_more'}}
</OsfLink>
Expand Down
20 changes: 7 additions & 13 deletions app/serializers/registration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,22 @@ import {
} from 'ember-osf-web/packages/registration-schema';
import { normalizeRegistrationResponses } from 'ember-osf-web/serializers/draft-registration';
import { mapKeysAndValues } from 'ember-osf-web/utils/map-keys';
import { SingleResourceDocument } from 'osf-api';
import { Resource } from 'osf-api';
import OsfSerializer from './osf-serializer';

export default class RegistrationSerializer extends OsfSerializer {
normalizeResponse(
store: DS.Store,
primaryModelClass: any,
payload: SingleResourceDocument,
id: string,
requestType: string,
) {
if (payload.data.attributes) {
const registrationResponses = payload.data.attributes.registration_responses as RegistrationResponse;
normalize(modelClass: DS.Model, resourceHash: Resource) {
if (resourceHash.attributes) {
const registrationResponses = resourceHash.attributes.registration_responses as RegistrationResponse;
// @ts-ignore
// eslint-disable-next-line no-param-reassign
payload.data.attributes.registration_responses = mapKeysAndValues(
resourceHash.attributes.registration_responses = mapKeysAndValues(
registrationResponses || {},
key => key,
value => normalizeRegistrationResponses(value, store),
value => normalizeRegistrationResponses(value, this.store),
) as NormalizedRegistrationResponse;
}
return super.normalizeResponse(store, primaryModelClass, payload, id, requestType);
return super.normalize(modelClass, resourceHash) as { data: Resource };
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Toast from 'ember-toastr/services/toast';
import User from 'ember-osf-web/models/user';
import UserPassword from 'ember-osf-web/models/user-password';
import CurrentUser from 'ember-osf-web/services/current-user';
import captureException, { getApiErrorMessage } from 'ember-osf-web/utils/capture-exception';

export default class ChangePasswordPane extends Component {
// Private properties
Expand Down Expand Up @@ -45,7 +46,8 @@ export default class ChangePasswordPane extends Component {
try {
yield this.userPassword.save();
} catch (e) {
this.toast.error(errorMessage);
captureException(e, { errorMessage });
this.toast.error(getApiErrorMessage(e), errorMessage);
return;
}
this.userPassword.unloadRecord();
Expand Down
10 changes: 7 additions & 3 deletions app/settings/account/-components/connected-emails/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Toast from 'ember-toastr/services/toast';
import { QueryHasManyResult } from 'ember-osf-web/models/osf-model';
import UserEmail from 'ember-osf-web/models/user-email';
import CurrentUser from 'ember-osf-web/services/current-user';
import captureException, { getApiErrorMessage } from 'ember-osf-web/utils/capture-exception';

import { ChangesetDef } from 'ember-changeset/types';
import getHref from 'ember-osf-web/utils/get-href';
Expand Down Expand Up @@ -60,7 +61,8 @@ export default class ConnectedEmails extends Component {
try {
yield email.destroyRecord();
} catch (e) {
return this.toast.error(errorMessage);
captureException(e, { errorMessage });
return this.toast.error(getApiErrorMessage(e), errorMessage);
}
if (email.isConfirmed) {
this.reloadAlternateList();
Expand All @@ -84,7 +86,8 @@ export default class ConnectedEmails extends Component {
try {
yield email.save();
} catch (e) {
return this.toast.error(errorMessage);
captureException(e, { errorMessage });
return this.toast.error(getApiErrorMessage(e), errorMessage);
}

this.get('loadPrimaryEmail').perform();
Expand All @@ -111,7 +114,8 @@ export default class ConnectedEmails extends Component {
type: 'GET',
});
} catch (e) {
return this.toast.error(errorMessage);
captureException(e, { errorMessage });
return this.toast.error(getApiErrorMessage(e), errorMessage);
}

return this.toast.success(successMessage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Intl from 'ember-intl/services/intl';
import Toast from 'ember-toastr/services/toast';

import ExternalIdentity from 'ember-osf-web/models/external-identity';
import captureException, { getApiErrorMessage } from 'ember-osf-web/utils/capture-exception';

const { support: { supportEmail } } = config;

Expand All @@ -26,10 +27,12 @@ export default class ConnectedIdentities extends Component {
try {
yield identity.destroyRecord();
} catch (e) {
this.toast.error(this.intl.t(
const errorMessage = this.intl.t(
'settings.account.connected_identities.remove_fail',
{ supportEmail, htmlSafe: true },
));
);
captureException(e, { errorMessage });
this.toast.error(getApiErrorMessage(e), errorMessage);
return false;
}
this.reloadIdentitiesList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Toast from 'ember-toastr/services/toast';
import User from 'ember-osf-web/models/user';
import UserSettingModel from 'ember-osf-web/models/user-setting';
import CurrentUser from 'ember-osf-web/services/current-user';
import captureException, { getApiErrorMessage } from 'ember-osf-web/utils/capture-exception';

@tagName('')
export default class DeactivationPane extends Component {
Expand Down Expand Up @@ -42,9 +43,10 @@ export default class DeactivationPane extends Component {
throw Error('No settings to save.');
} catch (e) {
const { supportEmail } = config.support;
const saveErrorMessage = this.intl
const errorMessage = this.intl
.t('settings.account.security.saveError', { supportEmail, htmlSafe: true });
return this.toast.error(saveErrorMessage);
captureException(e, { errorMessage });
return this.toast.error(getApiErrorMessage(e), errorMessage);
}
});

Expand Down
6 changes: 4 additions & 2 deletions app/settings/account/-components/security/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import User from 'ember-osf-web/models/user';
import UserEmail from 'ember-osf-web/models/user-email';
import UserSettingModel from 'ember-osf-web/models/user-setting';
import CurrentUser from 'ember-osf-web/services/current-user';
import captureException, { getApiErrorMessage } from 'ember-osf-web/utils/capture-exception';

@tagName('')
export default class SecurityPane extends Component {
Expand Down Expand Up @@ -65,9 +66,10 @@ export default class SecurityPane extends Component {
this.settings.rollbackAttributes();
}
const { supportEmail } = config.support;
const saveErrorMessage = this.intl
const errorMessage = this.intl
.t('settings.account.security.saveError', { supportEmail, htmlSafe: true });
this.toast.error(saveErrorMessage);
captureException(e, { errorMessage });
this.toast.error(getApiErrorMessage(e), errorMessage);
} finally {
this.hideDialogs();
}
Expand Down
Loading

0 comments on commit bbf339d

Please sign in to comment.