<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>

    <StackPanel Orientation="Horizontal" Spacing="6">
      <Button Classes="danger" Content="DELETE" Command="{Binding ConfirmDeleteCommand}"
              IsEnabled="{Binding !IsBusy}" />
      <Button Classes="ghost" Content="CANCEL" Command="{Binding CancelDeleteCommand}" />
    </StackPanel>

  </StackPanel>

</UserControl>
