Skip to content

Commit

Permalink
Fix migration
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikriemer committed Jan 28, 2025
1 parent 830a133 commit 93b9de8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@
import com.fasterxml.jackson.databind.ObjectMapper;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;

public class ModifyAssetLinksMigration implements Migration {

Expand Down Expand Up @@ -59,12 +61,13 @@ private void updateAssetLink(Map<String, Object> asset) {
if (asset.containsKey("assetLinks")) {
List<Map<String, Object>> assetLinks = castToListOfMaps(asset.get("assetLinks"));

assetLinks.removeIf(assetLink -> "dashboard".equals(assetLink.get("linkType")));
assetLinks.forEach(assetLink -> {
Optional.ofNullable(assetLink.get("linkType"))
.filter(linkType -> linkType.equals("data-view"))
.ifPresent(linkType -> {
assetLink.put("linkType", "chart");
assetLink.put("queryHint", "chart");
assetLink.put("linkType", "dashboard");
assetLink.put("queryHint", "dashboard");
});
});
}
Expand All @@ -82,7 +85,7 @@ private List<Map<String, Object>> castToListOfMaps(Object obj) {
return ((List<?>) obj).stream()
.filter(item -> item instanceof Map<?, ?>)
.map(item -> (Map<String, Object>) item)
.toList();
.collect(Collectors.toCollection(ArrayList::new));
} else {
throw new IllegalArgumentException("Expected a List of Maps but got: " + obj);
}
Expand Down
4 changes: 2 additions & 2 deletions ui/src/app/assets/dialog/base-asset-links.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ export abstract class BaseAssetLinksDirective {
a.name.localeCompare(b.name),
);
this.charts = charts.sort((a, b) =>
a.baseAppearanceConfig.name.localeCompare(
b.baseAppearanceConfig.name,
a.baseAppearanceConfig.widgetTitle.localeCompare(
b.baseAppearanceConfig.widgetTitle,
),
);
this.dashboards = dashboards.sort((a, b) =>
Expand Down

0 comments on commit 93b9de8

Please sign in to comment.