Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/Aspire.Hosting.Azure.CosmosDB/AzureCosmosDBExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -506,9 +506,7 @@ public static IResourceBuilder<AzureCosmosDBEmulatorResource> WithDataExplorer(t
.WithUrlForEndpoint(dataExplorerEndpointName, c =>
{
c.DisplayText = "Manage";
#pragma warning disable CS0618 // DisplayOrder is obsolete but must still be set to prioritize this URL.
c.DisplayOrder = 1;
#pragma warning restore CS0618
});

if (builder.ApplicationBuilder.ExecutionContext.IsRunMode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,7 @@ public static IResourceBuilder<DurableTaskSchedulerResource> RunAsEmulator(this
.WithUrlForEndpoint("dashboard", c =>
{
c.DisplayText = "Manage";
#pragma warning disable CS0618 // DisplayOrder is obsolete but must still be set to prioritize this URL.
c.DisplayOrder = 1;
#pragma warning restore CS0618
})
.WithAnnotation(new ContainerImageAnnotation
{
Expand Down
2 changes: 0 additions & 2 deletions src/Aspire.Hosting.Kafka/KafkaBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,11 @@ public static IResourceBuilder<KafkaServerResource> WithKafkaUI(this IResourceBu
foreach (var kafkaResource in @event.Model.Resources.OfType<KafkaServerResource>())
{
kafkaUiBuilder.WithRelationship(kafkaResource, KnownRelationshipTypes.Manages);
#pragma warning disable CS0618 // DisplayOrder is obsolete but must still be set to prioritize this URL.
builder.ApplicationBuilder.CreateResourceBuilder(kafkaResource).WithUrlForEndpoint(kafkaUi.PrimaryEndpoint, url =>
{
url.DisplayText = "Manage";
url.DisplayOrder = 1;
});
#pragma warning restore CS0618
}

return Task.CompletedTask;
Expand Down
2 changes: 0 additions & 2 deletions src/Aspire.Hosting.Milvus/MilvusBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,11 @@ public static IResourceBuilder<T> WithAttu<T>(this IResourceBuilder<T> builder,
.ExcludeFromManifest();

resourceBuilder.WithHidden();
#pragma warning disable CS0618 // DisplayOrder is obsolete but must still be set to prioritize this URL.
builder.WithUrlForEndpoint(attuContainer.PrimaryEndpoint, url =>
{
url.DisplayText = "Manage";
url.DisplayOrder = 1;
});
#pragma warning restore CS0618

configureContainer?.Invoke(resourceBuilder);

Expand Down
2 changes: 0 additions & 2 deletions src/Aspire.Hosting.MongoDB/MongoDBBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -330,13 +330,11 @@ public static IResourceBuilder<T> WithMongoExpress<T>(this IResourceBuilder<T> b
.ExcludeFromManifest();

resourceBuilder.WithHidden();
#pragma warning disable CS0618 // DisplayOrder is obsolete but must still be set to prioritize this URL.
builder.WithUrlForEndpoint(mongoExpressContainer.PrimaryEndpoint, url =>
{
url.DisplayText = "Manage";
url.DisplayOrder = 1;
});
#pragma warning restore CS0618

configureContainer?.Invoke(resourceBuilder);

Expand Down
2 changes: 0 additions & 2 deletions src/Aspire.Hosting.MySql/MySqlBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -317,13 +317,11 @@ public static IResourceBuilder<T> WithPhpMyAdmin<T>(this IResourceBuilder<T> bui
foreach (var mySqlResource in @event.Model.Resources.OfType<MySqlServerResource>())
{
phpMyAdminContainerBuilder.WithRelationship(mySqlResource, KnownRelationshipTypes.Manages);
#pragma warning disable CS0618 // DisplayOrder is obsolete but must still be set to prioritize this URL.
builder.ApplicationBuilder.CreateResourceBuilder(mySqlResource).WithUrlForEndpoint(phpMyAdminContainer.PrimaryEndpoint, url =>
{
url.DisplayText = "Manage";
url.DisplayOrder = 1;
});
#pragma warning restore CS0618
}

return Task.CompletedTask;
Expand Down
2 changes: 0 additions & 2 deletions src/Aspire.Hosting.PostgreSQL/PostgresBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -476,13 +476,11 @@ private static void AddManagementLinks<T>(IResourceBuilder<T> resourceBuilder, E
{
resourceBuilder.WithRelationship(postgresResource, KnownRelationshipTypes.Manages);

#pragma warning disable CS0618 // DisplayOrder is obsolete but must still be set to prioritize this URL.
resourceBuilder.ApplicationBuilder.CreateResourceBuilder(postgresResource).WithUrlForEndpoint(endpoint, url =>
{
url.DisplayText = displayText;
url.DisplayOrder = 1;
});
#pragma warning restore CS0618
}

return Task.CompletedTask;
Expand Down
2 changes: 0 additions & 2 deletions src/Aspire.Hosting.Qdrant/QdrantBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,7 @@ public static IResourceBuilder<QdrantServerResource> AddQdrant(this IDistributed
c.DisplayLocation = UrlDisplayLocation.DetailsOnly;
})
.WithUrlForEndpoint(QdrantServerResource.HttpEndpointName, c => c.DisplayText = "Qdrant (HTTP)")
#pragma warning disable CS0618 // DisplayOrder is obsolete but must still be set to prioritize this URL.
.WithUrlForEndpoint(QdrantServerResource.HttpEndpointName, e => new ResourceUrlAnnotation() { Url = "/dashboard", DisplayText = "Manage", DisplayOrder = 1 });
#pragma warning restore CS0618
}

/// <summary>
Expand Down
2 changes: 0 additions & 2 deletions src/Aspire.Hosting.RabbitMQ/RabbitMQBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,7 @@ public static IResourceBuilder<RabbitMQServerResource> WithManagementPlugin(this
.WithUrlForEndpoint(RabbitMQServerResource.ManagementEndpointName, c =>
{
c.DisplayText = "Manage";
#pragma warning disable CS0618 // DisplayOrder is obsolete but must still be set to prioritize this URL.
c.DisplayOrder = 1;
#pragma warning restore CS0618
});
return builder;
}
Expand Down
2 changes: 0 additions & 2 deletions src/Aspire.Hosting.Redis/RedisBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -470,13 +470,11 @@ private static void AddManagementLinks<T>(IResourceBuilder<T> resourceBuilder, E
{
resourceBuilder.WithRelationship(redisResource, KnownRelationshipTypes.Manages);

#pragma warning disable CS0618 // DisplayOrder is obsolete but must still be set to prioritize this URL.
resourceBuilder.ApplicationBuilder.CreateResourceBuilder(redisResource).WithUrlForEndpoint(endpoint, url =>
{
url.DisplayText = displayText;
url.DisplayOrder = 1;
});
#pragma warning restore CS0618
}

return Task.CompletedTask;
Expand Down
10 changes: 2 additions & 8 deletions src/Aspire.Hosting/ApplicationModel/ResourceUrlAnnotation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,9 @@ public sealed class ResourceUrlAnnotation : IResourceAnnotation
public EndpointReference? Endpoint { get; init; }

/// <summary>
/// The display order the URL. Higher values mean sort higher in the list.
/// Gets or sets the display order of the URL. Higher values mean sort higher in the list.
/// </summary>
/// <remarks>
/// This member was incorrectly created as a field. It will be re-added as a property in a future Aspire version.
/// </remarks>
[Obsolete("DisplayOrder was incorrectly created as a field. It will be re-added as a property in a future Aspire version.")]
public int? DisplayOrder;
public int? DisplayOrder { get; set; }
Comment thread
JamesNK marked this conversation as resolved.
Comment thread
JamesNK marked this conversation as resolved.

/// <summary>
/// Locations where this URL should be shown on the dashboard. Defaults to <see cref="UrlDisplayLocation.SummaryAndDetails"/>.
Expand All @@ -45,7 +41,6 @@ public sealed class ResourceUrlAnnotation : IResourceAnnotation

internal ResourceUrlAnnotation WithEndpoint(EndpointReference endpoint)
{
#pragma warning disable CS0618 // DisplayOrder is obsolete but must still be copied for compatibility.
return new()
{
Url = Url,
Expand All @@ -54,7 +49,6 @@ internal ResourceUrlAnnotation WithEndpoint(EndpointReference endpoint)
DisplayOrder = DisplayOrder,
DisplayLocation = DisplayLocation
};
#pragma warning restore CS0618
}
}

Expand Down
2 changes: 0 additions & 2 deletions src/Aspire.Hosting/Dashboard/DashboardEventHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,7 @@ private void ConfigureAspireDashboardResource(IResource dashboardResource)
// Other endpoints are for the dashboard UI. There are typically dashboard UI endpoints for http and https.
// Order these before non-browser usable endpoints.
url.DisplayText = $"Dashboard ({endpoint.EndpointName})";
#pragma warning disable CS0618 // DisplayOrder is obsolete but must still be set for compatibility.
url.DisplayOrder = 1;
#pragma warning restore CS0618

// Append the browser token to the URL as a query string parameter if token is configured
if (!string.IsNullOrEmpty(browserToken))
Expand Down
6 changes: 0 additions & 6 deletions src/Aspire.Hosting/Dcp/ResourceSnapshotBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,7 @@ private ImmutableArray<UrlSnapshot> GetUrls(CustomResource resource, string? res
endpointUrl.IsInternal)
{
IsInactive = isInactive,
#pragma warning disable CS0618 // DisplayOrder is obsolete but must still be flowed for compatibility.
DisplayProperties = new(endpointUrl.DisplayText ?? "", endpointUrl.DisplayOrder ?? 0)
#pragma warning restore CS0618
});
processedEndpointUrls.Add(endpointUrl);
}
Expand All @@ -355,9 +353,7 @@ private ImmutableArray<UrlSnapshot> GetUrls(CustomResource resource, string? res
new(Name: endpointName, Url: endpointUrl.Url, IsInternal: endpointUrl.IsInternal)
{
IsInactive = !isActive,
#pragma warning disable CS0618 // DisplayOrder is obsolete but must still be flowed for compatibility.
DisplayProperties = new(endpointUrl.DisplayText ?? "", endpointUrl.DisplayOrder ?? 0)
#pragma warning restore CS0618
});
}

Expand All @@ -368,9 +364,7 @@ private ImmutableArray<UrlSnapshot> GetUrls(CustomResource resource, string? res
new(Name: null, Url: url.Url, IsInternal: url.IsInternal)
{
IsInactive = !resourceRunning,
#pragma warning disable CS0618 // DisplayOrder is obsolete but must still be flowed for compatibility.
DisplayProperties = new(url.DisplayText ?? "", url.DisplayOrder ?? 0)
#pragma warning restore CS0618
});
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/Aspire.Hosting/Orchestrator/ApplicationOrchestrator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,7 @@ private static IEnumerable<UrlSnapshot> GetResourceUrls(IResource resource)
// Endpoint URLs are inactive (hidden in the dashboard) when published here. It is assumed they will get activated later when the endpoint is considered active
// by whatever allocated the endpoint in the first place, e.g. for resources controlled by DCP, when DCP detects the endpoint is listening.
IsInactive = url.Endpoint is not null,
#pragma warning disable CS0618 // DisplayOrder is obsolete but must still be flowed for compatibility.
DisplayProperties = new(url.DisplayText ?? "", url.DisplayOrder ?? 0)
#pragma warning restore CS0618
});
}
return urls;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1040,6 +1040,7 @@ type ResourceUrlAnnotation struct {
Url string `json:"Url,omitempty"`
DisplayText *string `json:"DisplayText,omitempty"`
Endpoint *EndpointReference `json:"Endpoint,omitempty"`
DisplayOrder *float64 `json:"DisplayOrder,omitempty"`
DisplayLocation UrlDisplayLocation `json:"DisplayLocation,omitempty"`
}

Expand All @@ -1049,6 +1050,7 @@ func (d *ResourceUrlAnnotation) ToMap() map[string]any {
m["Url"] = serializeValue(d.Url)
if d.DisplayText != nil { m["DisplayText"] = serializeValue(d.DisplayText) }
if d.Endpoint != nil { m["Endpoint"] = serializeValue(d.Endpoint) }
if d.DisplayOrder != nil { m["DisplayOrder"] = serializeValue(d.DisplayOrder) }
m["DisplayLocation"] = serializeValue(d.DisplayLocation)
return m
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22653,6 +22653,7 @@ public class ResourceUrlAnnotation implements JsonSerializable {
private String url;
private String displayText;
private EndpointReference endpoint;
private Number displayOrder;
private UrlDisplayLocation displayLocation;

public String getUrl() { return url; }
Expand All @@ -22661,6 +22662,8 @@ public class ResourceUrlAnnotation implements JsonSerializable {
public void setDisplayText(String value) { this.displayText = value; }
public EndpointReference getEndpoint() { return endpoint; }
public void setEndpoint(EndpointReference value) { this.endpoint = value; }
public Number getDisplayOrder() { return displayOrder; }
public void setDisplayOrder(Number value) { this.displayOrder = value; }
public UrlDisplayLocation getDisplayLocation() { return displayLocation; }
public void setDisplayLocation(UrlDisplayLocation value) { this.displayLocation = value; }

Expand All @@ -22673,6 +22676,8 @@ public static ResourceUrlAnnotation fromMap(Map<String, Object> map) {
value.setDisplayText(displayTextValue == null ? null : (String) displayTextValue);
var endpointValue = map.get("Endpoint");
value.setEndpoint((EndpointReference) endpointValue);
var displayOrderValue = map.get("DisplayOrder");
value.setDisplayOrder(displayOrderValue == null ? null : ((Number) displayOrderValue).doubleValue());
var displayLocationValue = map.get("DisplayLocation");
value.setDisplayLocation(UrlDisplayLocation.fromValue((String) displayLocationValue));
return value;
Expand All @@ -22683,6 +22688,7 @@ public Map<String, Object> toMap() {
map.put("Url", AspireClient.serializeValue(url));
map.put("DisplayText", AspireClient.serializeValue(displayText));
map.put("Endpoint", AspireClient.serializeValue(endpoint));
map.put("DisplayOrder", AspireClient.serializeValue(displayOrder));
map.put("DisplayLocation", AspireClient.serializeValue(displayLocation));
return map;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2052,6 +2052,7 @@ class ResourceUrlAnnotation(typing.TypedDict, total=False):
Url: str
DisplayText: str | None
Endpoint: EndpointReference
DisplayOrder: int | None
DisplayLocation: UrlDisplayLocation

class RunConfiguration(typing.TypedDict, total=False):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1830,6 +1830,8 @@ pub struct ResourceUrlAnnotation {
pub display_text: Option<String>,
#[serde(rename = "Endpoint", skip_serializing_if = "Option::is_none")]
pub endpoint: Option<Handle>,
#[serde(rename = "DisplayOrder", skip_serializing_if = "Option::is_none")]
pub display_order: Option<f64>,
#[serde(rename = "DisplayLocation")]
pub display_location: UrlDisplayLocation,
}
Expand All @@ -1842,6 +1844,9 @@ impl ResourceUrlAnnotation {
if let Some(ref v) = self.endpoint {
map.insert("Endpoint".to_string(), serde_json::to_value(v).unwrap_or(Value::Null));
}
if let Some(ref v) = self.display_order {
map.insert("DisplayOrder".to_string(), serde_json::to_value(v).unwrap_or(Value::Null));
}
map.insert("DisplayLocation".to_string(), serde_json::to_value(&self.display_location).unwrap_or(Value::Null));
map
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1313,6 +1313,8 @@ export interface ResourceUrlAnnotation {
displayText?: string | null;
/** The endpoint associated with this URL. Can be `null` if this URL is not associated with an endpoint. */
endpoint?: EndpointReference;
/** Gets or sets the display order of the URL. Higher values mean sort higher in the list. */
displayOrder?: number | null;
/** Locations where this URL should be shown on the dashboard. Defaults to `SummaryAndDetails`. */
displayLocation?: UrlDisplayLocation;
}
Expand Down
23 changes: 21 additions & 2 deletions tests/Aspire.Hosting.Tests/WithUrlsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,27 @@ namespace Aspire.Hosting.Tests;
[Trait("Partition", "5")]
public class WithUrlsTests(ITestOutputHelper testOutputHelper)
{
[Theory]
[InlineData(null)]
[InlineData(-1)]
[InlineData(0)]
[InlineData(1000)]
public void WithEndpointPreservesDisplayOrder(int? displayOrder)
{
var endpoint = new EndpointReference(new ContainerResource("container"), "http");
var annotation = new ResourceUrlAnnotation
{
Url = "https://example.com",
DisplayOrder = displayOrder
};

var updatedAnnotation = annotation.WithEndpoint(endpoint);

Assert.Equal(displayOrder, updatedAnnotation.DisplayOrder);
Assert.Same(endpoint, updatedAnnotation.Endpoint);
Assert.Null(annotation.Endpoint);
}

[Fact]
public void WithUrlsAddsAnnotationForAsyncCallback()
{
Expand Down Expand Up @@ -339,7 +360,6 @@ public async Task WithUrlForEndpointUpdatesUrlForEndpoint()
using var builder = TestDistributedApplicationBuilder.Create(testOutputHelper);

var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
#pragma warning disable CS0618 // This test intentionally verifies the obsolete DisplayOrder behavior.
var projectA = builder.AddProject<ProjectA>("projecta")
.WithHttpEndpoint(name: "test")
.WithUrlForEndpoint("test", u =>
Expand All @@ -364,7 +384,6 @@ public async Task WithUrlForEndpointUpdatesUrlForEndpoint()
&& u.DisplayText == "Link Text"
&& u.Endpoint?.EndpointName == "test"
&& u.DisplayOrder == 1000);
#pragma warning restore CS0618

await app.StopAsync().DefaultTimeout(TestConstants.LongTimeoutDuration);
}
Expand Down
Loading