Skip to content
Snippets Groups Projects

Resolve "Resource path can't be parsed if the version is the latest"

Merged Daniel Göbel requested to merge bugfix/115-fix-latest-resource-path-parser into main
3 files
+ 145
159
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -63,21 +63,18 @@ const inputDynamicClass = computed<string[]>(() => {
@@ -63,21 +63,18 @@ const inputDynamicClass = computed<string[]>(() => {
});
});
function updateResourceId(rid: string) {
function updateResourceId(rid: string) {
console.log("Update resource", rid);
resource.resource_id = rid;
resource.resource_id = rid;
resource.resource_version_id = "";
resource.resource_version_id = "";
model.value = translateToModel();
model.value = translateToModel();
}
}
function updateResourceVersionId(rvid: string) {
function updateResourceVersionId(rvid: string) {
console.log("Update resource version", rvid);
resource.resource_version_id = rvid;
resource.resource_version_id = rvid;
model.value = translateToModel();
model.value = translateToModel();
resourceRepository.fetchResourceTree(resource.resource_id, rvid);
resourceRepository.fetchResourceTree(resource.resource_id, rvid);
}
}
watch(model, (newVal, oldVal) => {
watch(model, (newVal, oldVal) => {
console.log("Update Model", newVal, oldVal);
if (newVal != oldVal && newVal !== translateToModel()) {
if (newVal != oldVal && newVal !== translateToModel()) {
/* eslint-disable @typescript-eslint/ban-ts-comment */
/* eslint-disable @typescript-eslint/ban-ts-comment */
// @ts-ignore
// @ts-ignore
@@ -104,7 +101,7 @@ function parseModel(val?: string) {
@@ -104,7 +101,7 @@ function parseModel(val?: string) {
tempResource.resource_version_id =
tempResource.resource_version_id =
match[2].length === 32
match[2].length === 32
? hexToUUID(match[2])
? hexToUUID(match[2])
: resourceRepository.getLatestVersion(resource.resource_id);
: resourceRepository.getLatestVersion(tempResource.resource_id);
if (
if (
resourceRepository.resourceMapping[tempResource.resource_id] ==
resourceRepository.resourceMapping[tempResource.resource_id] ==
undefined ||
undefined ||
@@ -112,14 +109,12 @@ function parseModel(val?: string) {
@@ -112,14 +109,12 @@ function parseModel(val?: string) {
undefined
undefined
) {
) {
// Missing resource
// Missing resource
console.error(`Resource ${val} unknown`);
emit("switch-to-raw");
emit("switch-to-raw");
return;
return;
}
}
Object.assign(resource, tempResource);
Object.assign(resource, tempResource);
} else {
} else {
// Not resource path
// Not resource path
console.error(`${val} not a resource path`);
emit("switch-to-raw");
emit("switch-to-raw");
}
}
}
}
@@ -142,25 +137,15 @@ watch(
@@ -142,25 +137,15 @@ watch(
);
);
function translateToModel(): string {
function translateToModel(): string {
console.log(
"Update model start",
resource.resource_id,
resource.resource_version_id,
);
if (resource.resource_version_id.length === 0) {
if (resource.resource_version_id.length === 0) {
return "";
return "";
}
}
let val =
let val =
resourceRepository.versionMapping[resource.resource_version_id]
resourceRepository.versionMapping[resource.resource_version_id]
?.cluster_path ?? "";
?.cluster_path ?? "";
console.log(
"mapped",
resourceRepository.versionMapping[resource.resource_version_id],
);
if (resource.suffix != undefined && val.length > 0) {
if (resource.suffix != undefined && val.length > 0) {
val = val + resource.suffix;
val = val + resource.suffix;
}
}
console.log("Update Model", val);
return val;
return val;
}
}
Loading