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

chore: migrate continue trial form and remove steps [DET-3780 DET-3854] #1050

Merged
merged 2 commits into from
Aug 14, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 5 additions & 4 deletions webui/react/config-overrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,13 @@ const webpackConfig = override(
// available options are documented at https://github.com/Microsoft/monaco-editor-webpack-plugin#options
languages: ['yaml'],
features: [
'suggest',
'codelens',
'colorDetector',
'find',
'parameterHints',
'quickOutline',
'suggest',
'wordHighlighter',
'colorDetector',
'codelens',
'parameterHints'
],
})
),
Expand Down
18 changes: 12 additions & 6 deletions webui/react/src/components/CreateExperimentModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,19 @@ import { forkExperiment } from 'services/api';
import css from './CreateExperimentModal.module.scss';

interface Props {
hamidzr marked this conversation as resolved.
Show resolved Hide resolved
title: string;
okText: string;
parentId: number;
visible: boolean;
config: string;
onVisibleChange: (visible: boolean) => void;
error?: string;
okText: string;
onCancel?: () => void;
onConfigChange: (config: string) => void;
onVisibleChange: (visible: boolean) => void;
parentId: number; // parent experiment ID.
title: string;
visible: boolean;
}

const CreateExperimentModal: React.FC<Props> = (
{ visible, config, onVisibleChange, onConfigChange, parentId, ...props }: Props,
{ visible, config, onVisibleChange, onConfigChange, parentId, error, ...props }: Props,
) => {
const [ configError, setConfigError ] = useState<string>();

Expand Down Expand Up @@ -47,6 +49,7 @@ const CreateExperimentModal: React.FC<Props> = (
};

const handleCancel = (): void => {
props.onCancel && props.onCancel();
onVisibleChange(false);
};
return <Modal
Expand Down Expand Up @@ -78,6 +81,9 @@ const CreateExperimentModal: React.FC<Props> = (
{configError &&
<Alert className={css.error} message={configError} type="error" />
}
{error &&
<Alert className={css.error} message={error} type="error" />
}
</Modal>;

};
Expand Down
43 changes: 28 additions & 15 deletions webui/react/src/pages/ExperimentDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { clone } from 'utils/data';
import { alphanumericSorter, numericSorter, runStateSorter, stringTimeSorter } from 'utils/data';
import { humanReadableFloat } from 'utils/string';
import { getDuration } from 'utils/time';
import { upgradeConfig } from 'utils/types';

import css from './ExperimentDetails.module.scss';

Expand All @@ -55,23 +56,34 @@ const ExperimentDetailsComp: React.FC = () => {
const [ forkModalVisible, setForkModalVisible ] = useState(false);
const [ forkModalConfig, setForkModalConfig ] = useState('Loading');

const setFreshForkConfig = useCallback(() => {
if (!experiment?.configRaw) return;
// do not reset the config if the modal is open
if (forkModalVisible) return;
const prefix = 'Fork of ';
const rawConfig = clone(experiment.configRaw);
rawConfig.description = prefix + rawConfig.description;
upgradeConfig(rawConfig);
setForkModalConfig(yaml.safeDump(rawConfig));
}, [ experiment?.configRaw, forkModalVisible ]);

const handleForkModalCancel = useCallback(() => {
setForkModalVisible(false);
setFreshForkConfig();
}, [ setFreshForkConfig ]);

useEffect(() => {
if (experiment && experiment.config) {
try {
const prefix = 'Fork of ';
const rawConfig = clone(experiment.configRaw);
rawConfig.description = prefix + rawConfig.description;
setForkModalConfig(yaml.safeDump(rawConfig));
} catch (e) {
handleError({
error: e,
message: 'failed to load experiment config',
type: ErrorType.ApiBadResponse,
});
setForkModalConfig('failed to load experiment config');
}
try {
setFreshForkConfig();
} catch (e) {
handleError({
error: e,
message: 'failed to load experiment config',
type: ErrorType.ApiBadResponse,
});
setForkModalConfig('failed to load experiment config');
}
}, [ experiment ]);
}, [ setFreshForkConfig ]);

const showForkModal = useCallback((): void => {
setForkModalVisible(true);
Expand Down Expand Up @@ -237,6 +249,7 @@ const ExperimentDetailsComp: React.FC = () => {
parentId={id}
title={`Fork Experiment ${id}`}
visible={forkModalVisible}
onCancel={handleForkModalCancel}
onConfigChange={setForkModalConfig}
onVisibleChange={setForkModalVisible}
/>
Expand Down
Loading