asset details (WIP)
This commit is contained in:
@@ -104,6 +104,7 @@ public enum I18n {
|
||||
ASSETS_SECTION_ACTIONS("assets.section.actions"),
|
||||
ASSETS_ACTIONS_EMPTY("assets.actions.empty"),
|
||||
ASSETS_ACTION_REGISTER("assets.action.register"),
|
||||
ASSETS_ACTION_ANALYSE("assets.action.analyse"),
|
||||
ASSETS_ACTION_DELETE("assets.action.delete"),
|
||||
ASSETS_ACTION_INCLUDE_IN_BUILD("assets.action.includeInBuild"),
|
||||
ASSETS_ACTION_EXCLUDE_FROM_BUILD("assets.action.excludeFromBuild"),
|
||||
@@ -162,6 +163,11 @@ public enum I18n {
|
||||
ASSETS_LOGS_TITLE("assets.logs.title"),
|
||||
ASSETS_INPUTS_EMPTY("assets.inputs.empty"),
|
||||
ASSETS_DIAGNOSTICS_EMPTY("assets.diagnostics.empty"),
|
||||
ASSETS_DIAGNOSTICS_DIALOG_TITLE("assets.diagnostics.dialog.title"),
|
||||
ASSETS_DIAGNOSTICS_DIALOG_SUMMARY("assets.diagnostics.dialog.summary"),
|
||||
ASSETS_DIAGNOSTICS_LABEL_CATEGORY("assets.diagnostics.label.category"),
|
||||
ASSETS_DIAGNOSTICS_LABEL_EVIDENCE("assets.diagnostics.label.evidence"),
|
||||
ASSETS_DIAGNOSTICS_LABEL_BLOCKING("assets.diagnostics.label.blocking"),
|
||||
ASSETS_PREVIEW_EMPTY("assets.preview.empty"),
|
||||
ASSETS_PREVIEW_ZOOM("assets.preview.zoom"),
|
||||
ASSETS_PREVIEW_TEXT_ERROR("assets.preview.textError"),
|
||||
|
||||
+31
-3
@@ -10,6 +10,7 @@ import javafx.scene.layout.Priority;
|
||||
import javafx.scene.layout.VBox;
|
||||
import p.packer.dtos.PackerAssetActionAvailabilityDTO;
|
||||
import p.packer.dtos.PackerAssetDetailsDTO;
|
||||
import p.packer.dtos.PackerDiagnosticDTO;
|
||||
import p.packer.messages.*;
|
||||
import p.studio.Container;
|
||||
import p.studio.controls.forms.StudioFormEditScopeChangedEvent;
|
||||
@@ -17,6 +18,7 @@ import p.studio.controls.forms.StudioSection;
|
||||
import p.studio.events.StudioWorkspaceEventBus;
|
||||
import p.studio.projects.ProjectReference;
|
||||
import p.studio.utilities.i18n.I18n;
|
||||
import p.studio.workspaces.assets.dialogs.AssetDiagnosticsDialog;
|
||||
import p.studio.workspaces.assets.details.bank.AssetDetailsBankCompositionControl;
|
||||
import p.studio.workspaces.assets.details.contract.AssetDetailsContractControl;
|
||||
import p.studio.workspaces.assets.details.summary.AssetDetailsSummaryControl;
|
||||
@@ -162,7 +164,10 @@ public final class AssetDetailsControl extends VBox implements StudioEventAware
|
||||
final var actionsResponse = workspaceService.getAssetActions(new GetAssetActionsRequest(
|
||||
projectReference.toPackerProjectContext(),
|
||||
assetReference));
|
||||
final AssetWorkspaceAssetDetails details = mapDetails(response.details(), actionsResponse.actions());
|
||||
final AssetWorkspaceAssetDetails details = mapDetails(
|
||||
response.details(),
|
||||
response.diagnostics(),
|
||||
actionsResponse.actions());
|
||||
Platform.runLater(() -> applyLoadedDetails(generation, assetReference, details));
|
||||
} catch (RuntimeException exception) {
|
||||
Platform.runLater(() -> applyLoadFailure(generation, assetReference, exception));
|
||||
@@ -305,7 +310,7 @@ public final class AssetDetailsControl extends VBox implements StudioEventAware
|
||||
final var visibleActions = viewState.selectedAssetDetails().actions().stream()
|
||||
.filter(AssetWorkspaceAssetAction::visible)
|
||||
.toList();
|
||||
if (visibleActions.isEmpty()) {
|
||||
if (visibleActions.isEmpty() && viewState.selectedAssetDetails().diagnostics().isEmpty()) {
|
||||
nodes.add(AssetDetailsUiSupport.createSectionMessage(Container.i18n().text(I18n.ASSETS_ACTIONS_EMPTY)));
|
||||
return nodes;
|
||||
}
|
||||
@@ -315,6 +320,10 @@ public final class AssetDetailsControl extends VBox implements StudioEventAware
|
||||
button.setOnAction(ignored -> executeAction(action));
|
||||
nodes.add(button);
|
||||
}
|
||||
final Button analyseButton = AssetDetailsUiSupport.createActionButton(Container.i18n().text(I18n.ASSETS_ACTION_ANALYSE));
|
||||
analyseButton.setDisable(viewState.selectedAssetDetails().diagnostics().isEmpty());
|
||||
analyseButton.setOnAction(ignored -> openDiagnosticsDialog());
|
||||
nodes.add(analyseButton);
|
||||
return nodes;
|
||||
}
|
||||
|
||||
@@ -365,6 +374,17 @@ public final class AssetDetailsControl extends VBox implements StudioEventAware
|
||||
Container.backgroundTasks().submit(() -> deleteSelectedAsset(assetReference));
|
||||
}
|
||||
|
||||
private void openDiagnosticsDialog() {
|
||||
if (viewState.selectedAssetDetails() == null || getScene() == null) {
|
||||
return;
|
||||
}
|
||||
AssetDiagnosticsDialog.showAndWait(
|
||||
getScene().getWindow(),
|
||||
projectReference,
|
||||
viewState.selectedAssetDetails().summary().assetName(),
|
||||
viewState.selectedAssetDetails().diagnostics());
|
||||
}
|
||||
|
||||
private void registerSelectedAsset(AssetReference assetReference) {
|
||||
try {
|
||||
final RegisterAssetResult result = Container.packer().workspaceService().registerAsset(new RegisterAssetRequest(
|
||||
@@ -428,7 +448,14 @@ public final class AssetDetailsControl extends VBox implements StudioEventAware
|
||||
|
||||
private AssetWorkspaceAssetDetails mapDetails(
|
||||
PackerAssetDetailsDTO details,
|
||||
java.util.List<PackerDiagnosticDTO> diagnostics,
|
||||
java.util.List<PackerAssetActionAvailabilityDTO> actions) {
|
||||
final java.util.List<PackerDiagnosticDTO> mergedDiagnostics = new java.util.ArrayList<>(details.diagnostics());
|
||||
for (PackerDiagnosticDTO diagnostic : diagnostics) {
|
||||
if (!mergedDiagnostics.contains(diagnostic)) {
|
||||
mergedDiagnostics.add(diagnostic);
|
||||
}
|
||||
}
|
||||
return new AssetWorkspaceAssetDetails(
|
||||
AssetListPackerMappings.mapSummary(details.summary()),
|
||||
actions.stream()
|
||||
@@ -444,7 +471,8 @@ public final class AssetDetailsControl extends VBox implements StudioEventAware
|
||||
details.codecConfigurationFieldsByCodec(),
|
||||
details.metadataFields(),
|
||||
mapBankComposition(details.bankComposition()),
|
||||
Map.copyOf(details.inputsByRole()));
|
||||
Map.copyOf(details.inputsByRole()),
|
||||
mergedDiagnostics);
|
||||
}
|
||||
|
||||
private AssetWorkspaceBankCompositionDetails mapBankComposition(p.packer.dtos.PackerBankCompositionDetailsDTO details) {
|
||||
|
||||
+138
@@ -0,0 +1,138 @@
|
||||
package p.studio.workspaces.assets.dialogs;
|
||||
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.ScrollPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.Priority;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.stage.Modality;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.Window;
|
||||
import p.packer.dtos.PackerDiagnosticDTO;
|
||||
import p.packer.messages.diagnostics.PackerDiagnosticSeverity;
|
||||
import p.studio.Container;
|
||||
import p.studio.projects.ProjectReference;
|
||||
import p.studio.utilities.i18n.I18n;
|
||||
import p.studio.workspaces.assets.details.AssetDetailsUiSupport;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public final class AssetDiagnosticsDialog {
|
||||
private final Stage stage;
|
||||
private final ProjectReference projectReference;
|
||||
private final String assetName;
|
||||
private final List<PackerDiagnosticDTO> diagnostics;
|
||||
|
||||
private AssetDiagnosticsDialog(
|
||||
Window owner,
|
||||
ProjectReference projectReference,
|
||||
String assetName,
|
||||
List<PackerDiagnosticDTO> diagnostics) {
|
||||
this.projectReference = Objects.requireNonNull(projectReference, "projectReference");
|
||||
this.assetName = Objects.requireNonNull(assetName, "assetName");
|
||||
this.diagnostics = List.copyOf(Objects.requireNonNull(diagnostics, "diagnostics"));
|
||||
this.stage = new Stage();
|
||||
stage.initOwner(owner);
|
||||
stage.initModality(Modality.WINDOW_MODAL);
|
||||
stage.setTitle(Container.i18n().text(I18n.ASSETS_DIAGNOSTICS_DIALOG_TITLE));
|
||||
stage.setScene(new Scene(buildRoot(), 720, 560));
|
||||
stage.getScene().getStylesheets().add(Container.theme().getDefaultTheme());
|
||||
}
|
||||
|
||||
public static void showAndWait(
|
||||
Window owner,
|
||||
ProjectReference projectReference,
|
||||
String assetName,
|
||||
List<PackerDiagnosticDTO> diagnostics) {
|
||||
new AssetDiagnosticsDialog(owner, projectReference, assetName, diagnostics).stage.showAndWait();
|
||||
}
|
||||
|
||||
private VBox buildRoot() {
|
||||
final Label title = new Label(Container.i18n().text(I18n.ASSETS_DIAGNOSTICS_DIALOG_TITLE));
|
||||
title.getStyleClass().add("studio-launcher-section-title");
|
||||
|
||||
final Label subtitle = new Label(Container.i18n().format(
|
||||
I18n.ASSETS_DIAGNOSTICS_DIALOG_SUMMARY,
|
||||
diagnostics.size(),
|
||||
assetName));
|
||||
subtitle.getStyleClass().add("studio-launcher-subtitle");
|
||||
subtitle.setWrapText(true);
|
||||
|
||||
final VBox diagnosticsContent = new VBox(10);
|
||||
diagnosticsContent.getStyleClass().add("assets-diagnostics-dialog-content");
|
||||
if (diagnostics.isEmpty()) {
|
||||
diagnosticsContent.getChildren().add(AssetDetailsUiSupport.createSectionMessage(
|
||||
Container.i18n().text(I18n.ASSETS_DIAGNOSTICS_EMPTY)));
|
||||
} else {
|
||||
diagnostics.forEach(diagnostic -> diagnosticsContent.getChildren().add(createDiagnosticCard(diagnostic)));
|
||||
}
|
||||
|
||||
final ScrollPane scrollPane = new ScrollPane(diagnosticsContent);
|
||||
scrollPane.setFitToWidth(true);
|
||||
scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
|
||||
scrollPane.getStyleClass().add("assets-diagnostics-dialog-scroll");
|
||||
|
||||
final Button closeButton = new Button();
|
||||
closeButton.textProperty().bind(Container.i18n().bind(I18n.WIZARD_CANCEL));
|
||||
closeButton.getStyleClass().addAll("studio-button", "studio-button-cancel");
|
||||
closeButton.setOnAction(ignored -> stage.close());
|
||||
|
||||
final HBox actions = new HBox(closeButton);
|
||||
actions.setAlignment(Pos.CENTER_RIGHT);
|
||||
|
||||
final VBox root = new VBox(16, title, subtitle, scrollPane, actions);
|
||||
root.setPadding(new Insets(24));
|
||||
VBox.setVgrow(scrollPane, Priority.ALWAYS);
|
||||
return root;
|
||||
}
|
||||
|
||||
private VBox createDiagnosticCard(PackerDiagnosticDTO diagnostic) {
|
||||
final Label severity = new Label(severityLabel(diagnostic));
|
||||
severity.getStyleClass().add("assets-details-diagnostic-severity");
|
||||
|
||||
final Label message = new Label(diagnostic.message());
|
||||
message.getStyleClass().add("assets-details-diagnostic-message");
|
||||
message.setWrapText(true);
|
||||
|
||||
final VBox card = new VBox(8, severity, message);
|
||||
card.getStyleClass().addAll("assets-details-diagnostic-card", severityToneClass(diagnostic.severity()));
|
||||
|
||||
card.getChildren().add(AssetDetailsUiSupport.createKeyValueRow(
|
||||
Container.i18n().text(I18n.ASSETS_DIAGNOSTICS_LABEL_CATEGORY),
|
||||
diagnostic.category().name()));
|
||||
card.getChildren().add(AssetDetailsUiSupport.createKeyValueRow(
|
||||
Container.i18n().text(I18n.ASSETS_DIAGNOSTICS_LABEL_BLOCKING),
|
||||
AssetDetailsUiSupport.booleanLabel(diagnostic.blocking())));
|
||||
card.getChildren().add(AssetDetailsUiSupport.createKeyValueRow(
|
||||
Container.i18n().text(I18n.ASSETS_DIAGNOSTICS_LABEL_EVIDENCE),
|
||||
evidenceLabel(diagnostic.evidencePath())));
|
||||
return card;
|
||||
}
|
||||
|
||||
private String severityLabel(PackerDiagnosticDTO diagnostic) {
|
||||
return diagnostic.blocking()
|
||||
? diagnostic.severity().name() + " / BLOCKING"
|
||||
: diagnostic.severity().name();
|
||||
}
|
||||
|
||||
private String severityToneClass(PackerDiagnosticSeverity severity) {
|
||||
return switch (severity) {
|
||||
case ERROR -> "assets-details-diagnostic-blocker";
|
||||
case WARNING -> "assets-details-diagnostic-warning";
|
||||
case INFO -> "assets-details-diagnostic-hint";
|
||||
};
|
||||
}
|
||||
|
||||
private String evidenceLabel(Path evidencePath) {
|
||||
if (evidencePath == null) {
|
||||
return "—";
|
||||
}
|
||||
return AssetDetailsUiSupport.projectRelativePath(projectReference, evidencePath);
|
||||
}
|
||||
}
|
||||
+4
-1
@@ -1,6 +1,7 @@
|
||||
package p.studio.workspaces.assets.messages;
|
||||
|
||||
import p.packer.dtos.PackerCodecConfigurationFieldDTO;
|
||||
import p.packer.dtos.PackerDiagnosticDTO;
|
||||
import p.packer.messages.assets.OutputCodecCatalog;
|
||||
import p.packer.messages.assets.OutputFormatCatalog;
|
||||
|
||||
@@ -18,7 +19,8 @@ public record AssetWorkspaceAssetDetails(
|
||||
Map<OutputCodecCatalog, List<PackerCodecConfigurationFieldDTO>> codecConfigurationFieldsByCodec,
|
||||
List<PackerCodecConfigurationFieldDTO> metadataFields,
|
||||
AssetWorkspaceBankCompositionDetails bankComposition,
|
||||
Map<String, List<Path>> inputsByRole) {
|
||||
Map<String, List<Path>> inputsByRole,
|
||||
List<PackerDiagnosticDTO> diagnostics) {
|
||||
|
||||
public AssetWorkspaceAssetDetails {
|
||||
Objects.requireNonNull(summary, "summary");
|
||||
@@ -30,5 +32,6 @@ public record AssetWorkspaceAssetDetails(
|
||||
metadataFields = List.copyOf(Objects.requireNonNull(metadataFields, "metadataFields"));
|
||||
bankComposition = Objects.requireNonNull(bankComposition, "bankComposition");
|
||||
inputsByRole = Map.copyOf(Objects.requireNonNull(inputsByRole, "inputsByRole"));
|
||||
diagnostics = List.copyOf(Objects.requireNonNull(diagnostics, "diagnostics"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,6 +94,7 @@ assets.section.diagnostics=Diagnostics
|
||||
assets.section.actions=Actions
|
||||
assets.actions.empty=No actions available for this asset.
|
||||
assets.action.register=Register
|
||||
assets.action.analyse=Analyse
|
||||
assets.action.delete=Delete
|
||||
assets.deleteDialog.title=Delete Asset
|
||||
assets.deleteDialog.description=Type the asset name below to confirm deletion of {0}.
|
||||
@@ -153,6 +154,11 @@ assets.progress.loadingDetails=Loading selected asset details...
|
||||
assets.logs.title=Logs
|
||||
assets.inputs.empty=No previewable inputs are currently declared for this asset.
|
||||
assets.diagnostics.empty=No diagnostics are currently attached to this asset.
|
||||
assets.diagnostics.dialog.title=Asset Diagnostics
|
||||
assets.diagnostics.dialog.summary={0} diagnostics for {1}
|
||||
assets.diagnostics.label.category=Category
|
||||
assets.diagnostics.label.evidence=Evidence
|
||||
assets.diagnostics.label.blocking=Blocking
|
||||
assets.preview.empty=Select an input to preview it here.
|
||||
assets.preview.zoom=Zoom
|
||||
assets.preview.textError=Unable to read this text-like input for preview.
|
||||
|
||||
@@ -572,6 +572,19 @@
|
||||
-fx-spacing: 10;
|
||||
}
|
||||
|
||||
.assets-diagnostics-dialog-scroll {
|
||||
-fx-background-color: transparent;
|
||||
-fx-fit-to-width: true;
|
||||
}
|
||||
|
||||
.assets-diagnostics-dialog-scroll > .viewport {
|
||||
-fx-background-color: transparent;
|
||||
}
|
||||
|
||||
.assets-diagnostics-dialog-content {
|
||||
-fx-spacing: 10;
|
||||
}
|
||||
|
||||
.assets-details-action-button {
|
||||
-fx-max-width: Infinity;
|
||||
-fx-padding: 6 10 6 10;
|
||||
|
||||
Reference in New Issue
Block a user