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

Added the ability to open a bot from just a URL #1232

Merged
merged 2 commits into from
Jan 16, 2019

Conversation

justinwilaby
Copy link
Contributor

This PR Fixes #1209 by adding the ability to connect to a bot by just a URL

To Test

  1. pull down this branch and build as normal then run the Emulator from sources
  2. On the welcome page or the left hand panel or the file menu, choose open bot.
    ** Observe ** A new UI dialog is presented with the ability to type in a URL, browse for a bot file or choose from a list of previously opened bots.
  3. Without opening a bot file, type a url in the input and choose open/connect
    ** Observe ** A new chat tab is is opened with a connection to the specified url.

@justinwilaby justinwilaby force-pushed the jwilaby/#1209-open-bot-via-url branch from 8884635 to 9e0daa7 Compare January 15, 2019 20:15
@coveralls
Copy link

coveralls commented Jan 15, 2019

Pull Request Test Coverage Report for Build 1799

  • 88 of 89 (98.88%) changed or added relevant lines in 13 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.3%) to 61.399%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/app/main/src/appMenuBuilder.ts 0 1 0.0%
Totals Coverage Status
Change from base Build 1781: 0.3%
Covered Lines: 5420
Relevant Lines: 7912

💛 - Coveralls

tonyanziano
tonyanziano previously approved these changes Jan 16, 2019
Copy link
Contributor

@tonyanziano tonyanziano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor nitpicks and some missing license headers.

:shipit:

@@ -1,11 +1,10 @@
import { SharedConstants } from '@bfemulator/app-shared';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

license

private get startSection(): JSX.Element {
const { onNewBotClick, onOpenBotClick } = this.props;
const { onNewBotClick } = this.props;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a reason onOpenBotClick was removed from the destructuring assignment, but it's still used with this. in front of it on line 91? If so, why is onNewBotClick destructured?

In my opinion, you should either keep both onNewBotClick and onOpenBotClick, or neither.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One function is on props while the other is on this. I'll remove the destructuring assignment.

@justinwilaby justinwilaby merged commit 023c955 into master Jan 16, 2019
@justinwilaby justinwilaby deleted the jwilaby/#1209-open-bot-via-url branch January 16, 2019 17:10
return ''; // Allow empty endpoints
}
if (/(http)(s)?(:\/\/)/.test(endpoint)) {
return endpoint.endsWith('/api/messages') ? '' : `Please include route if necessary: "/api/messages"`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it a requirement for a bot to have an /api/messages endpoint?

title="Open a Bot">
<p>
{ `You can open a bot using just a URL, choose from a list of recently opened bots or ` }
<a href="javascript:void(0);" onClick={ this.onCreateNewBotClick }>create a new bot configuration</a>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a button.

);
}

private onBotClick = (event: React.MouseEvent<HTMLButtonElement>) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, these handlers are better as closures.

onClick = (bot) => ()  => this.props.onBotSelected(bot)

@@ -1,11 +1,10 @@
import { SharedConstants } from '@bfemulator/app-shared';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This didn't get a license

onDeleteBotClick?: (_e: any, path: string) => void;
showContextMenuForBot?: (bot: BotInfo) => void;
recentBots?: BotInfo[];
showOpenBotDialog: () => Promise<any>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we avoid any? It is not very helpful.

signInWithAzure?: () => void;
signOutWithAzure?: () => void;
switchToBot?: (path: string) => Promise<any>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto about avoiding any

const filename = await this.browseForBotFile();
if (!filename) {
filename = await this.browseForBotFile();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -36,34 +36,42 @@ import * as React from 'react';
import * as styles from './botNotOpenExplorer.scss';

export interface BotNotOpenExplorerProps {
onOpenBotClick: () => any;
hasChat?: boolean;
showOpenBotDialog: () => Promise<any>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any


export interface RecentBotsListProps {
onBotSelected?: (bot: BotInfo) => void;
onDeleteBotClick?: (path: string) => Promise<any>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

avoid any

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants