Skip to content

Commit

Permalink
Prevent passing props to activity middleware (#2105)
Browse files Browse the repository at this point in the history
* Prevent passing props to activity middleware

* Package lock updated

* Changelog updated

* Corrected changelog
  • Loading branch information
srinaath authored Mar 13, 2020
1 parent 186d8e2 commit 4e714bf
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 23 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## v4.8.1 - 2019 - 03 - 16
## Fixed

- [client] Fixed an issue where Restart activity wont appear on selected activity after restarting once in PR [2103](https://github.com/microsoft/BotFramework-Emulator/pull/2103)
- [build] Replaced a missing .icns file that was deleted by mistake in a previous PR. Fixes the app icon on Linux & Mac in PR [2104](https://github.com/microsoft/BotFramework-Emulator/pull/2104)
- [client] Fixed an issue where Restart activity wont appear on selected activity after restarting once in PR [2105](https://github.com/microsoft/BotFramework-Emulator/pull/2105)


## v4.8.0 - 2019 - 03 - 12
## Added
Expand Down
24 changes: 12 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -139,18 +139,13 @@ export class Chat extends PureComponent<ChatProps, ChatState> {
}

private activityWrapper(next, card, children): ReactNode {
const { mode, restartStatus } = this.props;
const isWebChatDisabled =
mode === 'transcript' || mode === 'debug' || restartStatus === RestartConversationStatus.Started;
return (
<OuterActivityWrapperContainer
card={card}
documentId={this.props.documentId}
onContextMenu={this.onContextMenu}
onItemRendererClick={this.onItemRendererClick}
onItemRendererKeyDown={this.onItemRendererKeyDown}
restartStatusForActivity={this.props.restartStatus}
isWebChatDisabled={isWebChatDisabled}
>
{next(card)(children)}
</OuterActivityWrapperContainer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import * as React from 'react';
import { createStore } from 'redux';
import { Provider } from 'react-redux';
import { mount, shallow } from 'enzyme';
import { ValueTypes, RestartConversationOptions } from '@bfemulator/app-shared';
import { ValueTypes, RestartConversationOptions, RestartConversationStatus } from '@bfemulator/app-shared';

import { OuterActivityWrapper } from './outerActivityWrapper';
import { OuterActivityWrapperContainer } from './outerActivityWrapperContainer';
Expand All @@ -49,7 +49,9 @@ describe('<OuterActivityWrapper />', () => {
highlightedObjects: [],
inspectorObjects: [{ value: {}, valueType: ValueTypes.Activity }],
},
restartStatus: {},
},
restartStatus: {
doc1: RestartConversationStatus.Stop,
},
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import * as React from 'react';
import { SharedConstants, RestartConversationOptions } from '@bfemulator/app-shared';
import { Activity } from 'botframework-schema';
import { RestartConversationStatus } from '@bfemulator/app-shared';
import { EmulatorMode } from '@bfemulator/sdk-shared';

import { areActivitiesEqual } from '../../../../../utils';

Expand All @@ -54,15 +55,27 @@ export interface OuterActivityWrapperProps {
restartOption: RestartConversationOptions
) => void;
currentRestartConversationOption: RestartConversationOptions;
isWebChatDisabled: boolean;
mode: EmulatorMode;
restartStatus: RestartConversationStatus;
}

export class OuterActivityWrapper extends React.Component<OuterActivityWrapperProps, {}> {
public render() {
const { card, children, onContextMenu, onItemRendererClick, onItemRendererKeyDown, isWebChatDisabled } = this.props;
const {
card,
children,
onContextMenu,
onItemRendererClick,
onItemRendererKeyDown,
mode,
restartStatus,
} = this.props;

const isSelected = this.shouldBeSelected(card.activity);
const isUserActivity = this.isUserActivity(card.activity);
const isWebChatDisabled =
mode === 'transcript' || mode === 'debug' || restartStatus === RestartConversationStatus.Started;

const showRestartBubble = isUserActivity && isSelected && !isWebChatDisabled;

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ function mapStateToProps(state: RootState, { documentId }: { documentId: string
highlightedActivities,
documentId,
currentRestartConversationOption: state.chat.chats[documentId].restartConversationOption,
mode: state.chat.chats[documentId].mode,
restartStatus: state.chat.restartStatus[documentId],
};
}

Expand Down

0 comments on commit 4e714bf

Please sign in to comment.