Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: appended provision with a profile #5741

Merged
merged 66 commits into from
Mar 1, 2021
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
41e61cc
change edit dialog page 1
VanyLaw Feb 4, 2021
6a24f1c
Merge remote-tracking branch 'origin/main' into wenyluo/prov2
VanyLaw Feb 5, 2021
1eb3ae2
Merge remote-tracking branch 'origin/main' into wenyluo/prov2
VanyLaw Feb 8, 2021
ff0cc0a
change add and edit page one
VanyLaw Feb 8, 2021
722ae73
add review page and enable provision resources in current provision
VanyLaw Feb 9, 2021
b52e8ce
add some log
VanyLaw Feb 9, 2021
863c34a
fix test
VanyLaw Feb 9, 2021
52bd3f6
add profile merge logic
Feb 9, 2021
ff6dd1f
add retry logic judging
Feb 9, 2021
d8855a3
remove settings
Feb 9, 2021
205dc99
remove settings
Feb 9, 2021
c86c8e2
fix review page display error
VanyLaw Feb 9, 2021
0b48821
Merge branch 'wenyluo/prov2' of https://github.com/microsoft/BotFrame…
VanyLaw Feb 9, 2021
5daccf3
fix profile update in edit
VanyLaw Feb 9, 2021
f5104ce
remove status and fix provision update
VanyLaw Feb 9, 2021
ec03934
add missed field in current settings
Feb 10, 2021
19f6cdb
Fix some issues
luhan2017 Feb 18, 2021
6d0b7cc
merge main, fix conflict
VanyLaw Feb 19, 2021
2961939
remove the dependency between webapp and bot channel registration in …
luhan2017 Feb 19, 2021
6cba057
Merge remote-tracking branch 'origin/main' into wenyluo/prov2
VanyLaw Feb 19, 2021
f93987c
fix luis region always westus
VanyLaw Feb 19, 2021
93b00b3
decouple resourceGroup and hostName, fix regex
luhan2017 Feb 20, 2021
74ea3ef
Add a botName field for channel service
luhan2017 Feb 20, 2021
9ee1a8a
fix bug when select luis resource but not select the luis region
VanyLaw Feb 22, 2021
c18406e
add botName to publish profile
luhan2017 Feb 22, 2021
52f4623
make hostname disable if name or hostname already have
VanyLaw Feb 22, 2021
cdea646
Merge branch 'wenyluo/prov2' of https://github.com/microsoft/BotFrame…
VanyLaw Feb 22, 2021
b7d2db5
fix resourceGroup display error in review page
VanyLaw Feb 22, 2021
0f74d2e
remove annotation
VanyLaw Feb 22, 2021
5509f9a
Merge branch 'main' into wenyluo/prov2
luhan2017 Feb 22, 2021
de98b97
Merge branch 'main' into wenyluo/prov2
benbrown Feb 22, 2021
076aeba
fix regex issue and get location issue
VanyLaw Feb 23, 2021
9364d45
Merge branch 'wenyluo/prov2' of https://github.com/microsoft/BotFrame…
VanyLaw Feb 23, 2021
70a5c84
merge main fix conflict
VanyLaw Feb 23, 2021
61c6965
update publish function getPublishConfig
VanyLaw Feb 23, 2021
93194e8
Merge branch 'main' into wenyluo/prov2
luhan2017 Feb 23, 2021
c0529a1
fix hostname check issue
VanyLaw Feb 24, 2021
e868a15
Merge branch 'wenyluo/prov2' of https://github.com/microsoft/BotFrame…
VanyLaw Feb 24, 2021
ddda758
fix UI in add resource page
VanyLaw Feb 24, 2021
2f79a3c
fix UI issue
VanyLaw Feb 24, 2021
a1b3519
Fix the config missing issue
luhan2017 Feb 25, 2021
10dc131
merge main
VanyLaw Feb 26, 2021
b155176
update qna image and resource group check
VanyLaw Feb 26, 2021
e23de4e
merge main
VanyLaw Mar 1, 2021
338c54f
Merge branch 'main' into wenyluo/prov2
luhan2017 Mar 1, 2021
85dfda3
add region to profile and show the profile region as default in edit …
VanyLaw Mar 1, 2021
4d68c77
Merge branch 'wenyluo/prov2' of https://github.com/microsoft/BotFrame…
VanyLaw Mar 1, 2021
e0f68a2
add display name for app registration
VanyLaw Mar 1, 2021
701947c
Merge branch 'main' into wenyluo/prov2
luhan2017 Mar 1, 2021
159575d
remove form page if type already have
VanyLaw Mar 1, 2021
625a706
fix bug
VanyLaw Mar 1, 2021
5332fb4
Merge branch 'wenyluo/prov2' of https://github.com/microsoft/BotFrame…
VanyLaw Mar 1, 2021
22653bd
fix bug
VanyLaw Mar 1, 2021
41b5ee5
remove image
VanyLaw Mar 1, 2021
de0b25d
add image
VanyLaw Mar 1, 2021
621b8ac
fix bugs
VanyLaw Mar 1, 2021
582285b
fix: provision process shown in publish list (#6044)
alanlong9278 Mar 1, 2021
c021d27
fix region
VanyLaw Mar 1, 2021
71132f9
Merge branch 'wenyluo/prov2' of https://github.com/microsoft/BotFrame…
VanyLaw Mar 1, 2021
52c60f8
Merge branch 'main' into wenyluo/prov2
boydc2014 Mar 1, 2021
f6b88eb
go to edit page if no resources can be added
VanyLaw Mar 1, 2021
c6a3bde
Merge branch 'wenyluo/prov2' of https://github.com/microsoft/BotFrame…
VanyLaw Mar 1, 2021
f3cbe00
fix the region issue
luhan2017 Mar 1, 2021
cde52aa
fix ut
VanyLaw Mar 1, 2021
626f930
Merge branch 'wenyluo/prov2' of https://github.com/microsoft/BotFrame…
VanyLaw Mar 1, 2021
c1b4dd8
fix auth dialog popup everytime
VanyLaw Mar 1, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ import { dispatcherState } from '../../../recoilModel';
import { AuthClient } from '../../../utils/authClient';
import { getTokenFromCache, isGetTokenFromUser } from '../../../utils/auth';

type AddProfileDialogProps = {
type ProfileFormDialogProps = {
onDismiss: () => void;
targets: PublishTarget[];
types: PublishType[];
onNext: () => void;
updateSettings: (name: string, type: string, configuration: string) => Promise<void>;
projectId: string;
setType: (value) => void;
current?: { index: number; item: PublishTarget } | null;
};
const labelContainer = css`
display: flex;
Expand Down Expand Up @@ -72,11 +73,11 @@ const onRenderLabel = (props) => {
);
};

export const AddProfileDialog: React.FC<AddProfileDialogProps> = (props) => {
const { onDismiss, targets, types, onNext, updateSettings, projectId, setType } = props;
const [name, setName] = useState('');
export const ProfileFormDialog: React.FC<ProfileFormDialogProps> = (props) => {
const { onDismiss, targets, types, onNext, updateSettings, projectId, setType, current } = props;
const [name, setName] = useState(current?.item.name || '');
const [errorMessage, setErrorMsg] = useState('');
const [targetType, setTargetType] = useState<string>('');
const [targetType, setTargetType] = useState<string>(current?.item.type || '');
const [showAuthDialog, setShowAuthDialog] = useState(false);
const { provisionToTarget } = useRecoilValue(dispatcherState);

Expand Down Expand Up @@ -144,7 +145,7 @@ export const AddProfileDialog: React.FC<AddProfileDialogProps> = (props) => {
arm = getTokenFromCache('accessToken');
graph = getTokenFromCache('graphToken');
}
provisionToTarget(fullConfig, config.type, projectId, arm, graph);
provisionToTarget(fullConfig, config.type, projectId, arm, graph, current?.item);
};
}, [name, targetType]);

Expand All @@ -168,6 +169,7 @@ export const AddProfileDialog: React.FC<AddProfileDialogProps> = (props) => {
required
ariaLabel={formatMessage('The name of your publishing file')}
defaultValue={name}
disabled={current?.item.name ? true : false}
errorMessage={errorMessage}
label={formatMessage('Name')}
placeholder={formatMessage('e.g. AzureBot')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ import { PluginHost } from '../../../components/PluginHost/PluginHost';
import { defaultPublishSurface, pvaPublishSurface, azurePublishSurface } from '../../publish/styles';
import TelemetryClient from '../../../telemetry/TelemetryClient';

import { EditProfileDialog } from './EditProfileDialog';
import { AddProfileDialog } from './AddProfileDialog';
import { ProfileFormDialog } from './ProfileFormDialog';

type PublishProfileDialogProps = {
closeDialog: () => void;
Expand All @@ -28,19 +27,18 @@ type PublishProfileDialogProps = {
setPublishTargets: (targets: PublishTarget[], projectId: string) => Promise<void>;
};

enum Page {
AddProfile = 'add',
EditProfile = 'edit',
ConfigProvision = 'config',
}
const Page = {
ProfileForm: Symbol('form'),
ConfigProvision: Symbol('config'),
};

export const PublishProfileDialog: React.FC<PublishProfileDialogProps> = (props) => {
const { current, types, projectId, closeDialog, targets, setPublishTargets } = props;
const [page, setPage] = useState(current ? Page.EditProfile : Page.AddProfile);
const [page, setPage] = useState(Page.ProfileForm);
const [publishSurfaceStyles, setStyles] = useState(defaultPublishSurface);

const [dialogTitle, setTitle] = useState({
title: formatMessage('Add a publishing profile'),
title: current ? formatMessage('Edit a publishing profile') : formatMessage('Add a publishing profile'),
carlosscastro marked this conversation as resolved.
Show resolved Hide resolved
subText: formatMessage('A publishing profile provides the secure connectivity required to publish your bot. '),
});

Expand Down Expand Up @@ -72,7 +70,11 @@ export const PublishProfileDialog: React.FC<PublishProfileDialogProps> = (props)
useEffect(() => {
PluginAPI.publish.closeDialog = closeDialog;
PluginAPI.publish.onBack = () => {
setPage(Page.AddProfile);
setPage(Page.ProfileForm);
setTitle({
title: current ? formatMessage('Edit a publishing profile') : formatMessage('Add a publishing profile'),
carlosscastro marked this conversation as resolved.
Show resolved Hide resolved
subText: formatMessage('A publishing profile provides the secure connectivity required to publish your bot. '),
});
};
PluginAPI.publish.getTokenFromCache = () => {
return {
Expand All @@ -90,33 +92,22 @@ export const PublishProfileDialog: React.FC<PublishProfileDialogProps> = (props)

// setup plugin APIs so that the provisioning plugin can initiate the process from inside the iframe
useEffect(() => {
PluginAPI.publish.useConfigBeingEdited = () => [current ? JSON.parse(current.item.configuration) : undefined];
PluginAPI.publish.useConfigBeingEdited = () => (current ? JSON.parse(current.item.configuration) : undefined);
PluginAPI.publish.currentProjectId = () => {
return projectId;
};
}, [current, projectId]);

const updatePublishTarget = useCallback(
async (name: string, type: string, configuration: string, editTarget: any) => {
if (!editTarget) {
return;
}

const newTargets = targets ? [...targets] : [];
newTargets[editTarget.index] = {
name,
type,
configuration,
};

await setPublishTargets(newTargets, projectId);
},
[targets, projectId]
);

const savePublishTarget = useCallback(
async (name: string, type: string, configuration: string) => {
const newTargets = [...(targets || []), { name, type, configuration }];
// check exist
const newTargets = [...targets] || [];
const index = targets.findIndex((item) => item.name === name);
if (index >= 0) {
newTargets.splice(index, 1, { name, type, configuration });
} else {
newTargets.push({ name, type, configuration });
}
await setPublishTargets(newTargets, projectId);
TelemetryClient.track('NewPublishingProfileSaved', { type });
},
Expand All @@ -125,55 +116,46 @@ export const PublishProfileDialog: React.FC<PublishProfileDialogProps> = (props)

return (
<Fragment>
{page === Page.EditProfile && (
<EditProfileDialog
current={props.current}
types={types}
updateSettings={updatePublishTarget}
onDismiss={closeDialog}
/>
)}
{page != Page.EditProfile && (
<Dialog
dialogContentProps={{
title: dialogTitle.title,
subText: page !== Page.AddProfile ? dialogTitle.subText : '',
}}
hidden={false}
minWidth={960}
modalProps={{
isBlocking: true,
}}
onDismiss={closeDialog}
>
{page === Page.AddProfile && (
<div>
<div style={{ marginBottom: '16px' }}>
{dialogTitle.subText}
<Link href="https://aka.ms/bf-composer-docs-publish-bot" target="_blank">
{formatMessage('Learn More.')}
</Link>
</div>
<AddProfileDialog
projectId={projectId}
setType={setSelectType}
targets={targets}
types={types}
updateSettings={savePublishTarget}
onDismiss={closeDialog}
onNext={() => {
setPage(Page.ConfigProvision);
}}
/>
</div>
)}
{page === Page.ConfigProvision && selectedType?.bundleId && (
<div css={publishSurfaceStyles}>
<PluginHost bundleId={selectedType.bundleId} pluginName={selectedType.extensionId} pluginType="publish" />
<Dialog
dialogContentProps={{
title: dialogTitle.title,
subText: '',
}}
hidden={false}
minWidth={960}
modalProps={{
isBlocking: true,
}}
onDismiss={closeDialog}
>
{page !== Page.ConfigProvision && (
<div>
<div style={{ marginBottom: '16px' }}>
{dialogTitle.subText}
<Link href="https://aka.ms/bf-composer-docs-publish-bot" target="_blank">
{formatMessage('Learn More.')}
</Link>
</div>
)}
</Dialog>
)}
<ProfileFormDialog
current={current}
projectId={projectId}
setType={setSelectType}
targets={targets}
types={types}
updateSettings={savePublishTarget}
onDismiss={closeDialog}
onNext={() => {
setPage(Page.ConfigProvision);
}}
/>
</div>
)}
{page === Page.ConfigProvision && selectedType?.bundleId && (
<div css={publishSurfaceStyles}>
<PluginHost bundleId={selectedType.bundleId} pluginName={selectedType.extensionId} pluginType="publish" />
</div>
)}
</Dialog>
</Fragment>
);
};
2 changes: 1 addition & 1 deletion Composer/packages/client/src/plugins/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ interface AuthAPI {
}

interface PublishAPI {
useConfigBeingEdited?: (() => PublishConfig[]) | (() => void);
useConfigBeingEdited?: (() => PublishConfig) | (() => void);
startProvision?: (config: any) => void;
currentProjectId?: () => string;
closeDialog?: () => void;
Expand Down
Loading