Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"homepage_url": "https://github.com/mattermost/mattermost-plugin-demo",
"support_url": "https://github.com/mattermost/mattermost-plugin-demo/issues",
"icon_path": "assets/icon.svg",
"version": "0.10.3",
"version": "0.11.1",
"min_server_version": "7.9.0",
"server": {
"executables": {
Expand Down
3 changes: 3 additions & 0 deletions webapp/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
"submenu.menu": "Submenu Example",
"submenu.second": "Second Item",
"submenu.third": "Third Item",
"tooltip.description": "This is a sample description. Visit {link} for more details.",
"tooltip.message": "This is a custom tooltip from the Demo Plugin",
"tooltip.sharedVia": "Shared via {link}",
"tooltip.title": "Demo Link Preview",
"useractions.action": "Action",
"useractions.demo": "Demo Plugin: "
}
3 changes: 3 additions & 0 deletions webapp/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
"sidebar.demo": "Complemento de Demostración:",
"sidebar.disabled": "Discapacitado",
"sidebar.enabled": "Habilitado",
"tooltip.description": "Esta es una descripción de ejemplo. Visite {link} para más detalles.",
"tooltip.message": "Esta es una información sobre herramientas personalizada del complemento de demostración",
"tooltip.sharedVia": "Compartido a través de {link}",
"tooltip.title": "Vista previa del enlace de demostración",
"useractions.action": "Acción",
"useractions.demo": "Complemento de Demostración: ",
"submenu.menu": "Ejemplo de submenú",
Expand Down
109 changes: 96 additions & 13 deletions webapp/src/components/link_tooltip/link_tooltip.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,89 @@ export default class LinkTooltip extends React.PureComponent {
}

render() {
if (!this.props.href.includes('www.test.com')) {
let hostname;
try {
hostname = new URL(this.props.href).hostname.toLowerCase();
} catch {
return null;
}

if (hostname !== 'example.com' && !hostname.endsWith('.example.com')) {
return null;
}

const style = getStyle(this.props.theme);
return (
<div
style={style.configuration}
>
<i
style={iconStyles}
className='icon fa fa-plug'
/>
<FormattedMessage
id='tooltip.message'
defaultMessage='This is a custom tooltip from the Demo Plugin'
/>
<div style={style.container}>
<div style={style.header}>
<i
style={iconStyles}
className='icon fa fa-plug'
/>
<FormattedMessage
id='tooltip.message'
defaultMessage='This is a custom tooltip from the Demo Plugin'
/>
</div>
<div style={style.body}>
<a
href={this.props.href}
target='_blank'
rel='noopener noreferrer'
style={style.titleLink}
data-testid='demo-tooltip-title-link'
>
<FormattedMessage
id='tooltip.title'
defaultMessage='Demo Link Preview'
/>
</a>

<p style={style.sharedVia}>
<FormattedMessage
id='tooltip.sharedVia'
defaultMessage='Shared via {link}'
values={{
link: (
<a
href={this.props.href}
target='_blank'
rel='noopener noreferrer'
data-testid='demo-tooltip-shared-via-link'
>
{'example.com'}
</a>
),
}}
/>
</p>

<p style={style.description}>
<FormattedMessage
id='tooltip.description'
defaultMessage='This is a sample description. Visit {link} for more details.'
values={{
link: (
<a
href={this.props.href}
target='_blank'
rel='noopener noreferrer'
data-testid='demo-tooltip-description-link'
>
{'the original page'}
</a>
),
}}
/>
</p>
</div>
</div>
);
}
}

const getStyle = (theme) => ({
configuration: {
container: {
borderRadius: '4px',
boxShadow: 'rgba(61, 60, 64, 0.1) 0px 17px 50px 0px, rgba(61, 60, 64, 0.1) 0px 12px 15px 0px',
fontSize: '14px',
Expand All @@ -42,6 +101,30 @@ const getStyle = (theme) => ({
color: theme.centerChannelColor,
backgroundColor: theme.centerChannelBg,
},
header: {
marginBottom: '8px',
},
body: {
paddingLeft: '4px',
},
titleLink: {
display: 'block',
fontWeight: '600',
fontSize: '14px',
textDecoration: 'none',
color: theme.centerChannelColor,
},
sharedVia: {
fontSize: '12px',
marginTop: '4px',
color: hexToRGB(theme.centerChannelColor, '0.64'),
},
description: {
fontSize: '12px',
marginTop: '8px',
lineHeight: '1.25',
color: theme.centerChannelColor,
},
});

const iconStyles = {
Expand Down
Loading