Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: show bot url as tooltip #2676

Merged
merged 15 commits into from
Apr 21, 2020
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 @@ -11,7 +11,12 @@ describe('<EmulatorOpenButton />', () => {
it('should show the button to open emulator', () => {
const onClick = jest.fn(() => {});
const { container, getByText } = render(
<EmulatorOpenButton onClick={onClick} botStatus={BotStatus.connected} hidden={false} />
<EmulatorOpenButton
botEndpoint={'http://localhost:3979/api/messages'}
onClick={onClick}
botStatus={BotStatus.connected}
hidden={false}
/>
);

expect(container).toHaveTextContent('Test in Emulator');
Expand All @@ -24,7 +29,12 @@ describe('<EmulatorOpenButton />', () => {
it('should hidden the button if set hidden', () => {
const onClick = jest.fn(() => {});
const { container } = render(
<EmulatorOpenButton onClick={onClick} botStatus={BotStatus.connected} hidden={true} />
<EmulatorOpenButton
botEndpoint={'http://localhost:3979/api/messages'}
onClick={onClick}
botStatus={BotStatus.connected}
hidden={true}
/>
);

expect(container).not.toHaveTextContent('Test in Emulator');
Expand All @@ -33,7 +43,12 @@ describe('<EmulatorOpenButton />', () => {
it('should show the button if the bot status is not connected', () => {
const onClick = jest.fn(() => {});
const { container } = render(
<EmulatorOpenButton onClick={onClick} botStatus={BotStatus.publishing} hidden={false} />
<EmulatorOpenButton
botEndpoint={'http://localhost:3979/api/messages'}
onClick={onClick}
botStatus={BotStatus.publishing}
hidden={false}
/>
);

expect(container).not.toHaveTextContent('Test in Emulator');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,42 @@
/** @jsx jsx */
import { jsx } from '@emotion/core';
import formatMessage from 'format-message';
import { ActionButton } from 'office-ui-fabric-react/lib/Button';
import { ActionButton, IconButton } from 'office-ui-fabric-react/lib/Button';
import { TooltipHost } from 'office-ui-fabric-react/lib/Tooltip';
import { Fragment } from 'react';

import { BotStatus } from './../../constants';

interface IEmulatorOpenButtonProps {
botEndpoint: string;
botStatus: BotStatus;
hidden: boolean;
onClick: () => void;
}

export const EmulatorOpenButton: React.FC<IEmulatorOpenButtonProps> = props => {
const { onClick, botStatus, hidden } = props;
const { onClick, botStatus, hidden, botEndpoint } = props;
const connected = botStatus === BotStatus.connected;

if (hidden || !connected) return null;

return (
<ActionButton
iconProps={{
iconName: 'OpenInNewTab',
}}
onClick={onClick}
<TooltipHost
content={
<Fragment>
{botEndpoint}
<IconButton iconProps={{ iconName: 'copy' }} onClick={() => navigator.clipboard.writeText(botEndpoint)} />
</Fragment>
}
>
{formatMessage('Test in Emulator')}
</ActionButton>
<ActionButton
iconProps={{
iconName: 'OpenInNewTab',
}}
onClick={onClick}
>
{formatMessage('Test in Emulator')}
</ActionButton>
</TooltipHost>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,12 @@ export const TestController: React.FC = () => {
return (
<Fragment>
<div css={bot} ref={botActionRef}>
<EmulatorOpenButton botStatus={botStatus} hidden={showError} onClick={handleOpenEmulator} />
<EmulatorOpenButton
botEndpoint={botEndpoints[projectId] || 'http://localhost:3979/api/messages'}
botStatus={botStatus}
hidden={showError}
onClick={handleOpenEmulator}
/>
<Loading botStatus={botStatus} />
<div ref={addRef}>
<ErrorInfo hidden={!showError} onClick={handleErrorButtonClick} count={errorLength} />
Expand Down