Skip to content
Open
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
86 changes: 0 additions & 86 deletions src/TALXIS.CLI.Core/Contracts/Dataverse/ComponentTypeResolver.cs

This file was deleted.

48 changes: 48 additions & 0 deletions src/TALXIS.CLI.Core/Shared/BrowserLauncher.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using System.Diagnostics;
using System.Runtime.InteropServices;
using Microsoft.Extensions.Logging;
using TALXIS.CLI.Core.Abstractions;
using TALXIS.CLI.Core.DependencyInjection;

namespace TALXIS.CLI.Core;

/// <summary>
/// Cross-platform utility to open a URL in the default browser.
/// Headless-aware: skips browser launch in CI/non-interactive environments.
/// </summary>
public static class BrowserLauncher
{
/// <summary>
/// Opens <paramref name="url"/> in the default browser.
/// In headless/CI mode, logs a warning and returns without opening.
/// </summary>
public static void Open(Uri url, ILogger logger)
{
var detector = TxcServices.Get<IHeadlessDetector>();
if (detector.IsHeadless)
{
logger.LogWarning("Headless mode ({Reason}) — browser not opened.", detector.Reason);
return;
}

try
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
Process.Start(new ProcessStartInfo(url.AbsoluteUri) { UseShellExecute = true });
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
Process.Start("open", url.AbsoluteUri);
}
else
{
Process.Start("xdg-open", url.AbsoluteUri);
}
}
catch (Exception ex)
{
logger.LogWarning("Could not open browser: {Error}", ex.Message);
}
}
}
1 change: 1 addition & 0 deletions src/TALXIS.CLI.Core/TALXIS.CLI.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

<ItemGroup>
<PackageReference Include="DotMake.CommandLine" Version="2.6.7" />
<PackageReference Include="TALXIS.Platform.Metadata" Version="0.5.0-preview.1" />
Comment thread
TomProkop marked this conversation as resolved.
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.5" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.5" />
<PackageReference Include="Microsoft.Identity.Client" Version="4.83.3" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
namespace TALXIS.CLI.Features.Environment.Component.Browse;

/// <summary>
/// Shared constants for browse URL construction.
/// </summary>
public static class BrowseUrlConstants
{
/// <summary>Default Solution GUID — used when no solution context is specified for form/view/securityrole.</summary>
public const string DefaultSolutionId = "fd140aaf-4df4-11dd-bd17-0019b9312238";

/// <summary>
/// Extracts the hostname from an org URL for use in URL construction.
/// Accepts either a full URL or a bare hostname.
/// </summary>
public static string NormalizeOrgUrl(string orgUrl)
{
if (Uri.TryCreate(orgUrl, UriKind.Absolute, out var uri))
return uri.Host;
// Already a bare hostname
return orgUrl.TrimEnd('/');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
namespace TALXIS.CLI.Features.Environment.Component.Browse;

/// <summary>
/// URL builders for the Power Apps canvas app player (<c>apps.powerapps.com/play</c>).
/// Supports screen navigation, custom parameters, and hidden navbar.
/// </summary>
public static class CanvasAppUrls
{
private const string Base = "https://apps.powerapps.com/play";

/// <summary>
/// Open a canvas app in the Power Apps player.
/// </summary>
public static Uri Play(Guid environmentId, Guid appId, string? tenantId,
string? screenName = null, IDictionary<string, string>? customParams = null, bool hideNavbar = false)
{
var qs = new List<string>();
if (!string.IsNullOrWhiteSpace(tenantId))
qs.Add($"tenantId={Uri.EscapeDataString(tenantId)}");
if (!string.IsNullOrWhiteSpace(screenName))
qs.Add($"screenName={Uri.EscapeDataString(screenName)}");
if (hideNavbar)
qs.Add("hidenavbar=true");
if (customParams != null)
foreach (var (key, value) in customParams)
qs.Add($"{Uri.EscapeDataString(key)}={Uri.EscapeDataString(value)}");

var query = qs.Count > 0 ? "?" + string.Join("&", qs) : "";
return new Uri($"{Base}/e/{environmentId}/a/{appId}{query}");
}
}
Loading