Skip to content

Commit

Permalink
Reformat code
Browse files Browse the repository at this point in the history
  • Loading branch information
duyguHsnHsn committed Mar 7, 2023
1 parent 5debb19 commit 2ec345f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { VdkOption } from '../vdkOptions/vdk_options';
const defaultProps: IDeployJobDialogProps = {
jobName: 'test-name',
jobTeam: 'test-team',
jobPath: 'test-path',
jobPath: 'test-path'
};

describe('#constructor()', () => {
Expand Down Expand Up @@ -44,15 +44,14 @@ describe('#render()', () => {
const input = component.getByPlaceholderText(defaultProps.jobPath);
expect(input).toBe(component.getAllByLabelText('Job Path:')[0]);
});

});

describe('#onEnableClick', () => {
it('should put a flag for enabled in jobData', () => {
const box = new DeployJobDialog(defaultProps);
const component = render(box.render());
const enableCheckbox = component.getAllByLabelText(
'Enable - un-pause the job'
'Enable'
)[0] as HTMLInputElement;
expect(enableCheckbox.checked).toEqual(false);
fireEvent.click(enableCheckbox);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,21 +232,16 @@ export function updateVDKMenu(commands: CommandRegistry) {
});
if (runConfirmationResult.button.accept) {
let success = await jobRunRequest();
let bodyMessage = "We encauntered some errors while trying to run the job! To see more please check the vdk_logs.txt file!\n Do you want to continue with deployment?"
if(success[1]){
bodyMessage = success[0] + " Do you want to continue with the deployment?"
}
const finalResult = await showDialog({
title: 'Create deployment',
body: bodyMessage,
buttons: [
Dialog.cancelButton({ label: 'Cancel' }),
Dialog.okButton({ label: 'Yes' })
]
});
if (finalResult.button.accept) {
// add server request
}
else{
showErrorMessage(
'Encauntered an error while running the job!',
success[0],
[Dialog.okButton()]
);
}
}
} catch (error) {
await showErrorMessage(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export default class DeployJobDialog extends Component<IDeployJobDialogProps> {
* @returns React element
*/
render(): React.ReactElement {
// TODO: switch the checkbox into radio buttons
return (
<>
<div className='jp-vdk-input-wrapper'>
Expand All @@ -58,8 +57,8 @@ export default class DeployJobDialog extends Component<IDeployJobDialogProps> {
<input type="text" id="deploymentReason" className='jp-vdk-input' placeholder="reason" onChange={this.onDeploymentReasonChange} />
</div>
<div>
<input type="checkbox" name="enable" id="enable" className='jp-vdk-checkbox' onClick={this.onEnableClick()} />
<label className="checkboxLabel" htmlFor="enable">Enable - un-pause the job</label>
<input type="checkbox" name="enable" id="enable" className='jp-vdk-checkbox' onClick={this.onEnableClick()} />
<label className="checkboxLabel" htmlFor="enable">Enable</label>
</div>
</>
);
Expand All @@ -86,63 +85,46 @@ export default class DeployJobDialog extends Component<IDeployJobDialogProps> {
* @param event - event object
*/
private onNameChange = (event: any): void => {
const nameInput = event.currentTarget as HTMLInputElement;
let value = nameInput.value;
if (!value) {
value = this.props.jobName;
}
jobData.set(VdkOption.NAME, value);
this.populateJobData(VdkOption.NAME, event.currentTarget as HTMLInputElement);
};
/**
* Callback invoked upon changing the job team input.
*
* @param event - event object
*/
private onTeamChange = (event: any): void => {
const teamInput = event.currentTarget as HTMLInputElement;
let value = teamInput.value;
if (!value) {
value = "default-team";
}
jobData.set(VdkOption.TEAM, value);
this.populateJobData(VdkOption.TEAM, event.currentTarget as HTMLInputElement);
};
/**
* Callback invoked upon changing the job rest-api-url input.
*
* @param event - event object
*/
private onRestApiUrlChange = (event: any): void => {
const urlInput = event.currentTarget as HTMLInputElement;
let value = urlInput.value;
if (!value) {
value = "default-url";
}
jobData.set(VdkOption.REST_API_URL, value);
this.populateJobData(VdkOption.REST_API_URL, event.currentTarget as HTMLInputElement);
};
/**
* Callback invoked upon changing the job path input.
*
* @param event - event object
*/
private onPathChange = (event: any): void => {
const pathInput = event.currentTarget as HTMLInputElement;
let value = pathInput.value;
if (!value) {
value = this.props.jobPath;
}
jobData.set(VdkOption.PATH, value);
this.populateJobData(VdkOption.PATH, event.currentTarget as HTMLInputElement);
};
/**
* Callback invoked upon changing the deployent reason input.
*
* @param event - event object
*/
private onDeploymentReasonChange = (event: any): void => {
const pathInput = event.currentTarget as HTMLInputElement;
let value = pathInput.value;
if (!value) {
value = "";
}
jobData.set(VdkOption.DEPLOYMENT_REASON, value);
this.populateJobData(VdkOption.DEPLOYMENT_REASON, event.currentTarget as HTMLInputElement);
};
/**
* Helper function for populating jobData
*/
private populateJobData(option: VdkOption, input: HTMLInputElement) {
let value = input.value;
if (!value) value = "";
jobData.set(option, value);
}
}

0 comments on commit 2ec345f

Please sign in to comment.