From 4548f15d523ec3e6d5ce04afd6181fec5d42b6c9 Mon Sep 17 00:00:00 2001 From: GeoffCoxMSFT Date: Thu, 25 Mar 2021 09:59:45 -0700 Subject: [PATCH 1/4] Added delete action to list of publish targets --- .../src/pages/botProject/PublishTargets.tsx | 33 ++++++++++++++++++- .../packages/server/src/locales/en-US.json | 18 ++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/Composer/packages/client/src/pages/botProject/PublishTargets.tsx b/Composer/packages/client/src/pages/botProject/PublishTargets.tsx index 5407abc160..4496b0e16e 100644 --- a/Composer/packages/client/src/pages/botProject/PublishTargets.tsx +++ b/Composer/packages/client/src/pages/botProject/PublishTargets.tsx @@ -2,7 +2,7 @@ // Licensed under the MIT License. /** @jsx jsx */ -import React, { Fragment, useState, useEffect } from 'react'; +import React, { Fragment, useState, useEffect, useCallback } from 'react'; import { jsx, css } from '@emotion/core'; import { useRecoilValue } from 'recoil'; import { PublishTarget } from '@bfc/shared'; @@ -10,6 +10,7 @@ import formatMessage from 'format-message'; import { ActionButton } from 'office-ui-fabric-react/lib/Button'; import { FontWeights } from 'office-ui-fabric-react/lib/Styling'; import { SharedColors } from '@uifabric/fluent-theme'; +import { OpenConfirmModal } from '@bfc/ui-shared'; import { dispatcherState, settingsState, publishTypesState } from '../../recoilModel'; import { CollapsableWrapper } from '../../components/CollapsableWrapper'; @@ -83,6 +84,26 @@ export const PublishTargets: React.FC = (props) => { } }, [scrollToSectionId]); + const onDeletePublishTarget = useCallback( + async (publishTarget: PublishTarget) => { + if (publishTargets) { + const targetName = publishTarget.name; + const confirmed = await OpenConfirmModal( + formatMessage('Delete?'), + formatMessage( + 'Are you sure you want to remove "{targetName}"? This will remove only the profile and will not delete provisioned resources.', + { targetName } + ) + ); + if (confirmed) { + const newPublishTargets = publishTargets.filter((t) => t.name !== targetName); + setPublishTargets(newPublishTargets, projectId); + } + } + }, + [projectId, publishTargets] + ); + return ( @@ -103,6 +124,7 @@ export const PublishTargets: React.FC = (props) => {
{ setCurrent({ item: p, index: index }); @@ -116,6 +138,15 @@ export const PublishTargets: React.FC = (props) => { {formatMessage('Edit')}
+
+ onDeletePublishTarget(p)} + > + {formatMessage('Delete')} + +
); })} diff --git a/Composer/packages/server/src/locales/en-US.json b/Composer/packages/server/src/locales/en-US.json index 37b101e51f..015dfdd026 100644 --- a/Composer/packages/server/src/locales/en-US.json +++ b/Composer/packages/server/src/locales/en-US.json @@ -305,6 +305,9 @@ "are_you_sure_you_want_to_remove_propertyname_8a793e4f": { "message": "Are you sure you want to remove \"{ propertyName }\"?" }, + "are_you_sure_you_want_to_remove_targetname_this_wi_9d9d1d80": { + "message": "Are you sure you want to remove \"{ targetName }\"? This will remove only the profile and will not delete provisioned resources." + }, "are_you_sure_you_want_to_remove_this_property_5bfb9cb5": { "message": "Are you sure you want to remove this property?" }, @@ -698,6 +701,9 @@ "connect_to_a_skill_53c9dff0": { "message": "Connect to a skill" }, + "connect_to_an_existing_bot_7f42990b": { + "message": "Connect to an existing bot" + }, "connect_to_qna_knowledgebase_4b324132": { "message": "Connect to QnA Knowledgebase" }, @@ -776,6 +782,9 @@ "create_a_name_for_the_project_which_will_be_used_t_57e9b690": { "message": "Create a name for the project which will be used to name the application: (projectname-environment-LUfilename)" }, + "create_a_new_bot_51ce70d3": { + "message": "Create a new bot" + }, "create_a_new_dialog_21d84b82": { "message": "Create a new dialog" }, @@ -953,6 +962,9 @@ "delete_bot_73586104": { "message": "Delete Bot" }, + "delete_fd07d6ad": { + "message": "Delete?" + }, "delete_form_dialog_schema_c8e28229": { "message": "Delete form dialog schema?" }, @@ -1079,6 +1091,9 @@ "display_text_used_by_the_channel_to_render_visuall_4e4ab704": { "message": "Display text used by the channel to render visually." }, + "do_you_want_to_create_a_new_bot_or_connect_your_az_f5c9dee": { + "message": "Do you want to create a new bot, or connect your Azure Bot resource to an existing bot?" + }, "do_you_want_to_proceed_cd35aa38": { "message": "Do you want to proceed?" }, @@ -2348,6 +2363,9 @@ "open_web_chat_7a24d4f8": { "message": "Open web chat" }, + "open_your_azure_bot_resource_9165e3d1": { + "message": "Open your Azure Bot resource" + }, "optional_221bcc9d": { "message": "Optional" }, From 1f304e140e1b24b18aec7aac2b5742263d73068a Mon Sep 17 00:00:00 2001 From: GeoffCoxMSFT Date: Thu, 25 Mar 2021 10:12:44 -0700 Subject: [PATCH 2/4] Updated string to avoid extra quotes --- .../packages/client/src/pages/botProject/PublishTargets.tsx | 2 +- Composer/packages/server/src/locales/en-US.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Composer/packages/client/src/pages/botProject/PublishTargets.tsx b/Composer/packages/client/src/pages/botProject/PublishTargets.tsx index 4496b0e16e..02677f521d 100644 --- a/Composer/packages/client/src/pages/botProject/PublishTargets.tsx +++ b/Composer/packages/client/src/pages/botProject/PublishTargets.tsx @@ -91,7 +91,7 @@ export const PublishTargets: React.FC = (props) => { const confirmed = await OpenConfirmModal( formatMessage('Delete?'), formatMessage( - 'Are you sure you want to remove "{targetName}"? This will remove only the profile and will not delete provisioned resources.', + 'Are you sure you want to remove {targetName}? This will remove only the profile and will not delete provisioned resources.', { targetName } ) ); diff --git a/Composer/packages/server/src/locales/en-US.json b/Composer/packages/server/src/locales/en-US.json index 015dfdd026..de4a57c09f 100644 --- a/Composer/packages/server/src/locales/en-US.json +++ b/Composer/packages/server/src/locales/en-US.json @@ -305,8 +305,8 @@ "are_you_sure_you_want_to_remove_propertyname_8a793e4f": { "message": "Are you sure you want to remove \"{ propertyName }\"?" }, - "are_you_sure_you_want_to_remove_targetname_this_wi_9d9d1d80": { - "message": "Are you sure you want to remove \"{ targetName }\"? This will remove only the profile and will not delete provisioned resources." + "are_you_sure_you_want_to_remove_targetname_this_wi_b3ddce54": { + "message": "Are you sure you want to remove { targetName }? This will remove only the profile and will not delete provisioned resources." }, "are_you_sure_you_want_to_remove_this_property_5bfb9cb5": { "message": "Are you sure you want to remove this property?" From 8f3ba1b44332f60d8bd12491f1a2465777a3e445 Mon Sep 17 00:00:00 2001 From: GeoffCoxMSFT Date: Thu, 25 Mar 2021 10:27:42 -0700 Subject: [PATCH 3/4] Removed the non-useful useCallback --- .../src/pages/botProject/PublishTargets.tsx | 33 +++++++++---------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/Composer/packages/client/src/pages/botProject/PublishTargets.tsx b/Composer/packages/client/src/pages/botProject/PublishTargets.tsx index 02677f521d..d34c645107 100644 --- a/Composer/packages/client/src/pages/botProject/PublishTargets.tsx +++ b/Composer/packages/client/src/pages/botProject/PublishTargets.tsx @@ -84,25 +84,22 @@ export const PublishTargets: React.FC = (props) => { } }, [scrollToSectionId]); - const onDeletePublishTarget = useCallback( - async (publishTarget: PublishTarget) => { - if (publishTargets) { - const targetName = publishTarget.name; - const confirmed = await OpenConfirmModal( - formatMessage('Delete?'), - formatMessage( - 'Are you sure you want to remove {targetName}? This will remove only the profile and will not delete provisioned resources.', - { targetName } - ) - ); - if (confirmed) { - const newPublishTargets = publishTargets.filter((t) => t.name !== targetName); - setPublishTargets(newPublishTargets, projectId); - } + const onDeletePublishTarget = async (publishTarget: PublishTarget) => { + if (publishTargets) { + const targetName = publishTarget.name; + const confirmed = await OpenConfirmModal( + formatMessage('Delete?'), + formatMessage( + 'Are you sure you want to remove {targetName}? This will remove only the profile and will not delete provisioned resources.', + { targetName } + ) + ); + if (confirmed) { + const newPublishTargets = publishTargets.filter((t) => t.name !== targetName); + setPublishTargets(newPublishTargets, projectId); } - }, - [projectId, publishTargets] - ); + } + }; return ( From 74162bd351f05693b08970ac44891f451471198d Mon Sep 17 00:00:00 2001 From: GeoffCoxMSFT Date: Thu, 25 Mar 2021 11:36:23 -0700 Subject: [PATCH 4/4] Remove import of useCallback --- .../packages/client/src/pages/botProject/PublishTargets.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Composer/packages/client/src/pages/botProject/PublishTargets.tsx b/Composer/packages/client/src/pages/botProject/PublishTargets.tsx index d34c645107..6695a15edb 100644 --- a/Composer/packages/client/src/pages/botProject/PublishTargets.tsx +++ b/Composer/packages/client/src/pages/botProject/PublishTargets.tsx @@ -2,7 +2,7 @@ // Licensed under the MIT License. /** @jsx jsx */ -import React, { Fragment, useState, useEffect, useCallback } from 'react'; +import React, { Fragment, useState, useEffect } from 'react'; import { jsx, css } from '@emotion/core'; import { useRecoilValue } from 'recoil'; import { PublishTarget } from '@bfc/shared';