|
@@ -5,7 +5,10 @@ import Icon from '../../Icon/Icon';
|
|
|
|
|
|
import TooltipEntity from '../decorators/TooltipEntity';
|
|
|
|
|
|
+import { STRINGS } from '../../../config/wagtailConfig';
|
|
|
+
|
|
|
const LINK_ICON = <Icon name="link" />;
|
|
|
+const BROKEN_LINK_ICON = <Icon name="warning" />;
|
|
|
const MAIL_ICON = <Icon name="mail" />;
|
|
|
|
|
|
const getEmailAddress = mailto => mailto.replace('mailto:', '').split('?')[0];
|
|
@@ -13,11 +16,14 @@ const getDomainName = url => url.replace(/(^\w+:|^)\/\//, '').split('/')[0];
|
|
|
|
|
|
// Determines how to display the link based on its type: page, mail, or external.
|
|
|
export const getLinkAttributes = (data) => {
|
|
|
- const url = data.url || '';
|
|
|
+ const url = data.url || null;
|
|
|
let icon;
|
|
|
let label;
|
|
|
|
|
|
- if (data.id) {
|
|
|
+ if (!url) {
|
|
|
+ icon = BROKEN_LINK_ICON;
|
|
|
+ label = STRINGS.BROKEN_LINK;
|
|
|
+ } else if (data.id) {
|
|
|
icon = LINK_ICON;
|
|
|
label = url;
|
|
|
} else if (url.startsWith('mailto:')) {
|