Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Commit

Permalink
feat: ability to specify which action is used for reprompt" rather th…
Browse files Browse the repository at this point in the history
…an "none of the above (#1389)

* feat: none of the above

* fix: code review comments
  • Loading branch information
LarsLiden authored Dec 2, 2019
1 parent ddc2ce6 commit f6de212
Show file tree
Hide file tree
Showing 15 changed files with 903 additions and 397 deletions.
2 changes: 1 addition & 1 deletion src/Utils/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import * as CLM from '@conversationlearner/models'
import * as IntlMessages from '../react-intl-messages'
import * as Const from '../types/const'
import { MessageValue } from 'react-intl'
import * as moment from 'moment'
import * as stringify from 'fast-json-stable-stringify'
import { MessageValue } from 'react-intl'

export function notNullOrUndefined<TValue>(value: TValue | null | undefined): value is TValue {
return value !== null && value !== undefined;
Expand Down
10 changes: 5 additions & 5 deletions src/components/ActionDetailsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import * as ActionPayloadRenderers from './actionPayloadRenderers'
import * as moment from 'moment'
import * as CLM from '@conversationlearner/models'
import AdaptiveCardViewer from './modals/AdaptiveCardViewer/AdaptiveCardViewer'
import actionTypeRenderer from './ActionTypeRenderer'
import { actionTypeRenderer } from './ActionRenderers'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import { State } from '../types'
Expand Down Expand Up @@ -343,7 +343,7 @@ function getColumns(intl: InjectedIntl): IRenderableColumn[] {
return [
{
key: 'actionResponse',
name: Util.formatMessageId(intl, FM.ACTIONDETAILSLIST_COLUMNS_RESPONSE),
name: Util.formatMessageId(intl, FM.ACTIONLIST_COLUMNS_RESPONSE),
fieldName: 'actionResponse',
minWidth: 200,
maxWidth: 400,
Expand Down Expand Up @@ -411,7 +411,7 @@ function getColumns(intl: InjectedIntl): IRenderableColumn[] {
},
{
key: 'actionType',
name: Util.formatMessageId(intl, FM.ACTIONDETAILSLIST_COLUMNS_TYPE),
name: Util.formatMessageId(intl, FM.ACTIONLIST_COLUMNS_TYPE),
fieldName: 'metadata',
minWidth: 100,
maxWidth: 100,
Expand Down Expand Up @@ -471,7 +471,7 @@ function getColumns(intl: InjectedIntl): IRenderableColumn[] {
},
{
key: 'isTerminal',
name: Util.formatMessageId(intl, FM.ACTIONDETAILSLIST_COLUMNS_ISTERMINAL),
name: Util.formatMessageId(intl, FM.ACTIONLIST_COLUMNS_ISTERMINAL),
fieldName: 'isTerminal',
minWidth: 50,
maxWidth: 50,
Expand All @@ -481,7 +481,7 @@ function getColumns(intl: InjectedIntl): IRenderableColumn[] {
},
{
key: 'actionReprompt',
name: Util.formatMessageId(intl, FM.ACTIONDETAILSLIST_COLUMNS_REPROMPT),
name: Util.formatMessageId(intl, FM.ACTIONLIST_COLUMNS_REPROMPT),
fieldName: 'actionReprompt',
minWidth: 70,
isResizable: false,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.cl-actiontype-font {
.cl-actionrenderers-font {
padding: 0.25em;
margin: 5px;
}

.cl-actiontype-font--warning {
.cl-actionrenderers-font--warning {
background-color: var(--color-errorBackground);
margin: 5px;
padding: 0.25em;
Expand Down
94 changes: 94 additions & 0 deletions src/components/ActionRenderers.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
import * as OF from 'office-ui-fabric-react'
import * as CLM from '@conversationlearner/models'
import * as React from 'react'
import * as Util from '../Utils/util'
import * as ActionPayloadRenderers from './actionPayloadRenderers'
import './ActionRenderers.css'

export function actionTypeRenderer(action: CLM.ActionBase | undefined): JSX.Element {
let actionType = action ? action.actionType.toString() : "MISSING ACTION"
let addedStyle = "cl-actionrenderers-font"
if (actionType === CLM.ActionTypes.API_LOCAL) {
if (CLM.ActionBase.isPlaceholderAPI(action)) {
actionType = "API Placeholder"
addedStyle = "cl-actionrenderers-font--warning"
} else {
actionType = "API"
}
}
return <span
className={`${OF.FontClassNames.mediumPlus} ${addedStyle}`}
data-testid="action-details-action-type"
>
{actionType}
</span>
}

export function actionListViewRenderer(
action: CLM.ActionBase,
entities: CLM.EntityBase[],
callbacks: CLM.Callback[],
onClickViewCard: (action: CLM.ActionBase, cardViewerShowOriginal: boolean) => void
): React.ReactNode {

const defaultEntityMap = Util.getDefaultEntityMap(entities)

if (action.actionType === CLM.ActionTypes.TEXT) {
const textAction = new CLM.TextAction(action)
return (
<ActionPayloadRenderers.TextPayloadRendererWithHighlights
textAction={textAction}
entities={entities}
showMissingEntities={true}
/>)
}
else if (action.actionType === CLM.ActionTypes.API_LOCAL) {
const apiAction = new CLM.ApiAction(action)
const callback = callbacks.find(t => t.name === apiAction.name)
return (
<ActionPayloadRenderers.ApiPayloadRendererWithHighlights
apiAction={apiAction}
entities={entities}
callback={callback}
showMissingEntities={true}
/>)
}
else if (action.actionType === CLM.ActionTypes.CARD) {
const cardAction = new CLM.CardAction(action)
return (
<ActionPayloadRenderers.CardPayloadRendererWithHighlights
isValidationError={false}
cardAction={cardAction}
entities={entities}
onClickViewCard={(_, showOriginal) => onClickViewCard(action, showOriginal)}
showMissingEntities={true}
/>)
}
else if (action.actionType === CLM.ActionTypes.END_SESSION) {
const sessionAction = new CLM.SessionAction(action)
return (
<ActionPayloadRenderers.SessionPayloadRendererWithHighlights
sessionAction={sessionAction}
entities={entities}
showMissingEntities={true}
/>)
}
else if (action.actionType === CLM.ActionTypes.SET_ENTITY) {
const [name, value] = Util.setEntityActionDisplay(action, entities)
return <span data-testid="action-scorer-action-set-entity" className={OF.FontClassNames.mediumPlus}>{name}: {value}</span>
}
else if (action.actionType === CLM.ActionTypes.DISPATCH) {
const dispatchAction = new CLM.DispatchAction(action)
return <span data-testid="action-scorer-action-dispatch" className={OF.FontClassNames.mediumPlus}>Dispatch to model: {dispatchAction.modelName}</span>
}
else if (action.actionType === CLM.ActionTypes.CHANGE_MODEL) {
const changeModelAction = new CLM.ChangeModelAction(action)
return <span data-testid="action-scorer-action-change-model" className={OF.FontClassNames.mediumPlus}>Change to model: {changeModelAction.modelName}</span>
}

return <span className={OF.FontClassNames.mediumPlus}>{CLM.ActionBase.GetPayload(action, defaultEntityMap)}</span>
}
27 changes: 0 additions & 27 deletions src/components/ActionTypeRenderer.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@
grid-gap: 0.5em;
}

.cl-action-creator-reprompt {
margin-left: 50px;
}

.cl-action-creator-reprompt-box {
margin-top: 20px;
margin-bottom: 20px;
margin-left: 40px;
}

.cl-action-creator-select-action {
margin-left: 40px;
}

.cl-tag-item-suggestion--add-condition {
background-color: white;
width: 100%;
Expand Down
Loading

0 comments on commit f6de212

Please sign in to comment.