discourse/plugins/chat/spec/system
Joffrey JAFFEUX abcdd8d367
DEV: FloatKit (#23312)
This PR introduces three new UI elements to Discourse codebase through an addon called "FloatKit":

- menu
- tooltip
- toast

Simple cases can be express with an API similar to DButton:

```hbs
<DTooltip
  @label={{i18n "foo.bar"}}
  @icon="check"
  @content="Something"
/>
```

More complex cases can use blocks:

```hbs
<DTooltip>
  <:trigger>
   {{d-icon "check"}}
   <span>{{i18n "foo.bar"}}</span>
  </:trigger>
  <:content>
   Something
  </:content>
</DTooltip>
```

You can manually show a tooltip using the `tooltip` service:

```javascript
const tooltipInstance = await this.tooltip.show(
  document.querySelector(".my-span"),
  options
)

// and later manually close or destroy it
tooltipInstance.close();
tooltipInstance.destroy();

// you can also just close any open tooltip through the service
this.tooltip.close();
```

The service also allows you to register event listeners on a trigger, it removes the need for you to manage open/close of a tooltip started through the service:

```javascript
const tooltipInstance = this.tooltip.register(
  document.querySelector(".my-span"),
  options
)

// when done you can destroy the instance to remove the listeners
tooltipInstance.destroy();
```

Note that the service also allows you to use a custom component as content which will receive `@data` and `@close` as args:

```javascript
const tooltipInstance = await this.tooltip.show(
  document.querySelector(".my-span"),
  {
    component: MyComponent,
    data: { foo: 1 }
  }
)
```

Menus are very similar to tooltips and provide the same kind of APIs:

```hbs
<DMenu @icon="plus" @label={{i18n "foo.bar"}}>
  <ul>
    <li>Foo</li>
    <li>Bat</li>
    <li>Baz</li>
  </ul>
</DMenu>
```

They also support blocks:

```hbs
<DMenu>
  <:trigger>
    {{d-icon "plus"}}
    <span>{{i18n "foo.bar"}}</span>
  </:trigger>
  <:content>
    <ul>
      <li>Foo</li>
      <li>Bat</li>
      <li>Baz</li>
    </ul>
  </:content>
</DMenu>
```

You can manually show a menu using the `menu` service:

```javascript
const menuInstance = await this.menu.show(
  document.querySelector(".my-span"),
  options
)

// and later manually close or destroy it
menuInstance.close();
menuInstance.destroy();

// you can also just close any open tooltip through the service
this.menu.close();
```

The service also allows you to register event listeners on a trigger, it removes the need for you to manage open/close of a tooltip started through the service:

```javascript
const menuInstance = this.menu.register(
   document.querySelector(".my-span"),
   options
)

// when done you can destroy the instance to remove the listeners
menuInstance.destroy();
```

Note that the service also allows you to use a custom component as content which will receive `@data` and `@close` as args:

```javascript
const menuInstance = await this.menu.show(
  document.querySelector(".my-span"),
  {
    component: MyComponent,
    data: { foo: 1 }
  }
)
```

Interacting with toasts is made only through the `toasts` service.

A default component is provided (DDefaultToast) and can be used through dedicated service methods:

- this.toasts.success({ ... });
- this.toasts.warning({ ... });
- this.toasts.info({ ... });
- this.toasts.error({ ... });
- this.toasts.default({ ... });

```javascript
this.toasts.success({
  data: {
    title: "Foo",
    message: "Bar",
    actions: [
      {
        label: "Ok",
        class: "btn-primary",
        action: (componentArgs) => {
          // eslint-disable-next-line no-alert
          alert("Closing toast:" + componentArgs.data.title);
          componentArgs.close();
        },
      }
    ]
  },
});
```

You can also provide your own component:

```javascript
this.toasts.show(MyComponent, {
  autoClose: false,
  class: "foo",
  data: { baz: 1 },
})
```

Co-authored-by: Martin Brennan <mjrbrennan@gmail.com>
Co-authored-by: Isaac Janzen <50783505+janzenisaac@users.noreply.github.com>
Co-authored-by: David Taylor <david@taylorhq.com>
Co-authored-by: Jarek Radosz <jradosz@gmail.com>
2023-09-12 15:06:51 +02:00
..
admin DEV: Do one query per month when exporting chat messages (#22746) 2023-07-27 21:56:32 +04:00
chat/composer DEV: Refactor chat specs related to message creation 2023-08-31 11:21:23 +02:00
chat_message DEV: Refactor chat specs related to message creation 2023-08-31 11:21:23 +02:00
list_channels UX: implements swipe on row channel (#23436) 2023-09-11 14:51:13 +02:00
page_objects UI: refines thread list item (#23207) 2023-08-24 18:45:20 +02:00
reply_to_message DEV: Refactor chat specs related to message creation 2023-08-31 11:21:23 +02:00
select_message FEATURE: thread pagination (#22624) 2023-07-27 09:57:03 +02:00
shortcuts DEV: Refactor chat specs related to message creation 2023-08-31 11:21:23 +02:00
thread_list UX: thread list design changes (#23348) 2023-08-31 18:09:41 +02:00
thread_tracking DEV: Refactor chat specs related to message creation 2023-08-31 11:21:23 +02:00
user_menu_notifications DEV: Refactor chat specs related to message creation 2023-08-31 11:21:23 +02:00
user_status FEATURE: Use rich user status tooltip everywhere (#21125) 2023-07-03 11:09:41 -03:00
anonymous_spec.rb DEV: Remove superfluous js: true metadata (#21960) 2023-06-07 09:26:58 +08:00
archive_channel_spec.rb DEV: Refactor chat specs related to message creation 2023-08-31 11:21:23 +02:00
bookmark_message_spec.rb DEV: Remove superfluous js: true metadata (#21960) 2023-06-07 09:26:58 +08:00
browse_page_spec.rb FEATURE: enable_public_channels site setting (#22565) 2023-07-13 10:00:25 +02:00
channel_about_page_spec.rb DEV: makes chat modals use the new <DModal /> component (#22495) 2023-07-10 13:43:33 +02:00
channel_info_pages_spec.rb DEV: Remove superfluous js: true metadata (#21960) 2023-06-07 09:26:58 +08:00
channel_members_page_spec.rb DEV: Remove superfluous js: true metadata (#21960) 2023-06-07 09:26:58 +08:00
channel_message_upload_spec.rb DEV: Refactor a little chat uploads 2023-07-24 11:13:57 +02:00
channel_settings_page_spec.rb DEV: Remove experimental site setting for chat threads (#22720) 2023-07-26 12:46:23 +02:00
channel_thread_message_echoing_spec.rb DEV: makes every spec use new messages helper (#23163) 2023-08-21 16:31:58 +02:00
chat_channel_spec.rb FIX: Prevent chat message actions to disappear on mouseleave (#23063) 2023-09-11 16:54:01 -03:00
chat_composer_draft_spec.rb FIX: Render excerpt HTML for chat replies and edit (#22559) 2023-07-13 09:44:56 +10:00
chat_composer_spec.rb DEV: Fix flaky network-based upload spec (#23286) 2023-08-28 12:59:22 +08:00
chat_message_onebox_spec.rb DEV: Remove superfluous js: true metadata (#21960) 2023-06-07 09:26:58 +08:00
chat_summarization_spec.rb DEV: makes chat modals use the new <DModal /> component (#22495) 2023-07-10 13:43:33 +02:00
closed_channel_spec.rb DEV: Remove superfluous js: true metadata (#21960) 2023-06-07 09:26:58 +08:00
create_channel_spec.rb DEV: Remove experimental site setting for chat threads (#22720) 2023-07-26 12:46:23 +02:00
dates_separators_spec.rb FEATURE: thread pagination (#22624) 2023-07-27 09:57:03 +02:00
deleted_channel_spec.rb DEV: Remove superfluous js: true metadata (#21960) 2023-06-07 09:26:58 +08:00
deleted_message_spec.rb DEV: Unskip chat delete message spec (#22951) 2023-08-07 11:04:10 +10:00
document_title_spec.rb DEV: Remove superfluous js: true metadata (#21960) 2023-06-07 09:26:58 +08:00
drawer_spec.rb FIX: correctly recognizes URL with subfolder (#23173) 2023-08-21 22:12:05 +02:00
edited_message_spec.rb FIX: correctly resets editing state when done (#23209) 2023-08-24 09:41:37 +02:00
flag_message_spec.rb FIX: direct message channels can be flagged (#22134) 2023-06-16 11:04:59 +10:00
hashtag_autocomplete_spec.rb DEV: Remove enable_experimental_hashtag_autocomplete logic (#22820) 2023-08-08 11:18:55 +10:00
kick_user_from_channel_spec.rb DEV: Remove superfluous js: true metadata (#21960) 2023-06-07 09:26:58 +08:00
mention_warnings_spec.rb FEATURE: Chat global mention warnings (pre-send & post-send) (#22764) 2023-08-22 15:54:35 -05:00
message_errors_spec.rb DEV: Remove superfluous js: true metadata (#21960) 2023-06-07 09:26:58 +08:00
message_notifications_mobile_spec.rb DEV: makes every spec use new messages helper (#23163) 2023-08-21 16:31:58 +02:00
message_notifications_with_sidebar_spec.rb FIX: correctly makes dm creator to follow channel (#22470) 2023-07-06 21:42:19 +02:00
message_thread_indicator_spec.rb DEV: Refactor chat specs related to message creation 2023-08-31 11:21:23 +02:00
message_user_info.rb DEV: Remove superfluous js: true metadata (#21960) 2023-06-07 09:26:58 +08:00
move_message_to_channel_spec.rb DEV: makes chat modals use the new <DModal /> component (#22495) 2023-07-10 13:43:33 +02:00
navigation_spec.rb DEV: Refactor chat specs related to message creation 2023-08-31 11:21:23 +02:00
new_message_spec.rb FIX: correctly display max users message error (#23178) 2023-08-22 12:42:35 +02:00
react_to_message_spec.rb DEV: FloatKit (#23312) 2023-09-12 15:06:51 +02:00
read_only_spec.rb DEV: Remove superfluous js: true metadata (#21960) 2023-06-07 09:26:58 +08:00
removing_channel_spec.rb FIX: redirects to browse after removing last followed (#22563) 2023-07-14 08:26:18 +02:00
restore_message_spec.rb FIX: prevents user to restore message deleted by staff (#22571) 2023-07-13 10:16:15 +02:00
reviewables_spec.rb DEV: Remove superfluous js: true metadata (#21960) 2023-06-07 09:26:58 +08:00
send_message_spec.rb FIX: correctly makes dm creator to follow channel (#22470) 2023-07-06 21:42:19 +02:00
separate_sidebar_mode_spec.rb FIX: prevents setPanel to also set separated mode (#23227) 2023-08-24 18:21:28 +02:00
sidebar_navigation_menu_spec.rb UX: Remove section heading for community section (#22405) 2023-07-11 09:40:37 +08:00
sidebars_spec.rb FEATURE: enable_public_channels site setting (#22565) 2023-07-13 10:00:25 +02:00
silenced_user_spec.rb DEV: Remove superfluous js: true metadata (#21960) 2023-06-07 09:26:58 +08:00
single_thread_spec.rb DEV: Refactor chat specs related to message creation 2023-08-31 11:21:23 +02:00
transcript_spec.rb DEV: Fix or remove flaky chat specs (#22406) 2023-07-04 16:23:04 +10:00
unfollow_dm_channel_spec.rb DEV: makes every spec use new messages helper (#23163) 2023-08-21 16:31:58 +02:00
update_last_read.rb DEV: Remove superfluous js: true metadata (#21960) 2023-06-07 09:26:58 +08:00
uploads_spec.rb DEV: Remove superfluous js: true metadata (#21960) 2023-06-07 09:26:58 +08:00
user_card_spec.rb DEV: makes user-card-chat-button uses glimmer (#22496) 2023-07-10 14:04:26 +02:00
user_chat_preferences_spec.rb FIX: correctly check chat tab is present (#23200) 2023-08-23 13:06:29 +02:00
user_presence.rb FIX: correctly show unread and presence (#22441) 2023-07-05 21:01:23 +02:00
visit_channel_spec.rb DEV: makes every spec use new messages helper (#23163) 2023-08-21 16:31:58 +02:00