Skip to content

Commit

Permalink
fix: enable users to select any non multi bot template during add new…
Browse files Browse the repository at this point in the history
… skills flow (#7494)

* Fix wording and routing in addBotModal

* Adding isMultiBot boolean value to botTemplate type

* setting isMultiBotTemplate based on keyword value from template generator

* Adding logic to not show multibot template if you are in the add skills flow

* Adjusting unit test for new botTEmplate multibot variable

* Adding formatMessages

* Removing unneeded code in conditional
  • Loading branch information
pavolum authored Apr 29, 2021
1 parent 310e3d5 commit 322a901
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ interface AddBotModalProps {
onDismiss: () => void;
}

const addExistingKey = 'existing';
const addBlankKey = 'blank';
const addExistingBotKey = 'existing';
const addNewBotKey = 'new';

const addSkillOptions: IChoiceGroupOption[] = [
{ key: addExistingKey, text: 'Add an existing bot' },
{ key: addBlankKey, text: 'Create a new blank bot' },
const getAddSkillOptions = (): IChoiceGroupOption[] => [
{ key: addNewBotKey, text: formatMessage('Create a new bot') },
{ key: addExistingBotKey, text: formatMessage('Add an existing bot') },
];

export const AddBotModal: React.FC<AddBotModalProps> = (props) => {
const { setCreationFlowStatus } = useRecoilValue(dispatcherState);
const [addBotType, setAddBotType] = useState(addExistingKey);
const [addBotType, setAddBotType] = useState(addNewBotKey);

const handleChange = (ev?, option?: IChoiceGroupOption): void => {
if (option) {
Expand All @@ -35,10 +35,10 @@ export const AddBotModal: React.FC<AddBotModalProps> = (props) => {
};

const handleSubmit = () => {
if (addBotType === addExistingKey) {
if (addBotType === addExistingBotKey) {
setCreationFlowStatus(CreationFlowStatus.OPEN);
} else {
setCreationFlowStatus(CreationFlowStatus.NEW_FROM_TEMPLATE);
setCreationFlowStatus(CreationFlowStatus.NEW);
}
};

Expand All @@ -50,7 +50,7 @@ export const AddBotModal: React.FC<AddBotModalProps> = (props) => {
title={formatMessage('Add a bot')}
onDismiss={props.onDismiss}
>
<ChoiceGroup required defaultSelectedKey={addExistingKey} options={addSkillOptions} onChange={handleChange} />
<ChoiceGroup required defaultSelectedKey={addNewBotKey} options={getAddSkillOptions()} onChange={handleChange} />
<DialogFooter>
<DefaultButton text={formatMessage('Cancel')} onClick={props.onDismiss} />
<PrimaryButton data-testid="NextStepButton" text={formatMessage('Next')} onClick={handleSubmit} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,17 +199,22 @@ export function CreateBotV2(props: CreateBotProps) {

useEffect(() => {
const itemKey = selectedProgLang.props.itemKey;
let newTemplates: BotTemplate[] = [];
if (itemKey === csharpFeedKey) {
const newTemplates = templates.filter((template) => {
newTemplates = templates.filter((template) => {
return template.dotnetSupport;
});
setDisplayedTemplates(newTemplates);
} else if (itemKey === nodeFeedKey) {
const newTemplates = templates.filter((template) => {
newTemplates = templates.filter((template) => {
return template.nodeSupport;
});
setDisplayedTemplates(newTemplates);
}
if (creationFlowType === 'Skill') {
newTemplates = newTemplates.filter((template) => {
return !template.isMultiBotTemplate;
});
}
setDisplayedTemplates(newTemplates);
}, [templates, selectedProgLang]);

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ describe('assetManager', () => {
id: 'generator-conversational-core',
name: 'Conversational Core',
description: 'Preview conversational core package for TESTING ONLY',
isMultiBotTemplate: false,
package: {
packageName: 'generator-conversational-core',
packageSource: 'npm',
Expand Down
1 change: 1 addition & 0 deletions Composer/packages/server/src/models/asset/assetManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ export class AssetManager {
webAppSupported: keywords.includes('bf-js-webapp'),
};
}
templateToReturn.isMultiBotTemplate = keywords.includes('msbot-multibot-project');
}
return templateToReturn;
});
Expand Down
1 change: 1 addition & 0 deletions Composer/packages/types/src/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export type BotTemplate = {
id: string;
name: string;
description: string;
isMultiBotTemplate?: boolean;
nodeSupport?: EnvSupport;
dotnetSupport?: EnvSupport;
/* absolute path */
Expand Down

0 comments on commit 322a901

Please sign in to comment.