<UserControl x:Class="SharepointToolbox.Views.Tabs.BulkSitesView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:loc="clr-namespace:SharepointToolbox.Localization">
    <DockPanel Margin="10">
        <StackPanel DockPanel.Dock="Left" Width="240" Margin="0,0,10,0">
            <Button Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[bulksites.import]}"
                    Command="{Binding ImportCsvCommand}" Margin="0,0,0,5" />
            <Button Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[bulksites.example]}"
                    Command="{Binding LoadExampleCommand}" Margin="0,0,0,10" />

            <TextBlock Text="{Binding PreviewSummary}" TextWrapping="Wrap" Margin="0,0,0,10" />

            <Button Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[bulksites.execute]}"
                    Command="{Binding RunCommand}" Margin="0,0,0,5"
                    IsEnabled="{Binding IsRunning, Converter={StaticResource InverseBoolConverter}}" />
            <Button Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[status.cancelled]}"
                    Command="{Binding CancelCommand}"
                    Visibility="{Binding IsRunning, Converter={StaticResource BoolToVisibilityConverter}}" />

            <ProgressBar Height="20" Margin="0,10,0,5" Value="{Binding ProgressValue}"
                         Visibility="{Binding IsRunning, Converter={StaticResource BoolToVisibilityConverter}}" />
            <TextBlock Text="{Binding StatusMessage}" TextWrapping="Wrap" />

            <TextBlock Text="{Binding ResultSummary}" FontWeight="Bold" Margin="0,10,0,5" />
            <Button Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[bulk.retryfailed]}"
                    Command="{Binding RetryFailedCommand}" Margin="0,0,0,5" />
            <Button Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[bulk.exportfailed]}"
                    Command="{Binding ExportFailedCommand}" />
        </StackPanel>

        <DataGrid ItemsSource="{Binding PreviewRows}" AutoGenerateColumns="False"
                  IsReadOnly="True" CanUserSortColumns="True">
            <DataGrid.RowStyle>
                <Style TargetType="DataGridRow">
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding IsValid}" Value="False">
                            <Setter Property="Background" Value="#FFFDE0E0" />
                            <Setter Property="Foreground" Value="#FFB00020" />
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </DataGrid.RowStyle>
            <DataGrid.Columns>
                <DataGridTextColumn Header="Valid" Binding="{Binding IsValid}" Width="50" />
                <DataGridTextColumn Header="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[bulksites.name]}"
                                    Binding="{Binding Record.Name}" Width="*" />
                <DataGridTextColumn Header="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[bulksites.alias]}"
                                    Binding="{Binding Record.Alias}" Width="100" />
                <DataGridTextColumn Header="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[bulksites.type]}"
                                    Binding="{Binding Record.Type}" Width="100" />
                <DataGridTextColumn Header="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[bulksites.owners]}"
                                    Binding="{Binding Record.Owners}" Width="*" />
                <DataGridTextColumn Header="Errors"
                                    Binding="{Binding Errors, Converter={StaticResource ListToStringConverter}}"
                                    Width="*" />
            </DataGrid.Columns>
        </DataGrid>
    </DockPanel>
</UserControl>
