discourse/app/assets/javascripts
Isaac Janzen 8b80132f88
DEV: Convert dismiss modals to component-based API (#22262)
This PR converts the following modals:
- `dismiss-new`
- `dismiss-read`
- `dismiss-notification-confirmation`

to make use of the new component-based API

# Additional Changes
## Before
By default we display a warning modal when dismissing a notification however we bypass the warning modal for specific notification types when they are a 'low priority' type of notification (eg. likes). To do this we were overwriting `dismissWarningModal` on a given notification type component

```javascript
dismissWarningModal() {
  return null
}
```

but in the case we wanted to change the text within the modal we were calling `showModal` and then passing in the respective options all over again, putting the logic of rendering the modal in multiple places.

```javascript
dismissWarningModal() {
  const modalController = showModal("dismiss-notification-confirmation");
  modalController.set(
    "confirmationMessage",
    I18n.t("notifications.dismiss_confirmation.body.assigns", {
      count: this._unreadAssignedNotificationsCount,
    })
  );
  return modalController;
}
```
 

## After
I simplified this by adding an extensible `dismissConfirmationText` function that can be updated on a per component basis as that was the only option being overridden. 

eg

```javascript
get dismissConfirmationText() {
  return I18n.t("notifications.dismiss_confirmation.body.bookmarks", {
    count: this.#unreadBookmarkRemindersCount,
});
```

This saves us from importing the entire modal again and keeps the core logic in one place.

Instead of overwriting the `dismissWarningModal` function and returning `null` to bypass the confirmation modal, I added another extension point of `renderDismissConfirmation` (defaults to true) to _toggle_ whether we should display a confirmation when dismissing notifications.

eg

```javascript
get renderDismissConfirmation() {
  return false;
}
```

we utilize this in core for specific _low priority_ notification types. When you need the confirmation modal to be displayed no matter the case you can set `alwaysRenderDismissConfirmation` to `true`

```
get alwaysRenderDismissConfirmation(){
  return true
}
```

This can be useful when you want to render the confirmation modal on a custom notification type that is not deemed as _high priority_, leading to the confirmation modal never being rendered.

You can see this in use in [Discourse Assign](https://github.com/discourse/discourse-assign/pull/481)
2023-07-06 12:14:26 -05:00
..
admin DEV: Remove unused raw-email code (#22364) 2023-07-05 18:13:30 +02:00
bootstrap-json DEV: Clean up package.json files (#22349) 2023-06-30 13:01:45 +02:00
confirm-new-email DEV: Add error message styling (#21225) 2023-04-25 08:40:18 -04:00
dialog-holder Build(deps): Bump webpack in /app/assets/javascripts (#22336) 2023-06-29 01:00:12 +02:00
discourse DEV: Convert dismiss modals to component-based API (#22262) 2023-07-06 12:14:26 -05:00
discourse-common Build(deps-dev): Bump @babel/core in /app/assets/javascripts (#22418) 2023-07-05 16:47:28 +02:00
discourse-hbr Build(deps-dev): Bump @babel/core in /app/assets/javascripts (#22418) 2023-07-05 16:47:28 +02:00
discourse-plugins Build(deps-dev): Bump @babel/core in /app/assets/javascripts (#22418) 2023-07-05 16:47:28 +02:00
discourse-widget-hbs Build(deps-dev): Bump @babel/core in /app/assets/javascripts (#22418) 2023-07-05 16:47:28 +02:00
docs
ember-addons
ember-cli-progress-ci
ember-production-deprecations DEV: Clean up package.json files (#22349) 2023-06-30 13:01:45 +02:00
locales UX/DEV: Review queue redesign fixes (#20239) 2023-03-02 16:40:53 +01:00
patches DEV: Update ember-cli to 5.0.0 (#22280) 2023-06-26 17:15:59 +02:00
pretty-text Build(deps-dev): Bump @babel/core in /app/assets/javascripts (#22418) 2023-07-05 16:47:28 +02:00
select-kit Build(deps-dev): Bump @babel/core in /app/assets/javascripts (#22418) 2023-07-05 16:47:28 +02:00
truth-helpers Build(deps-dev): Bump @babel/core in /app/assets/javascripts (#22418) 2023-07-05 16:47:28 +02:00
wizard Build(deps-dev): Bump @babel/core in /app/assets/javascripts (#22418) 2023-07-05 16:47:28 +02:00
.licensee.json DEV: Update sub-dependencies (#22325) 2023-06-29 17:08:33 +02:00
.npmrc
discourse-js-processor.js DEV: Update ember-cli-htmlbars to 6.2.0 (#20467) 2023-02-27 18:43:28 +01:00
handlebars-shim.js
package.json DEV: Clean up package.json files (#22349) 2023-06-30 13:01:45 +02:00
polyfills.js Drop support for iOS < 15.7 (#19847) 2023-01-16 17:28:59 +00:00
service-worker.js.erb FIX: Attempt to reconnect to server when browser visibilty changes (#22259) 2023-06-23 11:32:34 -05:00
yarn.lock Build(deps-dev): Bump @babel/standalone in /app/assets/javascripts (#22419) 2023-07-05 17:05:32 +02:00