Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
143 commits
Select commit Hold shift + click to select a range
ec2860d
add js runtime
VanyLaw May 18, 2020
6b1e5c9
Merge remote-tracking branch 'origin/master' into wenyluo/jsRuntime
VanyLaw May 19, 2020
9f0095f
set copy button disable when copying
VanyLaw May 20, 2020
24955b0
updated js runtime to load settings correctly
chon219 May 20, 2020
74d6e9d
updated js runtime to load settings correctly
chon219 May 20, 2020
a9de283
add js runtime publish
May 21, 2020
3065826
add runtime config
May 21, 2020
7f5f176
fixed sample templates
chon219 May 23, 2020
2b90ee4
add JS runtime support in default, can run without eject
VanyLaw May 23, 2020
feb2ff0
read folder path from settings
chon219 May 23, 2020
d2417ac
change publish folder for js runtime
chon219 May 23, 2020
d5221d8
Merge branch 'wenyluo/jsRuntime' of https://github.com/microsoft/botf…
chon219 May 23, 2020
bf82179
exlucde *.zip from archived files
chon219 May 24, 2020
079129c
fixed appsettings path for deployment
chon219 May 24, 2020
a733aad
added web.config as well as iisnode.yml configuration files for deplo…
chon219 May 24, 2020
8493676
compiled js runtime
chon219 May 24, 2020
253e56f
merge settings
chon219 May 24, 2020
ad41eb8
enum value to lower case
chon219 May 24, 2020
2fe4d04
fixed zip deployment issue
chon219 May 24, 2020
02dca23
deploy js runtime without eject
VanyLaw May 25, 2020
6f16736
js runtime lib files
VanyLaw May 25, 2020
35c2543
fix restart
VanyLaw May 25, 2020
e96e023
Merge branch 'wenyluo/jsRuntime' of https://github.com/microsoft/BotF…
VanyLaw May 25, 2020
8860d7c
merge master, fix conflict
VanyLaw May 27, 2020
bfc3496
fix lint
VanyLaw May 27, 2020
c6578a9
fix zip runtime
VanyLaw May 27, 2020
0832ee1
fix bot-deploy package can not update in azurepublish plugin
VanyLaw May 28, 2020
d65aa6c
fix copy runtime everytime when local publish
VanyLaw May 28, 2020
5eed1a8
updated configuration files for deployment
chon219 May 29, 2020
5438c5a
add yarn install in first time clicking start
VanyLaw Jun 1, 2020
df4974c
Merge branch 'wenyluo/jsRuntime' of https://github.com/microsoft/BotF…
VanyLaw Jun 1, 2020
14d95ac
Merge remote-tracking branch 'origin/master' into wenyluo/jsRuntime
VanyLaw Jun 1, 2020
c1bfedf
Merge remote-tracking branch 'origin/master' into wenyluo/jsRuntime
VanyLaw Jun 2, 2020
6fd7807
bump runtime dependencies' version
chon219 Jun 3, 2020
98b6514
merge master fix conflict
VanyLaw Jun 3, 2020
6d60807
fix deploy absolute url and include .deployment into zip
VanyLaw Jun 3, 2020
6f3ccfc
Merge remote-tracking branch 'origin/master' into wenyluo/jsRuntime
VanyLaw Jun 4, 2020
42e7ea7
merge master fix conflict
VanyLaw Jun 19, 2020
147e283
decouple platform in localpublish plugin
VanyLaw Jun 19, 2020
fd6d7e9
Merge remote-tracking branch 'origin/master' into wenyluo/jsRuntime
VanyLaw Jun 23, 2020
af2d50a
move some code into nodejs runtime core
VanyLaw Jun 23, 2020
da784ae
Merge remote-tracking branch 'origin/master' into wenyluo/jsRuntime
VanyLaw Jun 24, 2020
26e7f5d
merge master and fix conflict
VanyLaw Jun 28, 2020
a506db2
merge master
VanyLaw Jun 28, 2020
c9f220f
merge master fix conflict
VanyLaw Jul 1, 2020
218eedb
fix profile edit and save not saving to settings
VanyLaw Jul 3, 2020
85edd76
Remove language specific features from core and into runtime plugin (…
benbrown Jul 3, 2020
cc9c534
fix save and edit profile
VanyLaw Jul 3, 2020
88c6479
fix js runtime in core
VanyLaw Jul 6, 2020
57146c7
fix js runtime local publish
VanyLaw Jul 6, 2020
d328b5e
fix exclude paths not working in copyDir
VanyLaw Jul 7, 2020
494fe1c
delete bot-deploy in lib
VanyLaw Jul 7, 2020
f5410ac
merge nodejs runtime packages into one and fix deploy path error
VanyLaw Jul 8, 2020
ff092d1
merge master and fix conflict
VanyLaw Jul 8, 2020
8718cd6
fix yarn to install lu 4.10.0
VanyLaw Jul 8, 2020
2d04460
fix merge conflict
VanyLaw Jul 8, 2020
b480107
enable switch runtime in managed mode
VanyLaw Jul 9, 2020
df5b7d9
add npmrc to set registry in azure, make sure daily build version pac…
VanyLaw Jul 10, 2020
5ddf973
fix several comments
VanyLaw Jul 10, 2020
5565481
Merge remote-tracking branch 'origin/main' into wenyluo/jsRuntime
VanyLaw Jul 13, 2020
000c8ce
fix comments
VanyLaw Jul 13, 2020
44ecb1f
fix luisbot deploy endpointKey issue and send 202 response before run…
VanyLaw Jul 14, 2020
152bd5a
fix luisbot deploy endpointKey issue and send 202 response before run…
VanyLaw Jul 14, 2020
1ae1cf7
fix ut in eject
VanyLaw Jul 15, 2020
0ca0677
move DialogSetting interface into shared folder
VanyLaw Jul 15, 2020
7e7f582
fix build error
VanyLaw Jul 16, 2020
fb86dad
merge master and fix conflict
VanyLaw Jul 16, 2020
edc0792
Merge remote-tracking branch 'origin/main' into wenyluo/jsRuntime
VanyLaw Jul 17, 2020
a4de5dd
fix e2e test fail
VanyLaw Jul 17, 2020
82261d1
fix all histories showing after deleted profile and underfined plugin…
VanyLaw Jul 20, 2020
40406ad
add test for js runtime
VanyLaw Jul 22, 2020
695dd00
dotnet runtime luis settings refactor, remove duplicate settings file…
Jul 22, 2020
93a09af
remove appsettings.deployment.json and appsettings.development.json
VanyLaw Jul 23, 2020
fbb36cb
merge main and fix conflict
VanyLaw Jul 24, 2020
20e65b8
fix get publish status after merge main
VanyLaw Jul 24, 2020
d9ccb57
merge main and fix eject error message and azure deploy
VanyLaw Jul 27, 2020
afd6bca
merge main and fix conflict
VanyLaw Jul 28, 2020
b41f48e
some updates to the plugins README to include new functionality
benbrown Jul 28, 2020
9e802b1
additional docs for the plugin APIs
benbrown Jul 29, 2020
6c10398
Merge branch 'main' of github.com:microsoft/BotFramework-Composer int…
benbrown Jul 29, 2020
804abb0
upgrade dependency
chon219 Jul 30, 2020
ce99f3c
support skills
chon219 Jul 30, 2020
6648604
optimized structure of js runtime
chon219 Jul 31, 2020
d70272c
to get correct project root
chon219 Jul 31, 2020
3f78bdc
merge main. fix conflict
VanyLaw Aug 3, 2020
32c297b
added manifest support in js runtime
chon219 Aug 3, 2020
cc44cbe
ignored lib folder in js runtime
chon219 Aug 3, 2020
7e3baa4
updated docs of js runtime
chon219 Aug 3, 2020
393b0eb
fix some comments
VanyLaw Aug 3, 2020
65a92e5
Merge branch 'wenyluo/jsRuntime' of https://github.com/microsoft/BotF…
VanyLaw Aug 3, 2020
0a0982a
Merge branch 'main' into wenyluo/jsRuntime
cwhitten Aug 4, 2020
0d713db
removed skills validation
chon219 Aug 4, 2020
c47d410
remove appsettings.json in dotnet
VanyLaw Aug 4, 2020
fc05f43
Merge branch 'wenyluo/jsRuntime' of https://github.com/microsoft/BotF…
VanyLaw Aug 4, 2020
7bdbf38
fixed case issue of microsoft app id
chon219 Aug 4, 2020
672dd0d
increased param length limit of web server
chon219 Aug 4, 2020
eb8bf4a
Merge branch 'wenyluo/jsRuntime' of https://github.com/microsoft/BotF…
VanyLaw Aug 4, 2020
0180090
Merge remote-tracking branch 'origin/main' into wenyluo/jsRuntime
VanyLaw Aug 5, 2020
142844f
shared skill conversation id factory
chon219 Aug 5, 2020
44ae258
remove listener before stop bot, move manifest saving into runtime pl…
VanyLaw Aug 5, 2020
365c0de
Merge branch 'wenyluo/jsRuntime' of https://github.com/microsoft/BotF…
VanyLaw Aug 5, 2020
81399f4
Merge remote-tracking branch 'origin/main' into wenyluo/jsRuntime
VanyLaw Aug 5, 2020
25baf2a
fix unit test
VanyLaw Aug 5, 2020
26fbf49
merge main fix conflict
VanyLaw Aug 6, 2020
d31ece7
Merge remote-tracking branch 'origin/main' into wenyluo/jsRuntime
VanyLaw Aug 10, 2020
f203168
modify node runtime actions test, add node runtime test into CI
VanyLaw Aug 10, 2020
00f7535
modify all node runtime tests
VanyLaw Aug 10, 2020
ef1af39
add working directory in ci yml
VanyLaw Aug 10, 2020
95f310d
Merge branch 'main' into wenyluo/jsRuntime
cwhitten Aug 11, 2020
19233bf
add preview in js eject and update restify package version
VanyLaw Aug 11, 2020
a321885
add ts into dev dep
VanyLaw Aug 11, 2020
8de7812
build after eject
VanyLaw Aug 11, 2020
325aada
added test cases for skill conversation id factory
chon219 Aug 11, 2020
0a5a0f7
fix npm build involve jest in production environment
VanyLaw Aug 11, 2020
4166413
Merge branch 'wenyluo/jsRuntime' of https://github.com/microsoft/BotF…
VanyLaw Aug 11, 2020
692a711
polish
VanyLaw Aug 11, 2020
906a744
fix some comments
VanyLaw Aug 12, 2020
467ed48
Merge remote-tracking branch 'origin/main' into wenyluo/jsRuntime
VanyLaw Aug 12, 2020
88cb140
add eslint and fix lint
VanyLaw Aug 12, 2020
2f25755
updated set output target of typescript to es6
chon219 Aug 12, 2020
d7aaaa4
use lodash merge instead object assign
VanyLaw Aug 12, 2020
e785e2b
change method parameter to object, move botStatusInterval from recoil…
VanyLaw Aug 13, 2020
10a3760
remove templatePath in publish api call and get it in plugins by runt…
VanyLaw Aug 13, 2020
c6f2ab8
azure functions in js runtime
chon219 Aug 14, 2020
01ca769
polish exec in runtime plugin, use lodash mergeWith to replace origin…
VanyLaw Aug 14, 2020
b1102c9
Merge branch 'wenyluo/jsRuntime' of https://github.com/microsoft/BotF…
VanyLaw Aug 14, 2020
1b5aaae
polish runtime plugin
VanyLaw Aug 14, 2020
56d9752
make console log in azure publish plugin to logger
VanyLaw Aug 17, 2020
f727950
Merge remote-tracking branch 'origin/main' into wenyluo/jsRuntime
VanyLaw Aug 17, 2020
0611451
fix mkdir error in runtime plugin; popup confirm dialog instead error…
VanyLaw Aug 17, 2020
f1cb23e
stop bot before switch eject runtime
VanyLaw Aug 17, 2020
ec0fd0c
ignore warning and error in npm install, modify schema folder into Sc…
VanyLaw Aug 18, 2020
589242e
add doc for js runtime
VanyLaw Aug 18, 2020
3224ea9
Merge branch 'main' into wenyluo/jsRuntime
luhan2017 Aug 18, 2020
d1d1685
polish
VanyLaw Aug 18, 2020
5a7bed7
polish
VanyLaw Aug 18, 2020
a580c9a
Merge branch 'wenyluo/jsRuntime' of https://github.com/microsoft/BotF…
VanyLaw Aug 18, 2020
3685c57
Merge branch 'main' into wenyluo/jsRuntime
cwhitten Aug 18, 2020
92fdcd2
modify readme
VanyLaw Aug 19, 2020
b09273d
Merge remote-tracking branch 'origin/main' into wenyluo/jsRuntime
VanyLaw Aug 19, 2020
3927454
merge multi parameter into object
VanyLaw Aug 19, 2020
59a5650
Merge branch 'main' into wenyluo/jsRuntime
cwhitten Aug 19, 2020
e94acbc
Merge branch 'main' into wenyluo/jsRuntime
cwhitten Aug 19, 2020
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
24 changes: 22 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
base-path: ./Composer

botproject:
name: BotProject
name: BotProject-dotnet
runs-on: windows-latest
timeout-minutes: 20

Expand All @@ -67,11 +67,31 @@ jobs:
run: dotnet test
working-directory: runtime/dotnet/tests

nodejs:
name: BotProject-nodejs
runs-on: ubuntu-latest
timeout-minutes: 20

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set Node Version
uses: actions/setup-node@v1
with:
node-version: 12.13.0
- name: npm install
run: npm install
working-directory: runtime/node
- name: npm build
run: npm run build
working-directory: runtime/node
- name: npm test
run: npm run test
working-directory: runtime/node
# docker-build:
# name: Docker Build
# timeout-minutes: 20
# runs-on: ubuntu-latest

# steps:
# - name: Checkout
# uses: actions/checkout@v2
Expand Down
28 changes: 8 additions & 20 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
],
"sourceMaps": true,
"cwd": "${workspaceFolder}/Composer/packages/tools/language-servers/language-understanding/demo/src",
"protocol": "inspector",
"protocol": "inspector"
},
{
"name": "LG LSP Server",
Expand All @@ -38,20 +38,16 @@
],
"sourceMaps": true,
"cwd": "${workspaceFolder}/Composer/packages/tools/language-servers/language-generation/demo/src",
"protocol": "inspector",
"protocol": "inspector"
},
{
"type": "node",
"request": "launch",
"name": "Server: Launch",
"args": [
"./build/server.js"
],
"args": ["./build/server.js"],
"preLaunchTask": "server: build",
"restart": true,
"outFiles": [
"./build/*"
],
"outFiles": ["./build/*"],
"envFile": "${workspaceFolder}/Composer/packages/server/.env",
"outputCapture": "std",
"cwd": "${workspaceFolder}/Composer/packages/server"
Expand All @@ -63,14 +59,8 @@
"name": "Jest Debug",
"program": "${workspaceRoot}/Composer/node_modules/jest/bin/jest",
"stopOnEntry": false,
"args": [
"--runInBand",
"--env=jsdom",
"--config=jest.config.js"
],
"runtimeArgs": [
"--inspect-brk"
],
"args": ["--runInBand", "--env=jsdom", "--config=jest.config.js"],
"runtimeArgs": ["--inspect-brk"],
"cwd": "${workspaceRoot}/Composer/packages/server",
"sourceMaps": true,
"console": "integratedTerminal"
Expand All @@ -87,11 +77,9 @@
"request": "launch",
"name": "Electron Main Process",
"runtimeExecutable": "${workspaceRoot}/Composer/node_modules/.bin/electron",
"args": [
"${workspaceRoot}/Composer/packages/electron-server",
],
"args": ["${workspaceRoot}/Composer/packages/electron-server"],
"env": {
"NODE_ENV": "development",
"NODE_ENV": "development"
},
"outputCapture": "std"
},
Expand Down
1 change: 1 addition & 0 deletions Composer/.npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
@bfcomposer:registry=https://botbuilder.myget.org/F/botbuilder-declarative/npm/
scripts-prepend-node-path=true
4 changes: 2 additions & 2 deletions Composer/cypress/integration/LuisDeploy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
context('Luis Deploy', () => {
beforeEach(() => {
cy.server();
cy.route('POST', '/api/publish/*/publish/default', { endpointURL: 'anything' });
cy.route('POST', '/api/publish/*/publish/default', { endpointURL: 'anything', status: 202 });
cy.route('POST', '/api/projects/*/settings', 'OK');
cy.route('GET', '/api/publish/*/status/default', { endpointURL: 'anything' });
cy.route('GET', '/api/publish/*/status/default', { endpointURL: 'anything', status: 200 });
cy.visit('/home');
cy.createBot('ToDoBotWithLuisSample');
});
Expand Down
6 changes: 5 additions & 1 deletion Composer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@
"build:server": "yarn workspace @bfc/server build",
"build:client": "yarn workspace @bfc/client build",
"build:tools": "yarn workspace @bfc/tools build:all",
"build:plugins": "cd plugins && yarn install && yarn build:all",
"build:plugins": "yarn build:plugins:localpublish && yarn build:plugins:samples && yarn build:plugins:azurePublish && yarn build:plugins:runtimes",
"build:plugins:localpublish": "cd plugins/localPublish && yarn install && yarn build",
"build:plugins:samples": "cd plugins/samples && yarn install && yarn build",
"build:plugins:azurePublish": "cd plugins/azurePublish && yarn install && yarn build",
"build:plugins:runtimes": "cd plugins/runtimes && yarn install && yarn build",
"start": "cross-env NODE_ENV=production PORT=3000 yarn start:server",
"startall": "yarn start",
"start:dev": "concurrently \"npm:start:client\" \"npm:start:server:dev\"",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { jsx, css } from '@emotion/core';
import { PrimaryButton } from 'office-ui-fabric-react/lib/Button';
import formatMessage from 'format-message';
import { useRecoilValue } from 'recoil';
import { defaultPublishConfig } from '@bfc/shared';

import { DefaultPublishConfig } from '../../constants';
import {
botNameState,
botStatusState,
Expand Down Expand Up @@ -49,10 +49,12 @@ export const botButton = css`
`;

// -------------------- TestController -------------------- //

const POLLING_INTERVAL = 2500;
export const TestController: React.FC = () => {
const [modalOpen, setModalOpen] = useState(false);
const [calloutVisible, setCalloutVisible] = useState(false);
const [botStatusInterval, setBotStatusInterval] = useState<NodeJS.Timeout | undefined>(undefined);

const botActionRef = useRef(null);
const notifications = useNotifications();
const botName = useRecoilValue(botNameState);
Expand Down Expand Up @@ -82,20 +84,34 @@ export const TestController: React.FC = () => {

useEffect(() => {
if (projectId) {
getPublishStatus(projectId, DefaultPublishConfig);
getPublishStatus(projectId, defaultPublishConfig);
}
}, [projectId]);

useEffect(() => {
switch (botStatus) {
case BotStatus.failed:
openCallout();
stopPollingRuntime();
setBotStatus(BotStatus.pending);
break;
case BotStatus.published:
stopPollingRuntime();
handleLoadBot();
break;
case BotStatus.reloading:
startPollingRuntime();
break;
default:
case BotStatus.connected:
stopPollingRuntime();
break;
}
// return the stoppolling function so the component will clean up
return () => {
stopPollingRuntime();
return;
};
}, [botStatus]);

function dismissDialog() {
Expand All @@ -114,6 +130,23 @@ export const TestController: React.FC = () => {
setCalloutVisible(true);
}

function startPollingRuntime() {
if (!botStatusInterval) {
const cancelInterval = setInterval(() => {
// get publish status
getPublishStatus(projectId, defaultPublishConfig);
}, POLLING_INTERVAL);
setBotStatusInterval(cancelInterval);
}
}

function stopPollingRuntime() {
if (botStatusInterval) {
clearInterval(botStatusInterval);
setBotStatusInterval(undefined);
}
}

async function handlePublishLuis(luisConfig) {
setBotStatus(BotStatus.publishing);
dismissDialog();
Expand All @@ -124,7 +157,7 @@ export const TestController: React.FC = () => {
async function handleLoadBot() {
setBotStatus(BotStatus.reloading);
const sensitiveSettings = settingsStorage.get(projectId);
await publishToTarget(projectId, DefaultPublishConfig, { comment: '' }, sensitiveSettings);
await publishToTarget(projectId, defaultPublishConfig, { comment: '' }, sensitiveSettings);
}

function isLuisConfigComplete(config) {
Expand Down
5 changes: 0 additions & 5 deletions Composer/packages/client/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,6 @@ export enum AppUpdaterStatus {
UPDATE_SUCCEEDED,
}

export const DefaultPublishConfig = {
name: 'default',
type: 'localpublish',
};

export const EmptyBotTemplateId = 'EmptyBot';

export const nameRegex = /^[a-zA-Z0-9-_]+$/;
4 changes: 2 additions & 2 deletions Composer/packages/client/src/pages/publish/Publish.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { RouteComponentProps } from '@reach/router';
import formatMessage from 'format-message';
import { Dialog, DialogType } from 'office-ui-fabric-react/lib/Dialog';
import { TextField } from 'office-ui-fabric-react/lib/TextField';
import { useRecoilValue } from 'recoil';
import { PublishTarget } from '@bfc/shared';
import { useRecoilValue } from 'recoil';

import settingsStorage from '../../utils/dialogSettingStorage';
import { projectContainer } from '../design/styles';
Expand Down Expand Up @@ -224,7 +224,7 @@ const Publish: React.FC<PublishPageProps> = (props) => {
},
]);
}
}, [publishHistory, selectedTargetName]);
}, [publishHistory, selectedTargetName, settings.publishTargets]);

// check history to see if a 202 is found
useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
dispatcherState,
ejectRuntimeSelector,
boilerplateVersionState,
isEjectRuntimeExistState,
} from '../../../recoilModel';
import { OpenConfirmModal } from '../../../components/Modal/ConfirmDialog';
import { LoadingSpinner } from '../../../components/LoadingSpinner';
Expand All @@ -33,17 +34,22 @@ export const RuntimeSettings: React.FC<RouteComponentProps> = () => {
const settings = useRecoilValue(settingsState);
const projectId = useRecoilValue(projectIdState);
const boilerplateVersion = useRecoilValue(boilerplateVersionState);

const { setCustomRuntime, setRuntimeField, getBoilerplateVersion, updateBoilerplate } = useRecoilValue(
dispatcherState
);
const isEjectRuntimeExist = useRecoilValue(isEjectRuntimeExistState);
const {
setCustomRuntime,
setRuntimeField,
getBoilerplateVersion,
updateBoilerplate,
stopPublishBot,
} = useRecoilValue(dispatcherState);
const runtimeEjection = useRecoilValue(ejectRuntimeSelector);

const [formDataErrors, setFormDataErrors] = useState({ command: '', path: '' });
const [ejectModalVisible, setEjectModalVisible] = useState(false);
const [working, setWorking] = useState(false);
const [ejecting, setEjecting] = useState(false);
const [needsUpdate, setNeedsUpdate] = useState(false);
const [templateKey, setTemplateKey] = useState('');

useEffect(() => {
// check the status of the boilerplate material and see if it requires an update
Expand All @@ -54,6 +60,13 @@ export const RuntimeSettings: React.FC<RouteComponentProps> = () => {
setNeedsUpdate(boilerplateVersion.updateRequired || false);
}, [boilerplateVersion.updateRequired]);

useEffect(() => {
if (isEjectRuntimeExist && templateKey) {
confirmReplaceEject(templateKey);
setTemplateKey('');
}
}, [isEjectRuntimeExist, templateKey]);

const handleChangeToggle = (_, isOn = false) => {
setCustomRuntime(projectId, isOn);
};
Expand Down Expand Up @@ -104,6 +117,7 @@ export const RuntimeSettings: React.FC<RouteComponentProps> = () => {
closeEjectModal();
await runtimeEjection?.onAction(projectId, templateKey);
setEjecting(false);
setTemplateKey(templateKey);
};

const callUpdateBoilerplate = async () => {
Expand All @@ -125,6 +139,20 @@ export const RuntimeSettings: React.FC<RouteComponentProps> = () => {
}
};

const confirmReplaceEject = async (templateKey: string) => {
const title = formatMessage('Runtime already exists');
const msg = formatMessage('Are you sure you want to stop current runtime and replace them?');
const res = await OpenConfirmModal(title, msg);
if (res) {
setEjecting(true);
// stop runtime
await stopPublishBot(projectId);
// replace the runtime
await runtimeEjection?.onAction(projectId, templateKey, true);
setEjecting(false);
}
};

return botName ? (
<div css={runtimeSettingsStyle}>
{header()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export interface EjectModalProps {

export const EjectModal: React.FC<EjectModalProps> = (props) => {
const [selectedTemplate, setSelectedTemplate] = useState<string | undefined>();

const runtimeTemplates = useRecoilValue(runtimeTemplatesState);
const { fetchRuntimeTemplates } = useRecoilValue(dispatcherState);

Expand Down
6 changes: 5 additions & 1 deletion Composer/packages/client/src/recoilModel/atoms/botState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { BotLoadError, DesignPageLocation } from '../../recoilModel/types';

import { PublishType, BreadcrumbItem } from './../../recoilModel/types';
import { BotStatus } from './../../constants';

const getFullyQualifiedKey = (value: string) => {
return `Bot_${value}_State`;
};
Expand Down Expand Up @@ -204,3 +203,8 @@ export const onDelLanguageDialogCompleteState = atom<any>({
key: getFullyQualifiedKey('onDelLanguageDialogComplete'),
default: { func: undefined },
});

export const isEjectRuntimeExistState = atom<boolean>({
key: getFullyQualifiedKey('isEjectRuntimeExist'),
default: false,
});
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,14 @@ describe('setting dispatcher', () => {

it('should update RuntimeSettings', async () => {
await act(async () => {
await dispatcher.setRuntimeSettings('', 'path', 'command');
await dispatcher.setRuntimeSettings('', { path: 'path', command: 'command', key: 'key', name: 'name' });
});

expect(renderedComponent.current.settings.runtime.customRuntime).toBeTruthy();
expect(renderedComponent.current.settings.runtime.path).toBe('path');
expect(renderedComponent.current.settings.runtime.command).toBe('command');
expect(renderedComponent.current.settings.runtime.key).toBe('key');
expect(renderedComponent.current.settings.runtime.name).toBe('name');
});

it('should update customRuntime', async () => {
Expand Down
Loading