Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.
Merged
Changes from 10 commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import { jsx } from '@emotion/core';
import { useState, Fragment, useEffect } from 'react';
import formatMessage from 'format-message';
import { mergeStyleSets } from '@uifabric/styling';
import { Toggle } from 'office-ui-fabric-react/lib/Toggle';
import { DefaultButton } from 'office-ui-fabric-react/lib/Button';
import { TextField } from 'office-ui-fabric-react/lib/TextField';
Expand All @@ -15,6 +16,7 @@ import { RouteComponentProps } from '@reach/router';
import { useRecoilValue } from 'recoil';
import { Spinner } from 'office-ui-fabric-react/lib/Spinner';
import { OpenConfirmModal } from '@bfc/ui-shared';
import { DialogSetting } from '@botframework-composer/types';

import {
dispatcherState,
Expand Down Expand Up @@ -43,6 +45,14 @@ import {

type RuntimeType = 'path' | 'command';

/** Determine if a bot is configured to use the adaptive runtime vs the legacy runtime */
export const isAdaptiveRuntime = (settings: DialogSetting): boolean => {
Comment thread
benbrown marked this conversation as resolved.
Outdated
return (
settings?.runtime?.key === 'csharp-azurewebapp-v2' ||
(settings?.runtime?.key.match(/^adaptive-runtime/) ? true : false)
Comment thread
benbrown marked this conversation as resolved.
Outdated
);
};

export const RuntimeSettings: React.FC<RouteComponentProps<{ projectId: string }>> = (props) => {
const { projectId = '' } = props;
const botName = useRecoilValue(botDisplayNameState(projectId));
Expand All @@ -67,11 +77,13 @@ export const RuntimeSettings: React.FC<RouteComponentProps<{ projectId: string }
const [templateKey, setTemplateKey] = useState('');
const [runtimePath, setRuntimePath] = useState(settings.runtime?.path ?? '');
const [runtimeCommand, setRuntimeCommand] = useState(settings.runtime?.command ?? '');
const [isAdaptive, setIsAdaptive] = useState(false);
const [usingCustomRuntime, setUsingCustomRuntime] = useState(settings.runtime?.customRuntime ?? false);

useEffect(() => {
// check the status of the boilerplate material and see if it requires an update
if (projectId) getBoilerplateVersion(projectId);
setIsAdaptive(isAdaptiveRuntime(settings));
Comment thread
benbrown marked this conversation as resolved.
Outdated
}, [projectId]);

useEffect(() => {
Expand Down Expand Up @@ -225,36 +237,43 @@ export const RuntimeSettings: React.FC<RouteComponentProps<{ projectId: string }
return botName ? (
<div css={runtimeSettingsStyle} id="runtimeSettings">
{header()}
{toggleOfCustomRuntime()}
{!isAdaptive && toggleOfCustomRuntime()}
<div>
{!isAdaptive && (
<TextField
required
data-testid="runtimeCodeLocation"
disabled={!settings.runtime || !settings.runtime.customRuntime}
errorMessage={errorElement(formDataErrors.path)}
label={formatMessage('Runtime code location')}
styles={mergeStyleSets({ root: { marginTop: 10 } }, customError)}
value={runtimePath}
onBlur={() => handleRuntimeSettingOnBlur('path')}
onChange={handleRuntimeSettingOnChange('path')}
onRenderLabel={onRenderLabel}
/>
)}
{!isAdaptive && (
<div>
<span css={textOr}>{formatMessage('Or: ')}</span>
<Link
css={breathingSpace}
disabled={!settings.runtime || !settings.runtime.customRuntime}
onClick={showEjectModal}
>
{formatMessage('Get a new copy of the runtime code')}
</Link>
</div>
)}
</div>
<div>
<TextField
required
data-testid="runtimeCodeLocation"
disabled={!settings.runtime || !settings.runtime.customRuntime}
errorMessage={errorElement(formDataErrors.path)}
label={formatMessage('Runtime code location')}
styles={customError}
value={runtimePath}
onBlur={() => handleRuntimeSettingOnBlur('path')}
onChange={handleRuntimeSettingOnChange('path')}
onRenderLabel={onRenderLabel}
/>
<span css={textOr}>{formatMessage('Or: ')}</span>
<Link
css={breathingSpace}
disabled={!settings.runtime || !settings.runtime.customRuntime}
onClick={showEjectModal}
>
{formatMessage('Get a new copy of the runtime code')}
</Link>

<TextField
required
data-testid="runtimeCommand"
disabled={!settings.runtime || !settings.runtime.customRuntime}
errorMessage={errorElement(formDataErrors.command)}
label={formatMessage('Start command')}
styles={customError}
styles={mergeStyleSets({ root: { marginTop: 10 } }, customError)}
value={runtimeCommand}
onBlur={() => handleRuntimeSettingOnBlur('command')}
onChange={handleRuntimeSettingOnChange('command')}
Expand Down