<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 two places — the host sidebar, where it takes the place of the row of buttons that
    opened it, and the vault screen's detail pane, where it takes the place of EDIT and DELETE. The two
    moments are different and what has to be said is not, which is why this is a shared control rather than
    two 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 the two hosts frame it themselves: the sidebar puts it in the
    strip along its bottom edge, and the vault screen in a column that scrolls.

    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="13" TextWrapping="Wrap"
               Text="{Binding PendingDeletion.Question}" />

    <TextBlock Foreground="{StaticResource WarnText}" FontSize="11" 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="11" 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>
