Add new detect install script type, restrict script editor to specific types

redistributables
Pat Hartl 2023-10-24 18:05:13 -05:00
parent af265e9d34
commit e4cf2aabfe
4 changed files with 9 additions and 4 deletions

View File

@ -56,7 +56,7 @@
</FormItem>
<FormItem Label="Type">
<Select @bind-Value="context.Type" TItem="ScriptType" TItemValue="ScriptType" DataSource="Enum.GetValues<ScriptType>()">
<Select @bind-Value="context.Type" TItem="ScriptType" TItemValue="ScriptType" DataSource="Enum.GetValues<ScriptType>().Where(st => AllowedTypes == null || AllowedTypes.Contains(st))">
<LabelTemplate Context="Value">@Value.GetDisplayName()</LabelTemplate>
<ItemTemplate Context="Value">@Value.GetDisplayName()</ItemTemplate>
</Select>
@ -117,6 +117,7 @@
[Parameter] public Guid ArchiveId { get; set; }
[Parameter] public ICollection<Script> Scripts { get; set; }
[Parameter] public EventCallback<ICollection<Script>> ScriptsChanged { get; set; }
[Parameter] public IEnumerable<ScriptType> AllowedTypes { get; set; }
Script Script;

View File

@ -13,6 +13,8 @@ namespace LANCommander.Data.Enums
[Display(Name = "Save Upload")]
SaveUpload,
[Display(Name = "Save Download")]
SaveDownload
SaveDownload,
[Display(Name = "Detect Install")]
DetectInstall
}
}

View File

@ -2,6 +2,7 @@
@page "/Games/{id:guid}/{panel}"
@page "/Games/Add"
@using LANCommander.Components.FileManagerComponents;
@using LANCommander.Data.Enums;
@using LANCommander.Models;
@using LANCommander.Pages.Games.Components
@using System.IO.Compression;
@ -125,7 +126,7 @@
</div>
<div data-panel="Scripts">
<ScriptEditor @bind-Scripts="Game.Scripts" GameId="Game.Id" ArchiveId="@LatestArchiveId" />
<ScriptEditor @bind-Scripts="Game.Scripts" GameId="Game.Id" ArchiveId="@LatestArchiveId" AllowedTypes="new ScriptType[] { ScriptType.Install, ScriptType.Uninstall, ScriptType.NameChange, ScriptType.KeyChange }" />
</div>
<div data-panel="Archives">

View File

@ -1,6 +1,7 @@
@page "/Redistributables/{id:guid}"
@page "/Redistributables/{id:guid}/{panel}"
@page "/Redistributables/Add"
@using LANCommander.Data.Enums;
@inject RedistributableService RedistributableService
@inject IMessageService MessageService
@inject NavigationManager NavigationManager
@ -46,7 +47,7 @@
@if (Panel == "Scripts")
{
<ScriptEditor @bind-Scripts="Redistributable.Scripts" RedistributableId="Redistributable.Id" ArchiveId="@LatestArchiveId" />
<ScriptEditor @bind-Scripts="Redistributable.Scripts" RedistributableId="Redistributable.Id" ArchiveId="@LatestArchiveId" AllowedTypes="new ScriptType[] { ScriptType.Install, ScriptType.DetectInstall }" />
}
@if (Panel == "Archives")