Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ exports[`should only render permalink panel when there are no other panels 1`] =
panels={
Array [
Object {
"content": <UrlPanelContent
"content": <InjectIntl(UrlPanelContentUI)
getUnhashableStates={[Function]}
objectType="dashboard"
/>,
Expand All @@ -26,15 +26,15 @@ exports[`should render context menu panel when there are more than one panel 1`]
panels={
Array [
Object {
"content": <UrlPanelContent
"content": <InjectIntl(UrlPanelContentUI)
getUnhashableStates={[Function]}
objectType="dashboard"
/>,
"id": 1,
"title": "Permalink",
},
Object {
"content": <UrlPanelContent
"content": <InjectIntl(UrlPanelContentUI)
getUnhashableStates={[Function]}
isEmbedded={true}
objectType="dashboard"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,24 @@ exports[`render 1`] = `
describedByIds={Array []}
fullWidth={false}
hasEmptyLabelSpace={false}
helpText="Can't share as saved object until the dashboard has been saved."
label="Generate the link as"
helpText={
<FormattedMessage
defaultMessage="Can't share as saved object until the {objectType} has been saved."
id="common.ui.share.urlPanel.canNotShareAsSavedObjectHelpText"
values={
Object {
"objectType": "dashboard",
}
}
/>
}
label={
<FormattedMessage
defaultMessage="Generate the link as"
id="common.ui.share.urlPanel.generateLinkAsLabel"
values={Object {}}
/>
}
>
<EuiRadioGroup
idSelected="snapshot"
Expand All @@ -33,16 +49,30 @@ exports[`render 1`] = `
component="div"
grow={true}
>
Snapshot
<FormattedMessage
defaultMessage="Snapshot"
id="common.ui.share.urlPanel.snapshotLabel"
values={Object {}}
/>
</EuiFlexItem>
<EuiFlexItem
component="div"
grow={false}
>
<EuiIconTip
aria-label="Info"
content="Snapshot URLs encode the current state of the dashboard in the URL itself.
Edits to the saved dashboard won't be visible via this URL."
content={
<FormattedMessage
defaultMessage="Snapshot URLs encode the current state of the {objectType} in the URL itself.
Edits to the saved {objectType} won't be visible via this URL."
id="common.ui.share.urlPanel.snapshotDescription"
values={
Object {
"objectType": "dashboard",
}
}
/>
}
position="bottom"
type="questionInCircle"
/>
Expand All @@ -66,15 +96,29 @@ exports[`render 1`] = `
component="div"
grow={true}
>
Saved object
<FormattedMessage
defaultMessage="Saved object"
id="common.ui.share.urlPanel.savedObjectLabel"
values={Object {}}
/>
</EuiFlexItem>
<EuiFlexItem
component="div"
grow={false}
>
<EuiIconTip
aria-label="Info"
content="You can share this URL with people to let them load the most recent saved version of this dashboard."
content={
<FormattedMessage
defaultMessage="You can share this URL with people to let them load the most recent saved version of this {objectType}."
id="common.ui.share.urlPanel.savedObjectDescription"
values={
Object {
"objectType": "dashboard",
}
}
/>
}
position="bottom"
type="questionInCircle"
/>
Expand Down Expand Up @@ -106,7 +150,13 @@ exports[`render 1`] = `
<EuiSwitch
checked={false}
data-test-subj="useShortUrl"
label="Short URL"
label={
<FormattedMessage
defaultMessage="Short URL"
id="common.ui.share.urlPanel.shortUrlLabel"
values={Object {}}
/>
}
onChange={[Function]}
/>
</EuiFlexItem>
Expand All @@ -116,10 +166,16 @@ exports[`render 1`] = `
>
<EuiIconTip
aria-label="Info"
content="We recommend sharing shortened snapshot URLs for maximum compatibility.
Internet Explorer has URL length restrictions,
and some wiki and markup parsers don't do well with the full-length version of the snapshot URL,
but the short URL should work great."
content={
<FormattedMessage
defaultMessage="We recommend sharing shortened snapshot URLs for maximum compatibility.
Internet Explorer has URL length restrictions,
and some wiki and markup parsers don't do well with the full-length version of the snapshot URL,
but the short URL should work great."
id="common.ui.share.urlPanel.shortUrlHelpText"
values={Object {}}
/>
}
position="bottom"
type="questionInCircle"
/>
Expand All @@ -143,7 +199,13 @@ exports[`should enable saved object export option when objectId is provided 1`]
describedByIds={Array []}
fullWidth={false}
hasEmptyLabelSpace={false}
label="Generate the link as"
label={
<FormattedMessage
defaultMessage="Generate the link as"
id="common.ui.share.urlPanel.generateLinkAsLabel"
values={Object {}}
/>
}
>
<EuiRadioGroup
idSelected="snapshot"
Expand All @@ -166,16 +228,30 @@ exports[`should enable saved object export option when objectId is provided 1`]
component="div"
grow={true}
>
Snapshot
<FormattedMessage
defaultMessage="Snapshot"
id="common.ui.share.urlPanel.snapshotLabel"
values={Object {}}
/>
</EuiFlexItem>
<EuiFlexItem
component="div"
grow={false}
>
<EuiIconTip
aria-label="Info"
content="Snapshot URLs encode the current state of the dashboard in the URL itself.
Edits to the saved dashboard won't be visible via this URL."
content={
<FormattedMessage
defaultMessage="Snapshot URLs encode the current state of the {objectType} in the URL itself.
Edits to the saved {objectType} won't be visible via this URL."
id="common.ui.share.urlPanel.snapshotDescription"
values={
Object {
"objectType": "dashboard",
}
}
/>
}
position="bottom"
type="questionInCircle"
/>
Expand All @@ -199,15 +275,29 @@ exports[`should enable saved object export option when objectId is provided 1`]
component="div"
grow={true}
>
Saved object
<FormattedMessage
defaultMessage="Saved object"
id="common.ui.share.urlPanel.savedObjectLabel"
values={Object {}}
/>
</EuiFlexItem>
<EuiFlexItem
component="div"
grow={false}
>
<EuiIconTip
aria-label="Info"
content="You can share this URL with people to let them load the most recent saved version of this dashboard."
content={
<FormattedMessage
defaultMessage="You can share this URL with people to let them load the most recent saved version of this {objectType}."
id="common.ui.share.urlPanel.savedObjectDescription"
values={
Object {
"objectType": "dashboard",
}
}
/>
}
position="bottom"
type="questionInCircle"
/>
Expand Down Expand Up @@ -239,7 +329,13 @@ exports[`should enable saved object export option when objectId is provided 1`]
<EuiSwitch
checked={false}
data-test-subj="useShortUrl"
label="Short URL"
label={
<FormattedMessage
defaultMessage="Short URL"
id="common.ui.share.urlPanel.shortUrlLabel"
values={Object {}}
/>
}
onChange={[Function]}
/>
</EuiFlexItem>
Expand All @@ -249,10 +345,16 @@ exports[`should enable saved object export option when objectId is provided 1`]
>
<EuiIconTip
aria-label="Info"
content="We recommend sharing shortened snapshot URLs for maximum compatibility.
Internet Explorer has URL length restrictions,
and some wiki and markup parsers don't do well with the full-length version of the snapshot URL,
but the short URL should work great."
content={
<FormattedMessage
defaultMessage="We recommend sharing shortened snapshot URLs for maximum compatibility.
Internet Explorer has URL length restrictions,
and some wiki and markup parsers don't do well with the full-length version of the snapshot URL,
but the short URL should work great."
id="common.ui.share.urlPanel.shortUrlHelpText"
values={Object {}}
/>
}
position="bottom"
type="questionInCircle"
/>
Expand Down
6 changes: 3 additions & 3 deletions src/ui/public/share/components/share_context_menu.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
jest.mock('../lib/url_shortener', () => ({}));

import React from 'react';
import { shallow } from 'enzyme';
import { shallowWithIntl } from 'test_utils/enzyme_helpers';

import {
ShareContextMenu,
} from './share_context_menu';

test('should render context menu panel when there are more than one panel', () => {
const component = shallow(<ShareContextMenu
const component = shallowWithIntl(<ShareContextMenu.WrappedComponent
allowEmbed
objectType="dashboard"
getUnhashableStates={() => {}}
Expand All @@ -36,7 +36,7 @@ test('should render context menu panel when there are more than one panel', () =
});

test('should only render permalink panel when there are no other panels', () => {
const component = shallow(<ShareContextMenu
const component = shallowWithIntl(<ShareContextMenu.WrappedComponent
allowEmbed={false}
objectType="dashboard"
getUnhashableStates={() => {}}
Expand Down
37 changes: 31 additions & 6 deletions src/ui/public/share/components/share_context_menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import './share_panel_content.less';
import { EuiContextMenuPanelDescriptor } from '@elastic/eui';
import { EuiContextMenu } from '@elastic/eui';

import { InjectedIntl, injectI18n } from '@kbn/i18n/react';
import { ShareAction, ShareActionProvider, ShareContextMenuPanelItem } from 'ui/share/share_action';
import { UrlPanelContent } from './url_panel_content';

Expand All @@ -35,9 +36,10 @@ interface Props {
sharingData: any;
isDirty: boolean;
onClose: () => void;
intl: InjectedIntl;
}

export class ShareContextMenu extends Component<Props> {
class ShareContextMenuUI extends Component<Props> {
public render() {
const { panels, initialPanelId } = this.getPanels();
return (
Expand All @@ -52,10 +54,14 @@ export class ShareContextMenu extends Component<Props> {
private getPanels = () => {
const panels: EuiContextMenuPanelDescriptor[] = [];
const menuItems: ShareContextMenuPanelItem[] = [];
const { intl } = this.props;

const permalinkPanel = {
id: panels.length + 1,
title: 'Permalink',
title: intl.formatMessage({
id: 'common.ui.share.contextMenu.permalinkPanelTitle',
defaultMessage: 'Permalink',
}),
content: (
<UrlPanelContent
objectId={this.props.objectId}
Expand All @@ -65,7 +71,10 @@ export class ShareContextMenu extends Component<Props> {
),
};
menuItems.push({
name: 'Permalinks',
name: intl.formatMessage({
id: 'common.ui.share.contextMenu.permalinksLabel',
defaultMessage: 'Permalinks',
}),
icon: 'link',
panel: permalinkPanel.id,
sortOrder: 0,
Expand All @@ -75,7 +84,10 @@ export class ShareContextMenu extends Component<Props> {
if (this.props.allowEmbed) {
const embedPanel = {
id: panels.length + 1,
title: 'Embed Code',
title: intl.formatMessage({
id: 'common.ui.share.contextMenu.embedCodePanelTitle',
defaultMessage: 'Embed Code',
}),
content: (
<UrlPanelContent
isEmbedded
Expand All @@ -87,7 +99,10 @@ export class ShareContextMenu extends Component<Props> {
};
panels.push(embedPanel);
menuItems.push({
name: 'Embed code',
name: intl.formatMessage({
id: 'common.ui.share.contextMenu.embedCodeLabel',
defaultMessage: 'Embed code',
}),
icon: 'console',
panel: embedPanel.id,
sortOrder: 0,
Expand Down Expand Up @@ -130,7 +145,15 @@ export class ShareContextMenu extends Component<Props> {
if (menuItems.length > 1) {
const topLevelMenuPanel = {
id: panels.length + 1,
title: `Share this ${this.props.objectType}`,
title: intl.formatMessage(
{
id: 'common.ui.share.contextMenuTitle',
defaultMessage: 'Share this {objectType}',
},
{
objectType: this.props.objectType,
}
),
items: menuItems
.map(menuItem => {
menuItem['data-test-subj'] = `sharePanel-${menuItem.name.replace(' ', '')}`;
Expand Down Expand Up @@ -161,3 +184,5 @@ export class ShareContextMenu extends Component<Props> {
return { panels, initialPanelId };
};
}

export const ShareContextMenu = injectI18n(ShareContextMenuUI);
Loading