Files
DodoSSH/src/DodoSSH.Client.App/Views/ConfirmDeleteCard.axaml
T

68 lines
3.5 KiB
XML

<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="using:DodoSSH.Client.Shell.ViewModels"
x:Class="DodoSSH.Client.App.Views.ConfirmDeleteCard"
x:DataType="vm:VaultViewModel">
<!--
The question in front of deleting something in the vault.
One control used in three places — the hosts drawer, where it takes the place of the row of buttons that
opened it; the hosts screen's GROUPS section, where it takes the place of that group's EDIT and DELETE;
and the vault screen's detail pane. The three moments are different and what has to be said is not,
which is why this is a shared control rather than three blocks that would drift apart. The sign-out
confirmation is the same arrangement, for the same reason; see SignOutCard.
A bare StackPanel and not a card, because all three hosts frame it themselves — each wraps it in its own
DangerWash border in the place its buttons were.
Everything it says is something the view model can answer. The question names the item, the consequence
knows whether this machine can push a tombstone yet, and the line in the box is a count of the hosts
that actually authenticate with the thing about to go — see VaultViewModel.HostsBoundTo. A confirmation
that only asked "are you sure?" would be a click to train people out of.
-->
<StackPanel Spacing="8">
<TextBlock Classes="heading" FontSize="14" TextWrapping="Wrap"
Text="{Binding PendingDeletion.Question}" />
<TextBlock Foreground="{StaticResource WarnText}" FontSize="12" TextWrapping="Wrap"
Text="{Binding PendingDeletion.Consequence}" />
<!--
What else in this vault leans on it. In a box of its own because it is the line that changes the
answer: everything above is true of every deletion, and this is about the one being made.
-->
<Border Background="{StaticResource Panel}" BorderBrush="{StaticResource Border}"
BorderThickness="1" CornerRadius="4" Padding="8,6"
IsVisible="{Binding PendingDeletion.HasUsage, FallbackValue=False}">
<TextBlock Foreground="{StaticResource Info}" FontSize="12" TextWrapping="Wrap"
Text="{Binding PendingDeletion.Usage}" />
</Border>
<!--
The second question, and only a group's deletion has one: whether the machines filed under it go with
it. See VaultViewModel.DeleteGroup for why it is asked rather than stated, and DeletionTakesTheHostsToo
for why it is a tick rather than a pair of options — the two answers are not equally weighted, and the
recoverable one is the one that needs no decision.
Below the usage box on purpose: that box is the count this is about, and a tick offered above the
number it applies to is a tick somebody answers before reading how many.
-->
<CheckBox IsVisible="{Binding PendingDeletion.HasChoice, FallbackValue=False}"
IsChecked="{Binding DeletionTakesTheHostsToo}">
<TextBlock Foreground="{StaticResource WarnText}" FontSize="12" TextWrapping="Wrap"
Text="{Binding PendingDeletion.Choice}" />
</CheckBox>
<StackPanel Orientation="Horizontal" Spacing="6">
<Button Classes="danger" Content="DELETE" Command="{Binding ConfirmDeleteCommand}"
IsEnabled="{Binding !IsBusy}" />
<Button x:Name="CancelButton" Classes="ghost" Content="CANCEL" Command="{Binding CancelDeleteCommand}" />
</StackPanel>
</StackPanel>
</UserControl>