From 8375eb7f65e936cb31ab1220f89ababad713774c Mon Sep 17 00:00:00 2001 From: John Tordoff <> Date: Tue, 3 Dec 2024 14:36:51 -0500 Subject: [PATCH 01/12] Add user messaging modal to user's tab on institutional dashboard --- app/adapters/user-message.ts | 13 ++++++ .../institutional-users-list/component.ts | 39 ++++++++++++++++ .../institutional-users-list/styles.scss | 20 ++++++++ .../institutional-users-list/template.hbs | 46 +++++++++++++++++++ app/models/user-message.ts | 8 ++++ translations/en-us.yml | 7 +++ 6 files changed, 133 insertions(+) create mode 100644 app/adapters/user-message.ts create mode 100644 app/models/user-message.ts diff --git a/app/adapters/user-message.ts b/app/adapters/user-message.ts new file mode 100644 index 00000000000..a92b865c714 --- /dev/null +++ b/app/adapters/user-message.ts @@ -0,0 +1,13 @@ +// app/adapters/user-message.js +import { inject as service } from '@ember/service'; +import config from 'ember-osf-web/config/environment'; +const { OSF: { apiUrl } } = config; +import OsfAdapter from './osf-adapter'; + +export default class UserMessageAdapter extends OsfAdapter { + @service session; + urlForCreateRecord(modelName, snapshot) { + const userId = snapshot.record.user; + return `${apiUrl}/v2/users/${userId}/messages/`; + } +} diff --git a/app/institutions/dashboard/-components/institutional-users-list/component.ts b/app/institutions/dashboard/-components/institutional-users-list/component.ts index 62c32591dc6..cadb989c193 100644 --- a/app/institutions/dashboard/-components/institutional-users-list/component.ts +++ b/app/institutions/dashboard/-components/institutional-users-list/component.ts @@ -26,6 +26,8 @@ interface InstitutionalUsersListArgs { export default class InstitutionalUsersList extends Component { @service analytics!: Analytics; @service intl!: Intl; + @service store; + @service currentUser!: CurrentUser; institution?: InstitutionModel; @@ -36,6 +38,10 @@ export default class InstitutionalUsersList extends Component {{institutionalUser.userName}} + {{else if (eq column.type 'osf_link')}} {{institutionalUser.userGuid}} @@ -185,4 +191,44 @@ {{t 'institutions.dashboard.users_list.empty'}} + + + {{t 'institutions.dashboard.send_message_modal.title'}} + + +
+
+ {{t 'institutions.dashboard.send_message_modal.opening_message_label'}} +
+ +
+ {{t 'institutions.dashboard.send_message_modal.closing_message_label' adminName=this.currentUser.user.fullName}} +
+
+
+ + + + +
{{/if}} diff --git a/app/models/user-message.ts b/app/models/user-message.ts new file mode 100644 index 00000000000..6233a239942 --- /dev/null +++ b/app/models/user-message.ts @@ -0,0 +1,8 @@ +// app/models/user-message.js +import Model, { attr, belongsTo } from '@ember-data/model'; + +export default class UserMessageModel extends Model { + @attr('string') messageText; + @attr('string') messageType; + @belongsTo('institution') institution; +} diff --git a/translations/en-us.yml b/translations/en-us.yml index 0416c52097d..b92b4bbdd72 100644 --- a/translations/en-us.yml +++ b/translations/en-us.yml @@ -799,6 +799,13 @@ institutions: search_placeholder: 'Search institutions' load_more: 'Load more institutions' dashboard: + send_message_modal: + title: 'Send Email' + opening_message_label: 'Comments:' + closing_message_label: 'Sincerely Yours, {adminName}' + message_sent_success: 'Message has been sent' + message_sent_failed: 'Message has failed to send of the issue persists contact your administrator' + send: 'Send' tabs: summary: Summary users: Users From 975af6682e72e865a47eb5953eb5d5bebd1f8269 Mon Sep 17 00:00:00 2001 From: John Tordoff <> Date: Fri, 6 Dec 2024 15:26:45 -0500 Subject: [PATCH 02/12] fix en-us typo --- translations/en-us.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/translations/en-us.yml b/translations/en-us.yml index b92b4bbdd72..c4a53b7504c 100644 --- a/translations/en-us.yml +++ b/translations/en-us.yml @@ -804,7 +804,7 @@ institutions: opening_message_label: 'Comments:' closing_message_label: 'Sincerely Yours, {adminName}' message_sent_success: 'Message has been sent' - message_sent_failed: 'Message has failed to send of the issue persists contact your administrator' + message_sent_failed: 'Message has failed to send. If the issue persists contact your administrator' send: 'Send' tabs: summary: Summary From d09ca7d33b61e9f9ca44f6fba984f7021ef65cb6 Mon Sep 17 00:00:00 2001 From: John Tordoff <> Date: Fri, 6 Dec 2024 15:58:45 -0500 Subject: [PATCH 03/12] add aira-label. --- .../-components/institutional-users-list/template.hbs | 4 ++++ translations/en-us.yml | 3 +++ 2 files changed, 7 insertions(+) diff --git a/app/institutions/dashboard/-components/institutional-users-list/template.hbs b/app/institutions/dashboard/-components/institutional-users-list/template.hbs index 8e214e4509e..82ba9d6b2bd 100644 --- a/app/institutions/dashboard/-components/institutional-users-list/template.hbs +++ b/app/institutions/dashboard/-components/institutional-users-list/template.hbs @@ -158,6 +158,8 @@
From d5803a686c20930af6a896cae0a1d3b8e091a42a Mon Sep 17 00:00:00 2001 From: John Tordoff <> Date: Mon, 16 Dec 2024 14:05:41 -0500 Subject: [PATCH 11/12] make message types an enum --- .../-components/institutional-users-list/component.ts | 3 ++- app/models/user-message.ts | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/institutions/dashboard/-components/institutional-users-list/component.ts b/app/institutions/dashboard/-components/institutional-users-list/component.ts index f7c93a393ee..dd8ae9442ec 100644 --- a/app/institutions/dashboard/-components/institutional-users-list/component.ts +++ b/app/institutions/dashboard/-components/institutional-users-list/component.ts @@ -11,6 +11,7 @@ import InstitutionModel from 'ember-osf-web/models/institution'; import InstitutionDepartmentsModel from 'ember-osf-web/models/institution-department'; import Analytics from 'ember-osf-web/services/analytics'; import { RelationshipWithLinks } from 'osf-api'; +import {MessageTypeChoices} from 'ember-osf-web/models/user-message'; interface Column { key: string; @@ -319,7 +320,7 @@ export default class InstitutionalUsersList extends Component Date: Mon, 16 Dec 2024 14:33:44 -0500 Subject: [PATCH 12/12] use proper Ember input tags, remove extra close modal command --- .../institutional-users-list/component.ts | 21 ++++--------------- .../institutional-users-list/template.hbs | 5 ++--- app/models/user-message.ts | 2 +- 3 files changed, 7 insertions(+), 21 deletions(-) diff --git a/app/institutions/dashboard/-components/institutional-users-list/component.ts b/app/institutions/dashboard/-components/institutional-users-list/component.ts index dd8ae9442ec..2268909b0c1 100644 --- a/app/institutions/dashboard/-components/institutional-users-list/component.ts +++ b/app/institutions/dashboard/-components/institutional-users-list/component.ts @@ -43,6 +43,8 @@ export default class InstitutionalUsersList extends Component
@@ -252,7 +252,6 @@ @type='primary' @disabled={{not this.messageText.trim}} {{on 'click' (queue (perform this.sendMessage))}} - {{on 'click' this.toggleMessageModal}} > {{t 'institutions.dashboard.send_message_modal.send'}} diff --git a/app/models/user-message.ts b/app/models/user-message.ts index 7154f15fe3c..9e66b3fa8fb 100644 --- a/app/models/user-message.ts +++ b/app/models/user-message.ts @@ -9,7 +9,7 @@ export enum MessageTypeChoices { export default class UserMessageModel extends Model { @attr('string') messageText; @attr('string') messageType: MessageTypeChoices; - @attr('boolean') cc; + @attr('boolean') bcc_sender; @attr('boolean') replyTo; @belongsTo('institution') institution; }