feat(new notification): SA/add "target" prop to link {} (#9472)

* feat(NewNotification): Add "target" prop to link {}

Signed-off-by: ScottAgirs <scott@ijs.to>

* chore: Minor typo fix occured > occur(R)ed

Signed-off-by: ScottAgirs <scott@ijs.to>

* fix: Add missing target check

Signed-off-by: ScottAgirs <scott@ijs.to>

* chore: Remove external window arrow if !"_blank"

Signed-off-by: ScottAgirs <scott@ijs.to>

* chore: replace redundant fragment w Padded />

Signed-off-by: ScottAgirs <scott@ijs.to>

* fix: Indentation

Signed-off-by: ScottAgirs <scott@ijs.to>
This commit is contained in:
Scott Agirs 2021-03-01 04:47:42 -05:00 committed by GitHub
parent de1575383c
commit 5311ca776e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 4 deletions

View File

@ -67,7 +67,7 @@ const AuthPage = ({ hasAdmin, setHasAdmin }) => {
});
}
} catch (err) {
const errorMessage = get(err, ['response', 'data', 'message'], 'An error occured');
const errorMessage = get(err, ['response', 'data', 'message'], 'An error occurred');
strapi.notification.toggle({
type: 'warning',

View File

@ -88,7 +88,15 @@ const Notification = ({ notification }) => {
<Text title={formattedMessage(message)}>{formattedMessage(message)}</Text>
)}
{link && (
<a href={link.url} target="_blank" rel="noopener noreferrer">
<a
href={link.url}
target={link.target || '_blank'}
rel={
!link.target || link.target === '_blank'
? 'noopener noreferrer'
: ''
}
>
<Padded right left size="xs">
<Flex alignItems="center">
<Text
@ -100,8 +108,11 @@ const Notification = ({ notification }) => {
>
{formattedMessage(link.label)}
</Text>
<Padded left size="xs" />
{link.target === "_blank" && (
<Padded left size="xs">
<LinkArrow />
</Padded>
)}
</Flex>
</Padded>
</a>
@ -152,6 +163,7 @@ Notification.propTypes = {
}),
]),
link: PropTypes.shape({
target: PropTypes.string,
url: PropTypes.string.isRequired,
label: PropTypes.oneOfType([
PropTypes.string,