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

vdk-jupyter: fix arguments input size #2685

Merged
merged 2 commits into from
Sep 21, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,8 @@ import { RUN_FAILED_BUTTON_LABEL, RUN_JOB_BUTTON_LABEL } from '../utils';
import { StatusButton } from './StatusButton';
import { checkIcon } from '@jupyterlab/ui-components';

interface IRunJobDialogState {
inputWidth: number;
}

export default class RunJobDialog extends Component<IJobPathProp> {
state: IRunJobDialogState = {
inputWidth: 0
};

/**
* Returns a React component for rendering a run menu.
Expand All @@ -36,29 +30,19 @@ export default class RunJobDialog extends Component<IJobPathProp> {
* @returns React element
*/
render(): React.ReactElement {
const { inputWidth } = this.state;
return (
<>
<VDKTextInput
option={VdkOption.PATH}
value={this.props.jobPath}
label="Path to job directory:"
onWidthComputed={(width) => this.setState({ inputWidth: width })}
/>
<div className="jp-vdk-input-wrapper">
<label className="jp-vdk-label" htmlFor="arguments">
Arguments:
</label>
<input
type="text"
id="arguments"
className="jp-vdk-input"
placeholder='{"key": "value"}'
onChange={this._onArgsChange}
style={{ width: `${inputWidth}px` }}
/>
</div>
<ul id="argumentsUl" className="hidden"></ul>
<VDKTextInput
option={VdkOption.ARGUMENTS}
value={'{"key": "value"}'}
label="Arguments:"
onChange={this._onArgsChange}
/>
</>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ export interface IVdkTextInputProps {
* Optional tooltip content.
*/
tooltip?: string;
/**
* Custom change handler if provided
*/
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
}

interface IVdkInputState {
Expand Down Expand Up @@ -147,6 +151,10 @@ export default class VDKTextInput extends Component<IVdkTextInputProps> {
* @param event - The event object containing details about the change event.
*/
private onInputChange = (event: any): void => {
if (this.props.onChange) {
this.props.onChange(event);
}

const nameInput = event.currentTarget as HTMLInputElement;
let value = nameInput.value;
if (!value) value = this.props.value;
Expand Down