Skip to content

Commit

Permalink
feat: provisioning in app (microsoft#4221)
Browse files Browse the repository at this point in the history
* provision UI change

* add provision UI (client)

* server change to support provision

* fix conflict when rebase main

* add provision UI (client)

* fix conflict in api.ts

* add a login plugin as middleware to check the token

* add azureResourceManager to manage provision

* change azure publish plugin to add provision feature

* auth in client

* add appinsight packages because of version not update in npmjs

* polish

* fix bug after merge main

* fix subscription getting issue in client

* add arm-appinsight build into azurePublish build

* fix lint

* add azure api utility class

* bring API calls into alignment with spec doc
standardize use of Authorization token across azure APIs
add TEMPORARY form for setting graph and access token

* clean up the web ui to get it slightly closer to the current designs

* update to create resources to include toggle

* add resource provider location api for differernt resource type

* add local file

* merge main
deal with problems created by merging main

* locale file

* refactor the azure provisioning to live inside the plugin

* mark globally scoped azure feature for deprecation

* do some very very basic error handlign on the subscriber endpoint

* add parts of sku checking, name checking

* add subtitle and separator in wizard

* change location of azure provision util

* remove azureLogin plugin and polish UI

* remove azure api call in provision controller, make azure api call in azure Publsh plugin api, and change azure api call from restapi to npm package

* remove azure api call in client

* remove azureLogin in package.json

* reuse edit and add profile Dialog

* split into two page

* big refactor on the internals of the azure provisioning process

* finish the refactor of deploy process.

* slight updates to handle blank environment value

* Standardize the mechanism used to track ongoing background processes and report their status
Apply this mechanism on azure deploy and azure publish
clean up consoles
clean up comments

* add qna provision to azureProvisionManager.ts

* add bundleId

* add notification

* Update localpublish to report its status in the slightly new format

* add ui preview list api

* change accoutName param to name

* add azure functions provision

* add provision detail page

* update locale file:

* add jsonEditor in plugin ui

* refactor the resource list a tiny bit so it comes from the server not the client

* fix issue

* clean up duplicate provision config

* add icon for resources

* add provisionStatus state in botState, and remove provisionState and provisionConfig in settings.publishTarget

* enable notification update

* remove azure package in server

* yarn.lock change

* update notification base on the same object

* first try in moving buttons out

* Revert "first try in moving buttons out"

This reverts commit 98c515f9c8064fd72b55eddfa9206a7f93f972d3.

* back button implement

* polish css

* fix build

* change dialog title with the page change

* add option to force rebuild all extensions

* fix publish plugin api return values

* update plugin with new extension apis

* add schema in plugin json editor and add botservice package, remove appinsight package

* remove appinsight package

* polish

* fix save import config

* fix save issue in edit profile

* send the config back if provision success, and just provision the resources which required is true

* fix bundleId so azureFunctionsPublish works. add getType to extension api to access publish type. remove requirement that resources be marked as required. use group names provided by server.

* fix publishTarget update after provision

* enable login in electron

* fix build

* fix UI overflow, modify provision message, fix page was freeze by login in web

* lock file change

* cherry pick commit about getting two token by one pop up window

* fix electron l10n error

* fix build

* classify error message, create customized error

* finish error classify

* make sure the location for luis region is validated

* fix functions provision issue, polish review list column width

* fix notification update and reshow after close current notification

* persist notification log in file

* remove access token in publihs schema, fix bf-lu version in publish

* add persona

* polish Persona

* add toggle in review list and make all resources be selected by default

* add luis region dropdown

* use botservice package in npmjs instead of self built

* fix conflict in publish result type

* fix conflict

* fix build conflict with  pva

* update azure extension node build

* add default runtime identifier

* finish web login

* fix build

* polish

* polish name check, adding webapp name check

* add user log out button

* fix: add unit tests for wenyluo/provision branch (microsoft#5002)

* add provision api/ui unit test

* fix ut for publish

* call token api directly instead use msal

* yarn lock change

* split ui test and node test

* filter test file in  build

* link provision into settings page

* polish ui

* fix data-Id warning in client

* fix time problem

* fix two issues

1. echo bot goes through the luis publish logic and throw exception.
2. logger exception, just disable it.

* remove login in local publish

* fix hostname and luisResource

* fix qna location

* fix build error in mockRemotePublish and sample-ui-plugin extensions

* fix provision target only save in root project

* fix logout bug and fix build

* add win-x64 into provision result

* add give token dialog

* fix bug

* fix bug

* fix bug cause auth dialog

* fix region bug

* fix logger bug and fix comment

* fix lint

* fix ut

* Update webpack.config.js

* Revert "Update webpack.config.js"

This reverts commit 8c9b6b8eba92add3629abf111c986d8297d3dfb0.

* Revert "Update webpack.config.js"

This reverts commit 8c9b6b8eba92add3629abf111c986d8297d3dfb0.

* change webpack and package.json

* remove annotation

* fix webpack

* fix comments

* remove unnecessary this in function calling

* remove publish page test now, and add it later

* fix lint

* refactor publish profile dialog

* polish

* fix lint

* minor refresh time

* fix build

* fix lint

* add weblogin environment value into client

* Revert "Remove Orchestrator pdbs from Azure publish flow (microsoft#5275)"

This reverts commit f94c72c.

* fix order of variables

* unity the data structure come from status and history api call

* fix comments

* polish

* fix build

Co-authored-by: Wenyi Luo <wenyluo@microsoft.com>
Co-authored-by: Qi Kang <qika@microsoft.com>
Co-authored-by: Andy Brown <asbrown002@gmail.com>
Co-authored-by: Tony Anziano <tonyanziano5@gmail.com>
Co-authored-by: Qi Kang <kangqidev@gmail.com>
Co-authored-by: Lu Han <32191031+luhan2017@users.noreply.github.com>
Co-authored-by: Tai Chou <tachou@microsoft.com>
Co-authored-by: Chris Whitten <christopher.whitten@microsoft.com>
Co-authored-by: Dong Lei <donglei@microsoft.com>
  • Loading branch information
10 people authored Dec 11, 2020
1 parent b65e0ea commit 0b4dda8
Show file tree
Hide file tree
Showing 104 changed files with 14,560 additions and 7,047 deletions.
63 changes: 0 additions & 63 deletions Composer/cypress/integration/Publish.spec.ts

This file was deleted.

2 changes: 1 addition & 1 deletion Composer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,4 @@
"wait-on": "^5.2.0",
"wsrun": "^5.2.0"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const rootState = {
status: true,
rollback: true,
pull: true,
provision: true,
},
},
],
Expand Down
3 changes: 3 additions & 0 deletions Composer/packages/client/config/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ function getClientEnvironment(publicUrl) {
COMPOSER_VERSION: '1.3.0-rc4',
LOCAL_PUBLISH_PATH:
process.env.LOCAL_PUBLISH_PATH || path.resolve(process.cwd(), '../../../extensions/localPublish/hostedBots'),
WEBLOGIN_CLIENTID: process.env.WEBLOGIN_CLIENTID,
WEBLOGIN_TENANTID: process.env.WEBLOGIN_TENANTID,
WEBLOGIN_REDIRECTURL: process.env.WEBLOGIN_REDIRECTURL,
}
);
// Stringify all values so we can feed into Webpack DefinePlugin
Expand Down
2 changes: 1 addition & 1 deletion Composer/packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"@bfc/form-dialogs": "*",
"@bfc/indexers": "*",
"@bfc/shared": "*",
"@bfc/ui-shared": "*",
"@bfc/ui-plugin-composer": "*",
"@bfc/ui-plugin-cross-trained": "*",
"@bfc/ui-plugin-dialog-schema-editor": "*",
Expand All @@ -47,6 +46,7 @@
"format-message": "^6.2.3",
"format-message-generate-id": "^6.2.3",
"immer": "^5.2.0",
"jsonwebtoken": "^8.5.1",
"jwt-decode": "^2.2.0",
"lodash": "^4.17.19",
"office-ui-fabric-react": "^7.121.11",
Expand Down
100 changes: 100 additions & 0 deletions Composer/packages/client/src/components/Auth/AuthDialog.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

/** @jsx jsx */
import { jsx } from '@emotion/core';
import { DialogWrapper, DialogTypes } from '@bfc/ui-shared';
import formatMessage from 'format-message';
import { DialogFooter } from 'office-ui-fabric-react/lib/Dialog';
import { PrimaryButton, DefaultButton } from 'office-ui-fabric-react/lib/Button';
import { TextField } from 'office-ui-fabric-react/lib/TextField';
import { useCallback, useState } from 'react';

import storage from '../../utils/storage';
import { isTokenExpired } from '../../utils/auth';

export interface AuthDialogProps {
needGraph: boolean;
onDismiss: () => void;
next: () => void;
}
export const AuthDialog: React.FC<AuthDialogProps> = (props) => {
const [graphToken, setGraphToken] = useState('');
const [accessToken, setAccessToken] = useState('');
const [tokenError, setTokenError] = useState<string>('');
const [graphError, setGraphError] = useState<string>('');
const isAble = useCallback(() => {
if (!accessToken) {
return false;
} else if (tokenError) {
return false;
}

if (props.needGraph && (!graphToken || graphError)) {
return false;
}
return true;
}, [accessToken, graphToken]);

return (
<DialogWrapper
isBlocking
isOpen
dialogType={DialogTypes.CreateFlow}
subText={formatMessage(
'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.'
)}
title={formatMessage('Provide access tokens')}
onDismiss={props.onDismiss}
>
<TextField
multiline
errorMessage={tokenError}
label={formatMessage('Provide ARM token by running `az account get-access-token`')}
placeholder={formatMessage('Paste token here')}
rows={4}
onChange={(event, newValue) => {
newValue && setAccessToken(newValue);
if (isTokenExpired(newValue || '')) {
setTokenError('Token Expire or token invalid');
} else {
setTokenError('');
}
}}
/>
{props.needGraph ? (
<TextField
multiline
errorMessage={graphError}
label={formatMessage(
'Provide graph token by running `az account get-access-token --resource-type ms-graph`'
)}
placeholder={formatMessage('Paste token here')}
rows={4}
onChange={(event, newValue) => {
newValue && setGraphToken(newValue);
if (isTokenExpired(newValue || '')) {
setGraphError('Token Expire or token invalid');
} else {
setGraphError('');
}
}}
/>
) : null}
<DialogFooter>
<DefaultButton text={formatMessage('Cancel')} onClick={props.onDismiss} />
<PrimaryButton
disabled={!isAble()}
text={formatMessage('Continue')}
onClick={() => {
props.onDismiss();
// cache tokens
storage.set('accessToken', accessToken);
storage.set('graphToken', graphToken);
props.next();
}}
/>
</DialogFooter>
</DialogWrapper>
);
};
22 changes: 22 additions & 0 deletions Composer/packages/client/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,28 @@ export const QnABotTemplateId = 'QnASample';

export const nameRegex = /^[a-zA-Z0-9-_]+$/;

export const authConfig = {
// for web login
clientId: process.env.WEBLOGIN_CLIENTID,
scopes: [
'https://management.core.windows.net/user_impersonation',
'https://graph.microsoft.com/Application.ReadWrite.All',
],
tenantId: process.env.WEBLOGIN_TENANTID,
redirectUrl: process.env.WEBLOGIN_REDIRECTURL,
};

export const armScopes = {
scopes: ['https://management.core.windows.net/user_impersonation'],
targetResource: 'https://management.core.windows.net/',
};
export const graphScopes = {
scopes: ['https://graph.microsoft.com/Application.ReadWrite.All'],
targetResource: 'https://graph.microsoft.com/',
};

export const authUrl = `https://login.microsoftonline.com/${authConfig.tenantId}/oauth2/v2.0/authorize`;

export const triggerNotSupportedWarning = () =>
formatMessage(
'This trigger type is not supported by the RegEx recognizer. To ensure this trigger is fired, change the recognizer type.'
Expand Down
Loading

0 comments on commit 0b4dda8

Please sign in to comment.