Kianna 47024f060c
UI: Fix bugs in custom messages (#25169)
* Fix bugs in custom messages

* Add new line split helper file

* Fix multiple banner issue

* Code cleanup

* Add tests

* Add more tests

* Remove empty state action

* Remove test
2024-02-05 09:08:10 -08:00

51 lines
1.6 KiB
Handlebars

{{!
Copyright (c) HashiCorp, Inc.
SPDX-License-Identifier: BUSL-1.1
~}}
<Hds::Modal
@onClose={{fn (mut @showMessagePreviewModal) false}}
id="message-alert-preview"
class="is-calc-large-height is-two-thirds-width"
data-test-modal="preview image"
as |M|
>
<M.Body class="is-paddingless is-overflow-hidden">
<Hds::Alert
@type="page"
@color="highlight"
@onDismiss={{fn (mut @showMessagePreviewModal) false}}
class="has-bottom-margin-s"
data-test-custom-alert={{@message.title}}
as |A|
>
<A.Title data-test-custom-alert-title={{@message.title}}>{{@message.title}}</A.Title>
{{#each (new-line-split @message.message) as |msg|}}
<A.Description data-test-custom-alert-description={{@message.title}}>
{{msg}}
</A.Description>
{{/each}}
{{#unless (is-empty-value @message.link)}}
{{#each-in @message.link as |title href|}}
<A.Link::Standalone
@color="secondary"
@icon="external-link"
@isHrefExternal={{true}}
@iconPosition="trailing"
@text={{title}}
@href={{href}}
data-test-custom-alert-action="link"
/>
{{/each-in}}
{{/unless}}
</Hds::Alert>
<img
src={{img-path (if @message.authenticated "~/custom-messages-dashboard.png" "~/custom-messages-login.png")}}
alt={{if @message.authenticated "dashboard page preview" "login page preview"}}
/>
</M.Body>
<M.Footer as |F|>
<Hds::Button @text="Close preview" {{on "click" F.close}} data-test-modal-button="Close" />
</M.Footer>
</Hds::Modal>