Skip to content

Commit

Permalink
Add a variable (%{pubvar}) during publish
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxhy committed Mar 7, 2024
1 parent 2e07653 commit 21e5f29
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 2 deletions.
18 changes: 18 additions & 0 deletions KeyManager.Library.UI/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions KeyManager.Library.UI/Properties/Resources.fr.resx
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,12 @@
<data name="PublishKeyStore" xml:space="preserve">
<value>Publier vers un autre magasin de clés</value>
</data>
<data name="PublishVariable" xml:space="preserve">
<value>Variable</value>
</data>
<data name="PublishVariableHelper" xml:space="preserve">
<value>Une variable qui peut être utilisée lors de la publication (via %{pubvar}).</value>
</data>
<data name="QrCode" xml:space="preserve">
<value>Qr Code</value>
</data>
Expand Down
6 changes: 6 additions & 0 deletions KeyManager.Library.UI/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,12 @@
<data name="PublishKeyStore" xml:space="preserve">
<value>Publish to another Key Store</value>
</data>
<data name="PublishVariable" xml:space="preserve">
<value>Variable</value>
</data>
<data name="PublishVariableHelper" xml:space="preserve">
<value>A variable which can be used during publish (using %{pubvar}).</value>
</data>
<data name="QrCode" xml:space="preserve">
<value>Qr Code</value>
</data>
Expand Down
7 changes: 5 additions & 2 deletions KeyManager.Library.UI/PublishKeyStoreDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,15 @@
<ToggleButton IsChecked="{Binding Options.ResolveKeyLinks}" Style="{StaticResource MaterialDesignSwitchLightToggleButton}" />
<TextBlock Text="{x:Static properties:Resources.ResolveKeyLinks}" Padding="3" />
</StackPanel>
<TextBox Text="{Binding Options.PublishVariable}" Margin="5,5,5,15"
materialDesign:HintAssist.HelperText="{x:Static properties:Resources.PublishVariableHelper}"
materialDesign:HintAssist.Hint="{x:Static properties:Resources.PublishVariable}"/>
<Expander HorizontalAlignment="Stretch" Header="{x:Static properties:Resources.WrappingKey}" Margin="5">
<StackPanel Orientation="Vertical" TextBlock.Foreground="{DynamicResource MaterialDesignBody}" Margin="24,8,24,16">
<local:KeyEntryIdControl KeyEntryId="{Binding Options.WrappingKey.KeyId, Mode=TwoWay}" />
<TextBox Text="{Binding Options.WrappingKey.ContainerSelector, Mode=TwoWay}" Margin="5"
materialDesign:HintAssist.HelperText="{x:Static properties:Resources.KeyVersionHelper}"
materialDesign:HintAssist.Hint="{x:Static properties:Resources.KeyVersion}"/>
materialDesign:HintAssist.HelperText="{x:Static properties:Resources.KeyVersionHelper}"
materialDesign:HintAssist.Hint="{x:Static properties:Resources.KeyVersion}"/>
</StackPanel>
</Expander>
</StackPanel>
Expand Down
6 changes: 6 additions & 0 deletions KeyManager.Library/KeyStore/KeyStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public abstract class KeyStore

public const string ATTRIBUTE_NAME = "name";
public const string ATTRIBUTE_HEXNAME = "hexname";
public const string ATTRIBUTE_PUBVAR = "pubvar";

protected readonly JsonSerializerSettings _jsonSettings;

Expand Down Expand Up @@ -258,6 +259,11 @@ public virtual async Task Publish(KeyStore store, Func<string, KeyStore?> getFav
{
var changes = new List<IChangeKeyEntry>();
initCallback?.Invoke(this, keClass, ids.Count());
if (!string.IsNullOrEmpty(Options?.PublishVariable))
{
Attributes[ATTRIBUTE_PUBVAR] = Options.PublishVariable;
}

foreach (var id in ids)
{
var entry = await Get(id, keClass);
Expand Down
7 changes: 7 additions & 0 deletions KeyManager.Library/KeyStore/StoreOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,12 @@ public bool ResolveKeyLinks
get => _resolveKeyLinks;
set => SetProperty(ref _resolveKeyLinks, value);
}

private string? _publishVariable;
public string? PublishVariable
{
get => _publishVariable;
set => SetProperty(ref _publishVariable, value);
}
}
}

0 comments on commit 21e5f29

Please sign in to comment.