84535[TASK] Introduce Alert web component
Commit message
Review
-
Code review CR +2 Done
- Andreas Kienast +2
- Oli Bartsch +1
-
Verified V +2 Done
- Andreas Kienast +2
- Oli Bartsch +1
- core-ci +1 CI
Issues 1
Files 2
Review log 5876
Show 3851 earlier messages
-
Marcin Sągol uploaded patch set 1 06/08/24, 21:08
-
core-ci voted on patch set 1 V +1 06/08/24, 21:13 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/58931
-
Ayke Halder commented on patch set 1 06/11/24, 14:32
Maybe combine the inline/non-inline rendering? And some idea for the property `iconIdentifier`.alert.ts:32Does it work to set the value of `iconIdentifier` here instead of using the constructor? ``` @property({ type: String }) iconIdentifier: string = this.getIconIdentifier(); [OR static method] @property({ type: String }) iconIdentifier: string = Alert.getIconIdentifier(this.severity); ``` May we actually expect `severity` to change after object-initialization? Then we might need to manage on-change `severity` to also update `iconIdentifier`. ---- Do we expect a custom `icon-identifier` to be set via attribute? Then rename the attribute from default `iconidentifier` to `icon-identifier`: `@property({ type: String, attribute: 'icon-identifier' }) iconIdentifier…` If not - maybe bind directly to method `getIconIdentifier()` ``` export class Alert extends LitElement { private static getIconIdentifier(severity: SeverityEnum): string { const icons = { [SeverityEnum.notice]: 'actions-lightbulb', [SeverityEnum.ok]: 'actions-check', [SeverityEnum.warning]: 'actions-exclamation', [SeverityEnum.error]: 'actions-close', [SeverityEnum.info]: 'actions-info', }; return icons[severity] || 'actions-info'; } @property(…)… … @property({ attribute: false }) iconIdentifier = () => { return Alert.getIconIdentifier(this.severity) }; public async … ```alert.ts:55May we combine inline/non-inline like this? * This adds some `div`-tags without `class`-attribute to the inline HTML. * Non-inline HTML does not change (mind `p`-/`div`-tag for `alert-body`). ```ts import { ifDefined } from 'lit/directives/if-defined'; […] return html` <div class=${classMap(classes)} role="alert"> <div class="${ifDefined(this.inline ? null : 'media')}"> ${this.showIcon ? html` <div class="${ifDefined(this.inline ? null : 'media-left')}"> <span class="${this.emphasizedIcon ? 'icon-emphasized' : nothing}"> <typo3-backend-icon identifier="${this.iconIdentifier}" size="small"></typo3-backend-icon> </span> </div> ` : nothing} <div class="${ifDefined(this.inline ? null : 'media-body')}"> ${this.heading ? html`<h4 class="alert-title">${this.heading}</h4>` : nothing} <p class="alert-body">${unsafeHTML(this.message)}</p> </div> </div> ${this.dismissible ? this.renderDismissButton() : nothing} </div> `; ``` To remove the `class`-attribute completely in case of inline: Instead of `<tag class="${ifDefined(this.inline ? null : 'media-body')}">` this might also work `<tag class="${this.inline ? nothing : 'media-body'}">`alert.ts:84Is a `div`-tag needed or can this be a `p`-tag like for the inline-version?alert.ts:92Can this become a static method? Also see comment about constructor above. -
Marcin Sągol uploaded patch set 2
V +106/16/24, 17:29 -
Marcin Sągol commented on patch set 2 06/16/24, 17:30
alert.ts:32ReplyProbably for now I would avoid custom icons, just to make sure that we have the same styles/views across the whole app. Later, when/if we make a common abstract class for notifications/callouts/alerts etc. we can think about giving an option for custom icons. Looking at Notification component, there is no option to set a custom icon - let's make here the same, then it will be easier to make a common ground for both. The iconIdentifier will be just a private property, which might change when severity changes, i have added update() method for this.alert.ts:55ReplyFor now I have removed the inline `property`. This was for special cases when i was testing this component in various code parts (when i replaced static HTML with this component). But since the unification of all those alert-like components will take place later (needs to be discussed with UI/UX team), so the code also will be updated later. So for now i do not implemet any variants (block or inline) of this component (I do not want to add now something that might change soon and wont be use dnow).alert.ts:84ReplyFor now, there won't be an inline version.alert.ts:92ReplyIt is now a static method. -
Marcin Sągol updated the commit message in patch set 3 06/16/24, 17:30
-
core-ci voted on patch set 3 V +1 06/16/24, 17:37 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/59681
-
core-ci voted on patch set 2 V +1 06/16/24, 17:37 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/59680
-
Georg Ringer voted on patch set 3 CR +1 V +1 06/17/24, 07:51
-
Andreas Kienast commented on patch set 3 CR -1 06/17/24, 13:03
Temp -1, will review thoroughly -
Marcin Sągol commented on patch set 3 06/18/24, 07:10
Reply
Hi Andreas, i would like to have some feedback here as this task blocks my other task :) -
Andreas Kienast commented on patch set 3 06/18/24, 10:37
alert.ts:22Please use proper naming here: `typo3-backend-alert`. Also, please move the module into the `elements` directory.alert.ts:31Why is this configurable at all?alert.ts:38The property is superfluous. It's better to call the method directly in the rendering, this would also make the `updated()` callback obsolete.alert.ts:52Why does `close` need to be async? All actions within a synchronous.alert.ts:53Can be shortened to `this.parentNode?.removeChild(this);`alert.ts:85I'm nor sure if I really like this... -
Andreas Kienast commented on patch set 3 06/18/24, 10:39
Also, this is a feature, but misses the feature.rst file. I'm not sure whether it's smart to propagate this as a general feature (for now). -
Andreas Kienast commented on patch set 3 06/18/24, 10:41
alert.ts:25This should also not be configurable (it's not used at all anyway). -
Benjamin Franzke commented on patch set 3 CR -1 06/18/24, 10:42
In general this needs to be compared with the similar patch https://review.typo3.org/c/Packages/TYPO3.CMS/+/84707 I'd like to see a list of usages where this component is planed to be integrated.alert.ts:85Replyack, this is not a good idea for new API. This needs to render a `<slot></slot>`, to ensure that this API can be used in a safe way and doesn't introduce security issues. -
Marcin Sągol commented on patch set 3 06/18/24, 13:38
Reply
@ben@bnf.dev I was explaining it a bit on the core devs channel, in the patch commit message, and in the issue on Forge. There are multiple elements that serve very similar roles: Notifications, Alerts, Callouts, and Infoboxes. The alert, for example, is used in many places in the code by using plain static HTML to define it (you can search the code by alert classes). I was suggesting introducing the Alert Web Component (I want to use it in my different task: https://review.typo3.org/c/Packages/TYPO3.CMS/+/83637) and then, as a separate patch, it could be used in the code instead of inlined HTML. Next, it should be discussed if all those components: Notifications, Alerts, Callouts, and Infoboxes are needed. If they are, we could create an abstract class for all of them, as they share a lot of common logic, and the concrete implementations could provide just small enhancements. -
Georg Ringer commented on patch set 3 CR 0 06/19/24, 08:03
rst is missing -
Jasmina Ließmann wrote 06/19/24, 13:07
Removed cc Jasmina Ließmann. -
Marcin Sągol uploaded patch set 4
CR -1V +106/24/24, 14:06 -
Marcin Sągol commented on patch set 4 06/24/24, 14:11
alert.ts:22ReplyDonealert.ts:31ReplyThe icon can be rendered in 2 styles: the default one (just an icon) and emphasized, then it is rendered inside circle with colored background. There is a style for it in the backend.css and for example such class is used in `TYPO3\CMS\Core\Messaging\Renderer\BootstrapRenderer`.alert.ts:38ReplyDonealert.ts:52ReplyDonealert.ts:53ReplyDone -
core-ci voted on patch set 4 V +1 06/24/24, 14:12 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/60180
-
Marcin Sągol uploaded patch set 5
V +106/24/24, 14:17 -
Marcin Sągol commented on patch set 5 06/24/24, 14:17
alert.ts:31ReplyAs discussed on Slack, i have removed this attribute and the icon is always emphasized. -
core-ci voted on patch set 5 V +1 06/24/24, 14:26 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/60186
-
Marcin Sągol uploaded patch set 6
V +106/24/24, 15:02 -
core-ci voted on patch set 6 V +1 06/24/24, 15:07 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/60191
-
Marcin Sągol commented on patch set 6 06/24/24, 15:49
alert.ts:85Reply@ben@bnf.dev how the slot could be implemented here without loosing bootstrap styles? -
Marcin Sągol updated the commit message in patch set 7
V +106/24/24, 15:55 -
Marcin Sągol uploaded patch set 8 06/24/24, 15:58
-
core-ci voted on patch set 8 V +1 06/24/24, 16:03 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/60196
-
core-ci voted on patch set 7 V +1 06/24/24, 16:03 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/60195
-
Marcin Sągol updated the commit message in patch set 9
V +106/24/24, 17:32 -
core-ci voted on patch set 9 V +1 06/24/24, 17:37 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/60201
-
Marcin Sągol uploaded patch set 10
V +106/25/24, 07:27 -
Marcin Sągol commented on patch set 9 06/25/24, 07:29
alert.ts:25ReplyDonealert.ts:85ReplyFor now i have removed the `unsafeHTML()` usage. -
core-ci voted on patch set 10 V +1 06/25/24, 07:32 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/60267
-
Marcin Sągol rebased onto patch set 11
V +106/30/24, 10:49 -
core-ci voted on patch set 11 V +1 06/30/24, 10:58 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/60663
-
Andreas Kienast commented on patch set 11 CR -1 07/05/24, 09:58
Will review asap One thing beforehand: the rst file must be moved to 13.3 -
Marcin Sągol uploaded patch set 12
CR -1V +107/05/24, 10:43 -
Marcin Sągol commented on patch set 12 07/05/24, 10:44
Reply
Rst moved into 13.3. -
core-ci voted on patch set 12 V +1 07/05/24, 10:48 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/61040
-
Andreas Kienast commented on patch set 12 CR -1 07/05/24, 11:18
on it -
Andreas Kienast uploaded patch set 13
CR -1V +107/05/24, 11:56 -
core-ci voted on patch set 13 V +1 07/05/24, 12:01 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/61046
-
Andreas Kienast voted on patch set 13 CR +1 V +1 07/05/24, 12:06
-
Andreas Kienast commented on patch set 13 07/05/24, 12:06
Reply
DoneReply
Donealert.ts:85ReplyDone -
Marcin Sągol voted on patch set 13 CR +1 V +1 07/05/24, 12:57
-
Mathias Brodala commented on patch set 13 07/05/24, 13:05
alert-element.ts:36It would be nice if this was a String instead with a suitable conversion. This would make it easier to understand the severity just from reading the source.alert-element.ts:40As mentioned on Slack: could this be passed as element content instead? -
Marcin Sągol commented on patch set 13 07/05/24, 13:13
alert-element.ts:36ReplyCould be, but i thought for example if used in PHP, we we would use `ContextualFeedbackSeverity` to pass the severity like `ContextualFeedbackSeverity::OK`, `ContextualFeedbackSeverity::NOTICE` so ve have numbers here, and for JS core we have the `SeverityEnum` like `SeverityEnum.info.info`. -
Mathias Brodala commented on patch set 13 07/05/24, 13:17
alert-element.ts:36ReplyCould you then use this in your commit description and in the RST? This way we have good examples to avoid magic numbers from the start.
-
Philipp Kuhlmay commented on patch set 13 07/05/24, 13:22
alert-element.ts:23Shouldn't this be something like 'alert-element' instead of 'immediate-action-element'? Module: @typo3/backend/element/alert-elementalert-element.ts:28I suggest to change the following to lines to "Alert heading" and "Alert message" like used inside the commit message, as this is an alert and not a modal. -
Andreas Kienast voted on patch set 13 CR 0 V 0 07/05/24, 13:24
-
Marcin Sągol uploaded patch set 14
CR +1V +107/05/24, 13:53 -
Marcin Sągol commented on patch set 14 07/05/24, 13:53
alert-element.ts:23ReplyDonealert-element.ts:28ReplyDonealert-element.ts:36ReplyDone -
Andreas Kienast commented on patch set 14 07/05/24, 13:54
@marcin@soee.pl your latest push reverted all the changes I did today. -
core-ci voted on patch set 14 V +1 07/05/24, 14:00 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/61057
-
Marcin Sągol commented on patch set 14 07/05/24, 14:09
Reply
Do you still have them locally and can push? -
Marcin Sągol uploaded patch set 15
V +107/05/24, 14:17 -
Marcin Sągol commented on patch set 15 07/05/24, 14:19
Reply
Ok, they should be back again. -
Marcin Sągol updated the commit message in patch set 16 07/05/24, 14:19
-
core-ci voted on patch set 15 V +1 07/05/24, 14:23 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/61059
-
core-ci voted on patch set 16 V +1 07/05/24, 14:28 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/61060
-
Andreas Kienast voted on patch set 16 CR +1 V +1 07/08/24, 06:05
-
Oli Bartsch commented on patch set 16 CR -1 07/08/24, 07:17
commit message and rst need some cleanup. Will try to do today.isdoes not exist anymoredoes not exist anymore -
Marcin Sągol commented on patch set 16 07/08/24, 11:21
Reply
Right, and this is desired from my perspective, as there are nested places where the alert should be condensed, so icon is not needed and rendered without icon atm. -
Oli Bartsch uploaded patch set 17
CR +1V +107/09/24, 14:54 -
core-ci voted on patch set 17 V +1 07/09/24, 14:59 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/61247
-
Oli Bartsch commented on patch set 17 CR +1 V +1 07/09/24, 14:59
Reply
DoneReply
DoneReply
DoneReply
Donealert-element.ts:40ReplyAs discussed in slack due to the need of shadow dom and the drawbacks (encapsulated styles, etc.) we will go with the current solution for now. -
Benjamin Franzke commented on patch set 17 07/09/24, 15:16
Reply
fine by mealert-element.ts:40ReplyI'm also not happy with this, as already mentioned in https://review.typo3.org/c/Packages/TYPO3.CMS/+/84535/13#message-9fc00fe5d0fd4447c270f998d9ac903177218883 But that means this component needs to use shadow-dom in order to use `<slot>` and therefore needs to avoid bootstrap classes. We'll need some more preparatory refactorings first, like: > 85132: [TASK] Introduce CSS Color Tokens | https://review.typo3.org/c/Packages/TYPO3.CMS/+/85132 ..and patches that will follow. if this patch is urgently needed it can go in, otherwise I'd love if someone would implement proper shadow DOM directly.. -
Andreas Kienast commented on patch set 17 07/10/24, 07:20
alert-element.ts:40ReplyCompromise: let's merge this patch as a [TASK]. This way the component isn't documented and we're fine changing this again at a later point without being breaking. -
Oli Bartsch uploaded patch set 18
CR +1V +107/10/24, 07:29 -
Oli Bartsch commented on patch set 18 CR +1 V +1 07/10/24, 07:29
alert-element.ts:40ReplyAcknowledged -
core-ci voted on patch set 18 V +1 07/10/24, 07:38 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/61289
-
Andreas Kienast voted on patch set 18 CR +2 V +2 07/10/24, 07:39
-
Andreas Kienast merged patch set 19 07/10/24, 07:39