From 0ddabc3eef8262d51ec07de5d9b3321feb8d8030 Mon Sep 17 00:00:00 2001 From: Vamsi Modem Date: Fri, 23 Apr 2021 16:31:05 -0700 Subject: [PATCH 01/10] Removed Signout Link & added title on Add new publishing profile --- .../src/components/ChooseProvisionAction.tsx | 1 + .../src/components/azureProvisionDialog.tsx | 25 ++++++++----------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/extensions/azurePublish/src/components/ChooseProvisionAction.tsx b/extensions/azurePublish/src/components/ChooseProvisionAction.tsx index 054d2f7efe..ec43168949 100644 --- a/extensions/azurePublish/src/components/ChooseProvisionAction.tsx +++ b/extensions/azurePublish/src/components/ChooseProvisionAction.tsx @@ -75,6 +75,7 @@ const LearnMoreLink = styled(Link)` const CreateActionContent = () => { return ( + {formatMessage('Create new resources')} {formatMessage( diff --git a/extensions/azurePublish/src/components/azureProvisionDialog.tsx b/extensions/azurePublish/src/components/azureProvisionDialog.tsx index 72c4e259c7..ae2c1d2b07 100644 --- a/extensions/azurePublish/src/components/azureProvisionDialog.tsx +++ b/extensions/azurePublish/src/components/azureProvisionDialog.tsx @@ -939,28 +939,25 @@ export const AzureProvisionDialog: React.FC = () => { ); const PageFooter = useMemo(() => { + console.log(page); if (page === PageTypes.ChooseAction) { + const isSignedInAndCreateCreationType = currentUser && formData.creationType === 'create'; return ( -
- {currentUser ? ( +
+ {isSignedInAndCreateCreationType ? ( - ) : ( -
{ - clearAll(); - closeDialog(); - logOut(); - }} - > - Sign out -
- )} + ) : null}
Date: Tue, 27 Apr 2021 18:43:57 -0700 Subject: [PATCH 02/10] Add Notification capability to extensions --- .../packages/client/src/shell/useShell.ts | 14 ++++ .../packages/client/src/utils/authClient.ts | 2 + .../src/hooks/useApplicationApi.ts | 4 + Composer/packages/types/src/shell.ts | 18 +++++ .../src/components/azureProvisionDialog.tsx | 77 +++++++++++-------- 5 files changed, 82 insertions(+), 33 deletions(-) diff --git a/Composer/packages/client/src/shell/useShell.ts b/Composer/packages/client/src/shell/useShell.ts index 5bd24d41f4..41113270da 100644 --- a/Composer/packages/client/src/shell/useShell.ts +++ b/Composer/packages/client/src/shell/useShell.ts @@ -11,6 +11,7 @@ import { BotInProject, FeatureFlagKey, SDKKinds, + Notification, } from '@botframework-composer/types'; import { useRecoilValue } from 'recoil'; import formatMessage from 'format-message'; @@ -48,6 +49,7 @@ import { navigateTo } from '../utils/navigation'; import TelemetryClient from '../telemetry/TelemetryClient'; import { lgFilesSelectorFamily } from '../recoilModel/selectors/lg'; import { getMemoryVariables } from '../recoilModel/dispatchers/utils/project'; +import { createNotification } from '../recoilModel/dispatchers/notification'; import { useLgApi } from './lgApi'; import { useLuApi } from './luApi'; @@ -127,6 +129,10 @@ export function useShell(source: EventSource, projectId: string): Shell { reloadProject, setApplicationLevelError, updateRecognizer, + addNotification, + deleteNotification, + hideNotification, + markNotificationAsRead, } = useRecoilValue(dispatcherState); const lgApi = useLgApi(projectId); @@ -279,6 +285,14 @@ export function useShell(source: EventSource, projectId: string): Shell { confirm: OpenConfirmModal, telemetryClient: TelemetryClient, getMemoryVariables, + addNotification: (notificationWithoutId: Notification): string => { + const notification = createNotification(notificationWithoutId); + addNotification(notification); + return notification.id; + }, + deleteNotification, + markNotificationAsRead, + hideNotification, }; const currentDialog = useMemo(() => { diff --git a/Composer/packages/client/src/utils/authClient.ts b/Composer/packages/client/src/utils/authClient.ts index b7014d4c7a..4b0c07ac45 100644 --- a/Composer/packages/client/src/utils/authClient.ts +++ b/Composer/packages/client/src/utils/authClient.ts @@ -93,6 +93,8 @@ async function getAccessToken(options: AuthParameters): Promise { async function logOut() { // clean tenantId cache removeTenantFromCache(); + cleanTokenFromCache('accessToken'); + cleanTokenFromCache('graphToken'); if (isElectron()) { try { const url = '/api/auth/logOut'; diff --git a/Composer/packages/extension-client/src/hooks/useApplicationApi.ts b/Composer/packages/extension-client/src/hooks/useApplicationApi.ts index 239e97704f..7e67ea4c8d 100644 --- a/Composer/packages/extension-client/src/hooks/useApplicationApi.ts +++ b/Composer/packages/extension-client/src/hooks/useApplicationApi.ts @@ -29,6 +29,10 @@ const APPLICATION_KEYS = [ 'api.confirm', 'api.updateFlowZoomRate', 'api.telemetryClient', + 'api.addNotification', + 'api.deleteNotification', + 'api.markNotificationAsRead', + 'api.hideNotification', ]; export function useApplicationApi(): ApplicationContext & ApplicationContextApi { diff --git a/Composer/packages/types/src/shell.ts b/Composer/packages/types/src/shell.ts index f3ef62cbe0..6b85af4375 100644 --- a/Composer/packages/types/src/shell.ts +++ b/Composer/packages/types/src/shell.ts @@ -64,6 +64,20 @@ export type DisabledMenuActions = { reason: string; }; +export type Notification = { + type: 'info' | 'warning' | 'error' | 'pending' | 'success'; + title: string; + description?: string; + retentionTime?: number; + link?: { + label: string; + onClick: () => void; + }; + read?: boolean; + hidden?: boolean; + onRenderCardContent?: ((props: Notification) => JSX.Element) | React.FC; +}; + export type ApplicationContextApi = { navigateTo: (to: string, opts?: { state?: any; replace?: boolean }) => void; updateUserSettings: (settings: Partial) => void; @@ -74,6 +88,10 @@ export type ApplicationContextApi = { confirm: (title: string, subTitle: string, settings?: any) => Promise; updateFlowZoomRate: (currentRate: number) => void; telemetryClient: TelemetryClient; + addNotification: (notification: Notification) => string; + deleteNotification: (id: string) => void; + markNotificationAsRead: (id: string) => void; + hideNotification: (id: string) => void; }; export type ApplicationContext = { diff --git a/extensions/azurePublish/src/components/azureProvisionDialog.tsx b/extensions/azurePublish/src/components/azureProvisionDialog.tsx index 6ca4717527..4fd14c1cd3 100644 --- a/extensions/azurePublish/src/components/azureProvisionDialog.tsx +++ b/extensions/azurePublish/src/components/azureProvisionDialog.tsx @@ -14,11 +14,12 @@ import { useLocalStorage, useTelemetryClient, TelemetryClient, + useApplicationApi, } from '@bfc/extension-client'; import { Subscription } from '@azure/arm-subscriptions/esm/models'; import { DeployLocation, AzureTenant } from '@botframework-composer/types'; import { FluentTheme, NeutralColors } from '@uifabric/fluent-theme'; -import { LoadingSpinner, ProvisionHandoff } from '@bfc/ui-shared'; +import { LoadingSpinner, OpenConfirmModal, ProvisionHandoff } from '@bfc/ui-shared'; import { ScrollablePane, ScrollbarVisibility, @@ -75,7 +76,9 @@ type ProvisionFormData = { }; // ---------- Styles ---------- // - +type ProvisonActionsStylingProps = { + showSignout: boolean; +}; const AddResourcesSectionName = styled(Text)` font-size: ${FluentTheme.fonts.mediumPlus.fontSize}; `; @@ -86,6 +89,12 @@ const ConfigureResourcesSectionName = styled(Text)` margin-bottom: 4px; `; +const ProvisonActions = styled.div((props) => ({ + display: 'flex', + flexFlow: 'row nowrap', + justifyContent: props.showSignout ? 'space-between' : 'flex-end', +})); + const ConfigureResourcesSectionDescription = styled(Text)` font-size: ${FluentTheme.fonts.medium.fontSize}; line-height: ${FontSizes.size14}; @@ -340,6 +349,7 @@ export const AzureProvisionDialog: React.FC = () => { const [handoffInstructions, setHandoffInstructions] = useState(''); const [showHandoff, setShowHandoff] = useState(false); + const { addNotification } = useApplicationApi(); const updateHandoffInstructions = (resources) => { const createLuisResource = resources.filter((r) => r.key === 'luisPrediction').length > 0; const createLuisAuthoringResource = resources.filter((r) => r.key === 'luisAuthoring').length > 0; @@ -739,8 +749,27 @@ export const AzureProvisionDialog: React.FC = () => {
{ - closeDialog(); - logOut(); + OpenConfirmModal( + formatMessage('Sign out from Azure'), + formatMessage('Changes you made may not be saved. Do you wish to continue?'), + { + confirmText: formatMessage('Sign out'), + cancelText: formatMessage('Cancel'), + } + ).then(async (signoutAndCloseProvisionDialog) => { + if (signoutAndCloseProvisionDialog) { + await logOut(); + console.log(addNotification); + if (!currentUser) { + addNotification({ + type: 'info', + title: '', + description: 'You have successfully signed out of Azure', + }); + } + closeDialog(); + } + }); }} > {props.secondaryText} @@ -996,17 +1025,10 @@ export const AzureProvisionDialog: React.FC = () => { ); const PageFooter = useMemo(() => { - console.log(page); + const isSignedInAndCreateCreationType = currentUser && formData.creationType === 'create'; if (page === PageTypes.ChooseAction) { - const isSignedInAndCreateCreationType = currentUser && formData.creationType === 'create'; return ( -
+ {isSignedInAndCreateCreationType ? ( { }} />
-
+ ); } else if (page === PageTypes.ConfigProvision) { return ( -
+ {currentUser ? ( { text={currentUser.name} onRenderSecondaryText={onRenderSecondaryText} /> - ) : ( -
{ - clearAll(); - closeDialog(); - logOut(); - }} - > - {formatMessage('Sign out')} -
- )} + ) : null}
{ }} />
-
+ ); } else if (page === PageTypes.AddResources) { return ( -
- {currentUser ? ( + + {isSignedInAndCreateCreationType ? ( { }} />
-
+ ); } else if (page === PageTypes.ReviewResource) { return ( -
+ {currentUser ? ( { }} />
-
+ ); } else { return ( From 4cf1a6f6eb383cb53d4c9fb914e0c756a1963494 Mon Sep 17 00:00:00 2001 From: Vamsi Modem Date: Tue, 27 Apr 2021 23:08:20 -0700 Subject: [PATCH 03/10] Added notification styles --- .../src/components/azureProvisionDialog.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/extensions/azurePublish/src/components/azureProvisionDialog.tsx b/extensions/azurePublish/src/components/azureProvisionDialog.tsx index dc5c07e99f..55f6ac7c42 100644 --- a/extensions/azurePublish/src/components/azureProvisionDialog.tsx +++ b/extensions/azurePublish/src/components/azureProvisionDialog.tsx @@ -749,7 +749,9 @@ export const AzureProvisionDialog: React.FC = () => { onClick={() => { OpenConfirmModal( formatMessage('Sign out from Azure'), - formatMessage('Changes you made may not be saved. Do you wish to continue?'), + formatMessage( + 'Changes you made may not be saved and the wizard will be closed. Do you wish to continue?' + ), { confirmText: formatMessage('Sign out'), cancelText: formatMessage('Cancel'), @@ -757,12 +759,15 @@ export const AzureProvisionDialog: React.FC = () => { ).then(async (signoutAndCloseProvisionDialog) => { if (signoutAndCloseProvisionDialog) { await logOut(); - console.log(addNotification); if (!currentUser) { addNotification({ type: 'info', title: '', - description: 'You have successfully signed out of Azure', + retentionTime: 5000, + description: formatMessage('You have successfully signed out of Azure'), + onRenderCardContent: (props) => { + return
{props.description}
; + }, }); } closeDialog(); From dde6b95f3f24a513e3d1554ce34980f5643e1276 Mon Sep 17 00:00:00 2001 From: Vamsi Modem Date: Wed, 28 Apr 2021 16:02:25 -0700 Subject: [PATCH 04/10] Modified authClient api --- Composer/packages/client/src/plugins/api.ts | 2 +- .../packages/client/src/utils/authClient.ts | 14 +++---- .../extension-client/src/auth/index.ts | 2 +- .../src/components/azureProvisionDialog.tsx | 37 +++++++++---------- 4 files changed, 27 insertions(+), 28 deletions(-) diff --git a/Composer/packages/client/src/plugins/api.ts b/Composer/packages/client/src/plugins/api.ts index 88bbdf2672..08b1d37511 100644 --- a/Composer/packages/client/src/plugins/api.ts +++ b/Composer/packages/client/src/plugins/api.ts @@ -20,7 +20,7 @@ interface AuthAPI { getAccessToken: (options: AuthParameters) => Promise; // returns an access token getARMTokenForTenant: (tenantId: string) => Promise; // returns an ARM access token for specified tenant getTenants: () => Promise; // signs a user in and returns available Azure tenants for the user - logOut: () => Promise; + logOut: () => Promise; } interface PublishAPI { diff --git a/Composer/packages/client/src/utils/authClient.ts b/Composer/packages/client/src/utils/authClient.ts index 4b0c07ac45..2bcaa8244a 100644 --- a/Composer/packages/client/src/utils/authClient.ts +++ b/Composer/packages/client/src/utils/authClient.ts @@ -1,6 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +import { promises } from 'fs'; + import { AuthParameters, AzureTenant } from '@botframework-composer/types'; import { authConfig } from '../constants'; @@ -96,18 +98,16 @@ async function logOut() { cleanTokenFromCache('accessToken'); cleanTokenFromCache('graphToken'); if (isElectron()) { - try { - const url = '/api/auth/logOut'; - await fetch(url, { method: 'GET' }); - } catch (e) { - // error handling - console.error('Can not log out'); - } + const url = '/api/auth/logOut'; + const result = await fetch(url, { method: 'GET' }); + return result.ok; } else if (authConfig.clientId) { // clean token cache in storage cleanTokenFromCache('idToken'); cleanTokenFromCache(authConfig.clientId); + return true; } + return true; } /** diff --git a/Composer/packages/extension-client/src/auth/index.ts b/Composer/packages/extension-client/src/auth/index.ts index bf9d25c4b1..9736ab684d 100644 --- a/Composer/packages/extension-client/src/auth/index.ts +++ b/Composer/packages/extension-client/src/auth/index.ts @@ -8,7 +8,7 @@ import { ComposerGlobalName } from '../common/constants'; /** * log out current user */ -export function logOut(): Promise { +export function logOut(): Promise { return window[ComposerGlobalName].logOut(); } diff --git a/extensions/azurePublish/src/components/azureProvisionDialog.tsx b/extensions/azurePublish/src/components/azureProvisionDialog.tsx index 55f6ac7c42..8bd9b30257 100644 --- a/extensions/azurePublish/src/components/azureProvisionDialog.tsx +++ b/extensions/azurePublish/src/components/azureProvisionDialog.tsx @@ -746,8 +746,8 @@ export const AzureProvisionDialog: React.FC = () => { return (
{ - OpenConfirmModal( + onClick={async () => { + const signoutAndCloseProvisionDialog = await OpenConfirmModal( formatMessage('Sign out from Azure'), formatMessage( 'Changes you made may not be saved and the wizard will be closed. Do you wish to continue?' @@ -756,30 +756,29 @@ export const AzureProvisionDialog: React.FC = () => { confirmText: formatMessage('Sign out'), cancelText: formatMessage('Cancel'), } - ).then(async (signoutAndCloseProvisionDialog) => { - if (signoutAndCloseProvisionDialog) { - await logOut(); - if (!currentUser) { - addNotification({ - type: 'info', - title: '', - retentionTime: 5000, - description: formatMessage('You have successfully signed out of Azure'), - onRenderCardContent: (props) => { - return
{props.description}
; - }, - }); - } - closeDialog(); + ); + if (signoutAndCloseProvisionDialog) { + const isSignedOutSuccesfully = await logOut(); + if (isSignedOutSuccesfully) { + addNotification({ + type: 'info', + title: '', + retentionTime: 5000, + description: formatMessage('You have successfully signed out of Azure'), + onRenderCardContent: (props) => { + return
{props.description}
; + }, + }); } - }); + closeDialog(); + } }} > {props.secondaryText}
); }, - [] + [addNotification] ); const isNextDisabled = useMemo(() => { From aed152c50133723b48b5450f6b29d5f7625b0ab4 Mon Sep 17 00:00:00 2001 From: Vamsi Modem Date: Thu, 29 Apr 2021 15:58:36 -0700 Subject: [PATCH 05/10] Removed deplicate code --- .../azurePublish/src/components/azureProvisionDialog.tsx | 6 ------ 1 file changed, 6 deletions(-) diff --git a/extensions/azurePublish/src/components/azureProvisionDialog.tsx b/extensions/azurePublish/src/components/azureProvisionDialog.tsx index 745645eedc..2a17009b81 100644 --- a/extensions/azurePublish/src/components/azureProvisionDialog.tsx +++ b/extensions/azurePublish/src/components/azureProvisionDialog.tsx @@ -95,12 +95,6 @@ const ConfigureResourcesSectionName = styled(Text)` margin-bottom: 4px; `; -const ProvisonActions = styled.div((props) => ({ - display: 'flex', - flexFlow: 'row nowrap', - justifyContent: props.showSignout ? 'space-between' : 'flex-end', -})); - const ConfigureResourcesSectionDescription = styled(Text)` font-size: ${FluentTheme.fonts.medium.fontSize}; line-height: ${FontSizes.size14}; From d1d7291755c3a56a2a60bd602513c15b04528143 Mon Sep 17 00:00:00 2001 From: Vamsi Modem Date: Thu, 29 Apr 2021 18:23:01 -0700 Subject: [PATCH 06/10] Refactored signout confirmation code --- .../src/components/ConfirmDialog.tsx | 2 +- .../packages/server/src/locales/en-US.json | 27 ++++++++++++-- .../src/components/azureProvisionDialog.tsx | 37 ++++++++++--------- 3 files changed, 45 insertions(+), 21 deletions(-) diff --git a/Composer/packages/lib/ui-shared/src/components/ConfirmDialog.tsx b/Composer/packages/lib/ui-shared/src/components/ConfirmDialog.tsx index f65a63dbbd..eae47b4e11 100644 --- a/Composer/packages/lib/ui-shared/src/components/ConfirmDialog.tsx +++ b/Composer/packages/lib/ui-shared/src/components/ConfirmDialog.tsx @@ -43,7 +43,7 @@ const builtInStyles = { const dialog = { title: { - fontWeight: FontWeights.bold, + fontWeight: FontWeights.semibold, }, }; diff --git a/Composer/packages/server/src/locales/en-US.json b/Composer/packages/server/src/locales/en-US.json index a523a8d646..6845817af4 100644 --- a/Composer/packages/server/src/locales/en-US.json +++ b/Composer/packages/server/src/locales/en-US.json @@ -182,6 +182,9 @@ "add_alternative_phrasing_17e0304c": { "message": "+ Add alternative phrasing" }, + "add_an_existing_bot_5a9cc5b1": { + "message": "Add an existing bot" + }, "add_app_id_and_password_164e0fdb": { "message": "Add App ID and Password" }, @@ -431,6 +434,12 @@ "azure_functions_5e23be5c": { "message": "Azure Functions" }, + "azure_functions_required_2a035b48": { + "message": "Azure Functions required" + }, + "azure_functions_runtime_not_installed_bc24e100": { + "message": "Azure Functions runtime not installed." + }, "azure_web_app_d834cb4c": { "message": "Azure Web App" }, @@ -698,6 +707,9 @@ "composer_logo_ba2048a0": { "message": "Composer Logo" }, + "composer_needs_azure_functions_36138382": { + "message": "Composer needs Azure Functions" + }, "composer_needs_net_core_sdk_46e2a8ae": { "message": "Composer needs .NET Core SDK" }, @@ -1910,6 +1922,9 @@ "insert_template_reference_bb33720e": { "message": "Insert template reference" }, + "install_azure_functions_d607f182": { + "message": "Install Azure Functions" + }, "install_error_a9319839": { "message": "Install Error" }, @@ -2621,6 +2636,9 @@ "onboarding_8407871c": { "message": "Onboarding" }, + "once_you_publish_your_bot_to_azure_you_will_be_rea_93048067": { + "message": "Once you publish your bot to Azure you will be ready to add connections." + }, "ondialogevents_types_3dc569b5": { "message": "OnDialogEvents Types" }, @@ -2894,6 +2912,9 @@ "publish_to_dev_ops_3b8f5a2f": { "message": "Publish to Dev Ops" }, + "publish_your_bot_9099e323": { + "message": "Publish your bot" + }, "publish_your_bot_to_azure_and_manage_published_bot_67751ca9": { "message": "Publish your bot to Azure and manage published bots here." }, @@ -3191,9 +3212,6 @@ "save_11a80ec3": { "message": "Save" }, - "save_as_9e0cf70b": { - "message": "Save as" - }, "save_your_skill_manifest_63bf5f26": { "message": "Save your skill manifest" }, @@ -3833,6 +3851,9 @@ "to_perform_provisioning_and_publishing_actions_com_a2c54389": { "message": "To perform provisioning and publishing actions, Composer requires access to your Azure and MS Graph accounts. Paste access tokens from the az command line tool using the commands highlighted below." }, + "to_run_this_bot_composer_needs_azure_functions_cor_bbbd0e7": { + "message": "To run this bot, Composer needs Azure Functions Core Tools." + }, "to_run_this_bot_composer_needs_net_core_sdk_d1551038": { "message": "To run this bot, Composer needs .NET Core SDK." }, diff --git a/extensions/azurePublish/src/components/azureProvisionDialog.tsx b/extensions/azurePublish/src/components/azureProvisionDialog.tsx index 2a17009b81..3bdfa749bc 100644 --- a/extensions/azurePublish/src/components/azureProvisionDialog.tsx +++ b/extensions/azurePublish/src/components/azureProvisionDialog.tsx @@ -19,7 +19,7 @@ import { import { Subscription } from '@azure/arm-subscriptions/esm/models'; import { DeployLocation, AzureTenant } from '@botframework-composer/types'; import { FluentTheme, NeutralColors } from '@uifabric/fluent-theme'; -import { LoadingSpinner, OpenConfirmModal, ProvisionHandoff } from '@bfc/ui-shared'; +import { dialogStyle, LoadingSpinner, OpenConfirmModal, ProvisionHandoff } from '@bfc/ui-shared'; import { ScrollablePane, ScrollbarVisibility, @@ -741,6 +741,22 @@ export const AzureProvisionDialog: React.FC = () => { closeDialog(); }, [importConfig]); + const signoutAndNotify = useCallback(async () => { + const isSignedOutSuccesfully = await logOut(); + if (isSignedOutSuccesfully) { + addNotification({ + type: 'info', + title: '', + retentionTime: 5000, + description: formatMessage('You have successfully signed out of Azure'), + onRenderCardContent: (props) => ( +
{props.description}
+ ), + }); + closeDialog(); + } + }, [addNotification]); + const onRenderSecondaryText = useMemo( () => (props: IPersonaProps) => { return ( @@ -753,32 +769,19 @@ export const AzureProvisionDialog: React.FC = () => { 'Changes you made may not be saved and the wizard will be closed. Do you wish to continue?' ), { + onRenderContent: (subtitle: string) =>
{subtitle}
, confirmText: formatMessage('Sign out'), cancelText: formatMessage('Cancel'), } ); - if (signoutAndCloseProvisionDialog) { - const isSignedOutSuccesfully = await logOut(); - if (isSignedOutSuccesfully) { - addNotification({ - type: 'info', - title: '', - retentionTime: 5000, - description: formatMessage('You have successfully signed out of Azure'), - onRenderCardContent: (props) => { - return
{props.description}
; - }, - }); - } - closeDialog(); - } + if (signoutAndCloseProvisionDialog) await signoutAndNotify(); }} > {props.secondaryText}
); }, - [addNotification] + [signoutAndNotify] ); const isNextDisabled = useMemo(() => { From 5dabfdd46b35ede9043f58021b7413664aae4030 Mon Sep 17 00:00:00 2001 From: Vamsi Modem Date: Thu, 29 Apr 2021 20:05:29 -0700 Subject: [PATCH 07/10] Added aria role to the div --- .../azurePublish/src/components/azureProvisionDialog.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/extensions/azurePublish/src/components/azureProvisionDialog.tsx b/extensions/azurePublish/src/components/azureProvisionDialog.tsx index 3bdfa749bc..26b45fdb2e 100644 --- a/extensions/azurePublish/src/components/azureProvisionDialog.tsx +++ b/extensions/azurePublish/src/components/azureProvisionDialog.tsx @@ -761,9 +761,10 @@ export const AzureProvisionDialog: React.FC = () => { () => (props: IPersonaProps) => { return (
{ - const signoutAndCloseProvisionDialog = await OpenConfirmModal( + const confirmed = await OpenConfirmModal( formatMessage('Sign out from Azure'), formatMessage( 'Changes you made may not be saved and the wizard will be closed. Do you wish to continue?' @@ -774,7 +775,9 @@ export const AzureProvisionDialog: React.FC = () => { cancelText: formatMessage('Cancel'), } ); - if (signoutAndCloseProvisionDialog) await signoutAndNotify(); + if (confirmed) { + await signoutAndNotify(); + } }} > {props.secondaryText} From d1f08369aacf707c53899652dfe7674984a929ed Mon Sep 17 00:00:00 2001 From: Vamsi Modem Date: Fri, 30 Apr 2021 13:22:52 -0700 Subject: [PATCH 08/10] User will be notified when signout fails --- .../src/components/azureProvisionDialog.tsx | 40 +++++++++++++------ 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/extensions/azurePublish/src/components/azureProvisionDialog.tsx b/extensions/azurePublish/src/components/azureProvisionDialog.tsx index 26b45fdb2e..e6c2cadece 100644 --- a/extensions/azurePublish/src/components/azureProvisionDialog.tsx +++ b/extensions/azurePublish/src/components/azureProvisionDialog.tsx @@ -268,7 +268,18 @@ const getHostname = (config) => { return config?.environment ? `${config.name}-${config.environment}` : config.name; } }; - +type NotificationType = 'info' | 'warning' | 'error' | 'pending' | 'success'; +const getLogoutNotificationSettings = (description: string, type: NotificationType) => { + return { + title: '', + retentionTime: 5000, + description: description, + type, + onRenderCardContent: (props) => ( +
{props.description}
+ ), + }; +}; const getDefaultFormData = (currentProfile, defaults) => { return { creationType: defaults.creationType ?? 'create', @@ -742,18 +753,21 @@ export const AzureProvisionDialog: React.FC = () => { }, [importConfig]); const signoutAndNotify = useCallback(async () => { - const isSignedOutSuccesfully = await logOut(); - if (isSignedOutSuccesfully) { - addNotification({ - type: 'info', - title: '', - retentionTime: 5000, - description: formatMessage('You have successfully signed out of Azure'), - onRenderCardContent: (props) => ( -
{props.description}
- ), - }); + const isSignedOut = await logOut(); + if (isSignedOut) { + addNotification( + getLogoutNotificationSettings(formatMessage('You have successfully signed out of Azure'), 'info') + ); closeDialog(); + } else { + addNotification( + getLogoutNotificationSettings( + formatMessage( + 'There was an error attempting to logout of Azure. To complete logout, you may need to restart Composer.' + ), + 'error' + ) + ); } }, [addNotification]); @@ -767,7 +781,7 @@ export const AzureProvisionDialog: React.FC = () => { const confirmed = await OpenConfirmModal( formatMessage('Sign out from Azure'), formatMessage( - 'Changes you made may not be saved and the wizard will be closed. Do you wish to continue?' + 'By signing out of Azure, your new publishing profile will be canceled and this dialog will close. Do you want to continue?' ), { onRenderContent: (subtitle: string) =>
{subtitle}
, From deea1e733eb0f06334aa2978656cf21820761651 Mon Sep 17 00:00:00 2001 From: Vamsi Modem Date: Fri, 30 Apr 2021 14:15:39 -0700 Subject: [PATCH 09/10] Changed the confirmation message & used the exisiting notificationType --- .../Notifications/NotificationCard.tsx | 21 +++---------------- .../src/components/azureProvisionDialog.tsx | 10 ++++----- 2 files changed, 8 insertions(+), 23 deletions(-) diff --git a/Composer/packages/client/src/components/Notifications/NotificationCard.tsx b/Composer/packages/client/src/components/Notifications/NotificationCard.tsx index 698cc92edf..a39519b89f 100644 --- a/Composer/packages/client/src/components/Notifications/NotificationCard.tsx +++ b/Composer/packages/client/src/components/Notifications/NotificationCard.tsx @@ -10,6 +10,7 @@ import { FontSizes, SharedColors } from '@uifabric/fluent-theme'; import { Shimmer, ShimmerElementType } from 'office-ui-fabric-react/lib/Shimmer'; import { Icon } from 'office-ui-fabric-react/lib/Icon'; import formatMessage from 'format-message'; +import { Notification } from '@botframework-composer/types'; import { useInterval } from '../../utils/hooks'; @@ -121,24 +122,8 @@ const getShimmerStyles = { ], }; // -------------------- NotificationCard -------------------- // - -export type NotificationType = 'info' | 'warning' | 'error' | 'pending' | 'success'; - -export type Link = { - label: string; - onClick: () => void; -}; - -export type CardProps = { - type: NotificationType; - title: string; - description?: string; - retentionTime?: number; - link?: Link; - read?: boolean; - hidden?: boolean; - onRenderCardContent?: ((props: CardProps) => JSX.Element) | React.FC; -}; +export type CardProps = Notification; +export type NotificationType = Notification['type']; export type NotificationProps = { id: string; diff --git a/extensions/azurePublish/src/components/azureProvisionDialog.tsx b/extensions/azurePublish/src/components/azureProvisionDialog.tsx index e6c2cadece..31f43f5eb9 100644 --- a/extensions/azurePublish/src/components/azureProvisionDialog.tsx +++ b/extensions/azurePublish/src/components/azureProvisionDialog.tsx @@ -17,7 +17,7 @@ import { useApplicationApi, } from '@bfc/extension-client'; import { Subscription } from '@azure/arm-subscriptions/esm/models'; -import { DeployLocation, AzureTenant } from '@botframework-composer/types'; +import { DeployLocation, AzureTenant, Notification } from '@botframework-composer/types'; import { FluentTheme, NeutralColors } from '@uifabric/fluent-theme'; import { dialogStyle, LoadingSpinner, OpenConfirmModal, ProvisionHandoff } from '@bfc/ui-shared'; import { @@ -268,8 +268,8 @@ const getHostname = (config) => { return config?.environment ? `${config.name}-${config.environment}` : config.name; } }; -type NotificationType = 'info' | 'warning' | 'error' | 'pending' | 'success'; -const getLogoutNotificationSettings = (description: string, type: NotificationType) => { + +const getLogoutNotificationSettings = (description: string, type: Notification['type']) => { return { title: '', retentionTime: 5000, @@ -763,7 +763,7 @@ export const AzureProvisionDialog: React.FC = () => { addNotification( getLogoutNotificationSettings( formatMessage( - 'There was an error attempting to logout of Azure. To complete logout, you may need to restart Composer.' + 'There was an error attempting to sign out of Azure. To complete sign out, you may need to restart Composer.' ), 'error' ) @@ -779,7 +779,7 @@ export const AzureProvisionDialog: React.FC = () => { style={{ color: 'blue', cursor: 'pointer' }} onClick={async () => { const confirmed = await OpenConfirmModal( - formatMessage('Sign out from Azure'), + formatMessage('Sign out of Azure'), formatMessage( 'By signing out of Azure, your new publishing profile will be canceled and this dialog will close. Do you want to continue?' ), From 23e2e328c67adf0af2b58259e91615cb8ed5447a Mon Sep 17 00:00:00 2001 From: Vamsi Modem Date: Fri, 30 Apr 2021 15:08:35 -0700 Subject: [PATCH 10/10] Removed unused type --- Composer/packages/client/src/utils/authClient.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/Composer/packages/client/src/utils/authClient.ts b/Composer/packages/client/src/utils/authClient.ts index 2bcaa8244a..f39228dc1b 100644 --- a/Composer/packages/client/src/utils/authClient.ts +++ b/Composer/packages/client/src/utils/authClient.ts @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { promises } from 'fs'; - import { AuthParameters, AzureTenant } from '@botframework-composer/types'; import { authConfig } from '../constants';