Skip to content
Open
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
2 changes: 0 additions & 2 deletions vscode-trace-extension/src/json-editor/file-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ export class FileService {
'* • Submit the current config',
'* • Save this config for future use',
'* • Load an existing config file',
'*',
'* You can also submit by simply closing the file',
'*/',
JSON.stringify(json, undefined, 2)
].join('\n');
Expand Down
25 changes: 6 additions & 19 deletions vscode-trace-extension/src/json-editor/json-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import { FileService } from './file-service';
export class JsonConfigEditor {
private _tempFilePath: string = '';
private isEditing: boolean = false;
private isAwaitingUserSubmit: boolean = false;
private availableConfigurations: CustomizationConfigObject[] = [];
private userClickedSubmit: boolean = false;
private trackedEditor?: vscode.TextEditor;
Expand Down Expand Up @@ -51,8 +50,6 @@ export class JsonConfigEditor {
throw Error(
'a config editing session is already active - Please close the active editor and try again.'
);
if (this.isAwaitingUserSubmit)
throw Error('awaiting prompt response - Please chose to if you want to submit then try again.');

this.availableConfigurations = configs;
const selectedConfig = await this.promptUserSchemaSelection(configs);
Expand Down Expand Up @@ -276,31 +273,22 @@ export class JsonConfigEditor {

try {
this.isEditing = false;
this.isAwaitingUserSubmit = true;
// Write content to temp file for validation
if (fs.existsSync(this.tempFilePath)) {
fs.writeFileSync(this.tempFilePath, document.getText(), 'utf8');
} else {
throw new Error('Temporary file not found');
}

if (!this.userClickedSubmit) {
return;
}

const validation = await this.schemaService.validateJsonFile(this.tempFileUri, schema);

if (validation.isValid && validation.content) {
const submit = this.userClickedSubmit
? 'Yes'
: await vscode.window.showInformationMessage(
'Do you want to submit this configuration?',
'Yes',
'No'
);

if (submit === 'Yes') {
vscode.window.showInformationMessage('Configuration submitted successfully');
return validation.content;
}

return undefined; // User chose not to submit
vscode.window.showInformationMessage('Configuration submitted successfully');
return validation.content;
} else if (validation.errors) {
this.displayValidationErrorDialogue(
`Your configuration was not submitted because it had errors`,
Expand All @@ -321,7 +309,6 @@ export class JsonConfigEditor {
private resetState = () => {
this.fileService.cleanupTempFile(this.tempFilePath);
this.userClickedSubmit = false;
this.isAwaitingUserSubmit = false;
this.isEditing = false;
this.trackedEditor = undefined;
this.tempFilePath = '';
Expand Down