Skip to content

Commit

Permalink
chore: remove legacy camera transformation, closes #3139
Browse files Browse the repository at this point in the history
add proper error handling
add (bad) if condition for tests in customConfigHelper.ts
  • Loading branch information
friedrich-roskosch-mw committed Jan 12, 2023
1 parent 65209e6 commit cfaf05b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ export class ApplyCustomConfigButtonComponent {
) {}

applyCustomConfig() {
CustomConfigHelper.applyCustomConfig(this.customConfigItem.id, this.store, this.threeCameraService, this.threeOrbitControlsService)
try {
CustomConfigHelper.applyCustomConfig(
this.customConfigItem.id,
this.store,
this.threeCameraService,
this.threeOrbitControlsService
)
} catch (error) {
console.error(`${error.name}: ${error.message}`)
alert(`Unable to load Custom-View-file: ${error.message}`)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ export class UploadCustomConfigButtonComponent {
for (const customConfigContent of customConfigsContent) {
try {
CustomConfigHelper.importCustomConfigs(customConfigContent)
} catch {
// Explicitly ignored
} catch (error) {
console.error(`${error.name}: ${error.message}`)
alert(`Unable to load Custom-View-file: ${error.message}`)
}
}
})
Expand Down
17 changes: 8 additions & 9 deletions visualization/app/codeCharta/util/customConfigHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ export class CustomConfigHelper {
camera: exportedConfig.camera
}

CustomConfigHelper.checkForLegacyCameraSettingsOfCustomConfig(importedCustomConfig)

CustomConfigHelper.addCustomConfig(importedCustomConfig)
}
}
Expand Down Expand Up @@ -215,7 +217,7 @@ export class CustomConfigHelper {
threeOrbitControlsService: ThreeOrbitControlsService
) {
const customConfig = this.getCustomConfigSettings(configId)
CustomConfigHelper.transformLegacyCameraSettingsOfCustomConfig(customConfig)
CustomConfigHelper.checkForLegacyCameraSettingsOfCustomConfig(customConfig)
CustomConfigHelper.deleteUnusedKeyPropsOfCustomConfig(customConfig)

store.dispatch(setState(customConfig.stateSettings))
Expand All @@ -230,16 +232,13 @@ export class CustomConfigHelper {
}
}

// TODO [2023-01-01] remove support
private static transformLegacyCameraSettingsOfCustomConfig(customConfig: any) {
private static checkForLegacyCameraSettingsOfCustomConfig(customConfig: any) {
if (customConfig.appSettings === undefined) {
return
}
const appSettings = customConfig.stateSettings.appSettings
if (appSettings.camera || appSettings.cameraTarget) {
customConfig.camera = {
camera: appSettings.camera,
cameraTarget: appSettings.cameraTarget
}
delete customConfig.stateSettings.appSettings.camera
delete customConfig.stateSettings.appSettings.cameraTarget
throw new Error("CustomConfig contained unsupported legacy camera data.")
}
}

Expand Down

0 comments on commit cfaf05b

Please sign in to comment.