ciyidogan commited on
Commit
2888e07
·
verified ·
1 Parent(s): afe7199

Update flare-ui/src/app/dialogs/version-edit-dialog/version-edit-dialog.component.ts

Browse files
flare-ui/src/app/dialogs/version-edit-dialog/version-edit-dialog.component.ts CHANGED
@@ -287,42 +287,71 @@ export default class VersionEditDialogComponent implements OnInit {
287
 
288
  async createVersion() {
289
  const dialogRef = this.dialog.open(ConfirmDialogComponent, {
290
- width: '500px',
291
  data: {
292
  title: 'Create New Version',
293
- message: 'Which version would you like to use as a base for the new version?',
 
 
 
 
 
 
294
  confirmText: 'Create',
295
- showVersionSelect: true,
296
- versions: this.versions
297
  }
298
  });
299
-
300
- dialogRef.afterClosed().subscribe(async (sourceVersionId) => {
301
- if (sourceVersionId) {
302
- this.creating = true;
303
  try {
304
- const result = await this.apiService.createVersion(this.project.id, {
305
- source_version_id: sourceVersionId,
306
- caption: 'New Version'
307
- }).toPromise();
308
-
309
- this.snackBar.open('Version created successfully', 'Close', { duration: 3000 });
310
-
311
- // Reload project to get new version
312
- await this.reloadProject();
313
 
314
- // Select the new version
315
- const newVersion = this.versions.find(v => v.id === result.id);
316
- if (newVersion) {
317
- this.loadVersion(newVersion);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
318
  }
319
- } catch (error: any) {
320
- this.snackBar.open(error.error?.detail || 'Failed to create version', 'Close', {
321
- duration: 5000,
322
- panelClass: 'error-snackbar'
323
- });
 
 
 
324
  } finally {
325
- this.creating = false;
326
  }
327
  }
328
  });
 
287
 
288
  async createVersion() {
289
  const dialogRef = this.dialog.open(ConfirmDialogComponent, {
290
+ width: '400px',
291
  data: {
292
  title: 'Create New Version',
293
+ message: 'Select source version:',
294
+ showDropdown: true,
295
+ dropdownOptions: this.versions.map(v => ({
296
+ value: v.id,
297
+ label: `Version ${v.id}${v.published ? ' (Published)' : ''}${v.description ? ' - ' + v.description : ''}`
298
+ })),
299
+ dropdownPlaceholder: 'Select source version (or leave empty for blank)',
300
  confirmText: 'Create',
301
+ cancelText: 'Cancel'
 
302
  }
303
  });
304
+
305
+ dialogRef.afterClosed().subscribe(async (result) => {
306
+ if (result?.confirmed) {
307
+ this.loading = true;
308
  try {
309
+ let newVersionData;
 
 
 
 
 
 
 
 
310
 
311
+ if (result.selectedValue) {
312
+ // Copy from selected version
313
+ const sourceVersion = this.versions.find(v => v.id === result.selectedValue);
314
+ if (sourceVersion) {
315
+ newVersionData = {
316
+ ...sourceVersion,
317
+ id: undefined,
318
+ published: false,
319
+ last_update_date: undefined,
320
+ description: `Copy of version ${sourceVersion.id}`
321
+ };
322
+ }
323
+ } else {
324
+ // Create blank version
325
+ newVersionData = {
326
+ description: 'New version',
327
+ default_api: '',
328
+ published: false,
329
+ llm: {
330
+ repo_id: '',
331
+ generation_config: {
332
+ max_new_tokens: 512,
333
+ temperature: 0.7,
334
+ top_p: 0.95,
335
+ top_k: 50,
336
+ repetition_penalty: 1.1
337
+ },
338
+ use_fine_tune: false,
339
+ fine_tune_zip: ''
340
+ },
341
+ intents: [],
342
+ parameters: []
343
+ };
344
  }
345
+
346
+ if (newVersionData) {
347
+ await this.apiService.createVersion(this.project.id, newVersionData).toPromise();
348
+ await this.loadVersions();
349
+ this.snackBar.open('Version created successfully!', 'Close', { duration: 3000 });
350
+ }
351
+ } catch (error) {
352
+ this.snackBar.open('Failed to create version', 'Close', { duration: 3000 });
353
  } finally {
354
+ this.loading = false;
355
  }
356
  }
357
  });