diff --git a/CHANGELOG.md b/CHANGELOG.md index 10f04fa..a3d0e06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,15 +8,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Changed -- **Shared parameter definitions — resolution groundwork.** A Snip's - `{token}` now resolves its parameter definition by name with precedence: - the Snip's own parameter overrides a CLI-scoped one, which overrides a - global one. A Snip can omit a parameter to inherit the shared definition - (e.g. an `env` Choice defined once on a CLI). Store schema is now v2 - (additive: `Cli.Parameters` + `SnipStoreDocument.GlobalParameters`); an - older build refuses a v2 store rather than dropping shared definitions. - The UI to manage shared parameters lands next; existing snips are - unaffected. - **JSON stores moved to System.Text.Json source generation.** `JsonSnipStore` and `JsonSettingsStore` now serialise via a generated `JsonSerializerContext` instead of the reflection-based serializer, removing the IL2026 trim warnings. @@ -26,6 +17,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 IL2104 on the WinAppSDK/WinRT/Jdenticon assemblies, which aren't trim-safe. ### Added +- **Shared parameter definitions.** Define a parameter once and reuse it + across snips, at two scopes: **CLI-scoped** (in the CLI editor — inherited by + every snip under that CLI) and **global** (a new "Shared parameters" entry in + the left pane — available to every snip across all CLIs). A snip's `{token}` + resolves its definition by name with precedence **snip-local → CLI → global**; + omit a parameter to inherit the shared one, or define it locally to override. + Existing snips are unaffected. (Store schema is now v2; an older build refuses + a v2 store rather than dropping shared definitions.) - **Change the storage location.** A "Change…" button on Settings → Storage location lets you pick a new folder for your snips. If the folder already contains a Snipdeck store it's adopted (your current snips are left where diff --git a/src/Snipdeck.App/Views/CliEditorDialog.xaml b/src/Snipdeck.App/Views/CliEditorDialog.xaml index 184222e..051280b 100644 --- a/src/Snipdeck.App/Views/CliEditorDialog.xaml +++ b/src/Snipdeck.App/Views/CliEditorDialog.xaml @@ -3,6 +3,7 @@ x:Class="Snipdeck.App.Views.CliEditorDialog" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:vm="using:Snipdeck.Core.ViewModels" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" @@ -11,30 +12,96 @@ CloseButtonText="Cancel" DefaultButton="Primary"> - - + + + + + + + + + + + + + + + + + Text + Choice + + + + + + + + - + diff --git a/src/Snipdeck.App/Views/CliEditorDialog.xaml.cs b/src/Snipdeck.App/Views/CliEditorDialog.xaml.cs index e3da04d..278d57f 100644 --- a/src/Snipdeck.App/Views/CliEditorDialog.xaml.cs +++ b/src/Snipdeck.App/Views/CliEditorDialog.xaml.cs @@ -34,6 +34,19 @@ private void UpdatePrimaryButtonEnabled() IsPrimaryButtonEnabled = ViewModel.CanSave; } + private void OnAddParameterClicked(object sender, RoutedEventArgs e) + { + ViewModel.AddParameter(); + } + + private void OnRemoveParameterClicked(object sender, RoutedEventArgs e) + { + if (sender is FrameworkElement element && element.Tag is ParameterEditorRowViewModel row) + { + ViewModel.RemoveParameter(row); + } + } + private async void OnPickIconClicked(object sender, RoutedEventArgs e) { var picked = await _filePicker.PickImageAsync(); diff --git a/src/Snipdeck.App/Views/ShellContentTemplateSelector.cs b/src/Snipdeck.App/Views/ShellContentTemplateSelector.cs index 5c37434..ec2a33c 100644 --- a/src/Snipdeck.App/Views/ShellContentTemplateSelector.cs +++ b/src/Snipdeck.App/Views/ShellContentTemplateSelector.cs @@ -19,6 +19,8 @@ public sealed partial class ShellContentTemplateSelector : DataTemplateSelector public DataTemplate? TrashTemplate { get; set; } + public DataTemplate? GlobalParametersTemplate { get; set; } + protected override DataTemplate? SelectTemplateCore(object item) { return item switch @@ -27,6 +29,7 @@ public sealed partial class ShellContentTemplateSelector : DataTemplateSelector CliViewModel => CliTemplate, SettingsViewModel => SettingsTemplate, TrashViewModel => TrashTemplate, + GlobalParametersViewModel => GlobalParametersTemplate, _ => null, }; } diff --git a/src/Snipdeck.App/Views/ShellPage.xaml b/src/Snipdeck.App/Views/ShellPage.xaml index e4f81df..9400993 100644 --- a/src/Snipdeck.App/Views/ShellPage.xaml +++ b/src/Snipdeck.App/Views/ShellPage.xaml @@ -17,6 +17,7 @@ + @@ -316,11 +317,97 @@ + + + + + + + + + + + + + + + + + Text + Choice + + + + + + + + + + + + + TrashTemplate="{StaticResource TrashContentTemplate}" + GlobalParametersTemplate="{StaticResource GlobalParametersContentTemplate}" /> +