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

fix: Hide deprecated "custom runtime" related features for adaptive rutime #6367

Merged
merged 17 commits into from
Mar 31, 2021
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 => {
benbrown marked this conversation as resolved.
Show resolved Hide resolved
return (
settings?.runtime?.key === 'csharp-azurewebapp-v2' ||
(settings?.runtime?.key.match(/^adaptive-runtime/) ? true : false)
benbrown marked this conversation as resolved.
Show resolved Hide resolved
);
};

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));
benbrown marked this conversation as resolved.
Show resolved Hide resolved
}, [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