Commit 336dd68c authored by Thomas's avatar Thomas
Browse files

Add submitter and creation date information to Form Region

parent e79230b1
...@@ -28,7 +28,7 @@ namespace pEp.DPE ...@@ -28,7 +28,7 @@ namespace pEp.DPE
/// </summary> /// </summary>
private void PatchEvents_PatchAccepted(object sender, PatchEventArgs e) private void PatchEvents_PatchAccepted(object sender, PatchEventArgs e)
{ {
ThisAddIn.PEPEngine.ShowNotification("pEp Distributed Policy Engine", $"Patch with id {e.Patch.Id} was accepted."); ThisAddIn.PEPEngine.ShowNotification("pEp Distributed Policy Engine", $"Patch with id { e.Patch.Id } was accepted.");
} }
/// <summary> /// <summary>
...@@ -36,7 +36,7 @@ namespace pEp.DPE ...@@ -36,7 +36,7 @@ namespace pEp.DPE
/// </summary> /// </summary>
private void PatchEvents_PatchRejected(object sender, PatchEventArgs e) private void PatchEvents_PatchRejected(object sender, PatchEventArgs e)
{ {
ThisAddIn.PEPEngine.ShowNotification("pEp Distributed Policy Engine", $"Patch with id {e.Patch.Id} was rejected."); ThisAddIn.PEPEngine.ShowNotification("pEp Distributed Policy Engine", $"Patch with id { e.Patch.Id } was rejected.");
} }
/// <summary> /// <summary>
......
...@@ -2,10 +2,6 @@ ...@@ -2,10 +2,6 @@
using pEp.UI.Models; using pEp.UI.Models;
using pEp.UI.ViewModels; using pEp.UI.ViewModels;
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Office = Microsoft.Office.Core;
using Outlook = Microsoft.Office.Interop.Outlook; using Outlook = Microsoft.Office.Interop.Outlook;
namespace pEp namespace pEp
...@@ -39,8 +35,8 @@ namespace pEp ...@@ -39,8 +35,8 @@ namespace pEp
omi = this.OutlookItem as Outlook.MailItem; omi = this.OutlookItem as Outlook.MailItem;
string xml = omi.HTMLBody; string xml = omi.HTMLBody;
Patch patch = Patch.Deserialize(xml); Patch patch = Patch.Deserialize(xml);
FormControlPatchViewModel formControlPatchViewModel = new FormControlPatchViewModel(patch, PatchDialog.PatchAction.SupportOrRejectPatch); PEPIdentity.GetFromIdentity(omi, out PEPIdentity submitter);
this.FormControlPatchView.DataContext = formControlPatchViewModel; this.FormControlPatchView.DataContext = new FormControlPatchViewModel(patch, submitter, PatchDialog.PatchAction.SupportOrRejectPatch);
} }
catch (Exception ex) catch (Exception ex)
{ {
......
using pEp.DPE; using pEp.DPE;
using pEp.UI.Models; using pEp.UI.Models;
using System;
using System.Windows.Documents; using System.Windows.Documents;
using System.Windows.Media; using System.Windows.Media;
...@@ -37,6 +36,11 @@ namespace pEp.UI.ViewModels ...@@ -37,6 +36,11 @@ namespace pEp.UI.ViewModels
} }
} }
/// <summary>
/// Gets the creation date as string.
/// </summary>
public string CreationDateString => this.patch?.CreationDate.ToString("F");
/// <summary> /// <summary>
/// The diff of this patch. /// The diff of this patch.
/// </summary> /// </summary>
...@@ -181,6 +185,11 @@ namespace pEp.UI.ViewModels ...@@ -181,6 +185,11 @@ namespace pEp.UI.ViewModels
/// </summary> /// </summary>
public string RejectButtonText { get; } = Properties.Resources.SyncWizard_RejectButton; public string RejectButtonText { get; } = Properties.Resources.SyncWizard_RejectButton;
/// <summary>
/// Gets the submitter of this patch.
/// </summary>
public PEPIdentity Submitter { get; }
/// <summary> /// <summary>
/// Gets or sets the tag of the patch. /// Gets or sets the tag of the patch.
/// </summary> /// </summary>
...@@ -212,10 +221,18 @@ namespace pEp.UI.ViewModels ...@@ -212,10 +221,18 @@ namespace pEp.UI.ViewModels
#region Constructors #region Constructors
public FormControlPatchViewModel(Patch patch, PatchDialog.PatchAction patchAction, bool isEditable = false) /// <summary>
/// Primary constructor.
/// </summary>
/// <param name="patch">The patch to create the form region with.</param>
/// <param name="submitter">The submitter of the patch.</param>
/// <param name="patchAction">The action to perform with the patch.</param>
/// <param name="isEditable">Whether this patch is editable.</param>
public FormControlPatchViewModel(Patch patch, PEPIdentity submitter, PatchDialog.PatchAction patchAction, bool isEditable = false)
{ {
this.patch = patch; this.patch = patch;
this.IsEditable = isEditable; this.IsEditable = isEditable;
this.Submitter = submitter;
switch (patchAction) switch (patchAction)
{ {
...@@ -234,7 +251,7 @@ namespace pEp.UI.ViewModels ...@@ -234,7 +251,7 @@ namespace pEp.UI.ViewModels
break; break;
case PatchDialog.PatchAction.SupportOrRejectPatch: case PatchDialog.PatchAction.SupportOrRejectPatch:
{ {
this.Explanation = "Support or reject patch"; this.Explanation = "New configuration changes pending approval";
this.IsRejectButtonVisible = true; this.IsRejectButtonVisible = true;
this.OKButtonText = "Support"; this.OKButtonText = "Support";
} }
......
...@@ -7,7 +7,9 @@ ...@@ -7,7 +7,9 @@
xmlns:ui="clr-namespace:pEp.UI" xmlns:ui="clr-namespace:pEp.UI"
xmlns:vm="clr-namespace:pEp.UI.ViewModels" xmlns:vm="clr-namespace:pEp.UI.ViewModels"
mc:Ignorable="d" mc:Ignorable="d"
d:DataContext="{d:DesignInstance Type=vm:PatchDialogViewModel}" FontFamily="Segoe UI"
FontSize="12"
d:DataContext="{d:DesignInstance Type=vm:FormControlPatchViewModel}"
d:DesignHeight="450" d:DesignWidth="800"> d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources> <UserControl.Resources>
<ResourceDictionary> <ResourceDictionary>
...@@ -24,10 +26,13 @@ ...@@ -24,10 +26,13 @@
</UserControl.Resources> </UserControl.Resources>
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="*" /> <RowDefinition Height="*" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
...@@ -37,22 +42,44 @@ ...@@ -37,22 +42,44 @@
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Label Grid.Column="0" <Label Grid.Column="0"
Grid.Row="0" Grid.Row="0"
Grid.ColumnSpan="2"
Content="{Binding Explanation}" Content="{Binding Explanation}"
Margin="10"/> FontWeight="Bold"
<Button Grid.Column="1" Margin="10,5"/>
Grid.Row="0"
Content="Load from file"
Margin="10"
HorizontalAlignment="Right"
Style="{StaticResource StyleButtonGray}"
Command="{Binding LoadFromFileCommand}"
Visibility="{Binding IsEditable, Converter={StaticResource BoolToVisibility}}"/>
<Label Grid.Column="0" <Label Grid.Column="0"
Grid.Row="1" Grid.Row="1"
Content="Diff*" Grid.ColumnSpan="2"
Content="{Binding Submitter.DisplayString}"
Margin="10,2" />
<Label Grid.Column="0"
Grid.Row="2"
Grid.ColumnSpan="2"
Content="{Binding CreationDateString}"
Margin="10,2" />
<Image Grid.Column="2"
Grid.Row="0"
Grid.RowSpan="3"
Width="100"
Height="41"
Source="pack://application:,,,/pEp;component/Resources/ImageLogoMedium.png"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Margin="5,5,10,5"/>
<!--<Button Grid.Column="1"
Grid.Row="0"
Content="Load from file"
Margin="10"
HorizontalAlignment="Right"
Style="{StaticResource StyleButtonGray}"
Command="{Binding LoadFromFileCommand}"
Visibility="{Binding IsEditable, Converter={StaticResource BoolToVisibility}}"/>-->
<Label Grid.Column="0"
Grid.Row="3"
Content="Diff"
Margin="10,10,5,10"/> Margin="10,10,5,10"/>
<ui:TextBoxWithPlaceholder Grid.Column="1" <ui:TextBoxWithPlaceholder Grid.Column="1"
Grid.Row="1" Grid.ColumnSpan="2"
Grid.Row="3"
Text="{Binding Diff, UpdateSourceTrigger=PropertyChanged}" Text="{Binding Diff, UpdateSourceTrigger=PropertyChanged}"
MultiLine="True" MultiLine="True"
IsReadOnly="{Binding IsEditable, Converter={StaticResource InvertBool}}" IsReadOnly="{Binding IsEditable, Converter={StaticResource InvertBool}}"
...@@ -63,20 +90,22 @@ ...@@ -63,20 +90,22 @@
Margin="5,10,10,10" Margin="5,10,10,10"
Visibility="{Binding IsEditable, Converter={StaticResource BoolToVisibility}}"/> Visibility="{Binding IsEditable, Converter={StaticResource BoolToVisibility}}"/>
<FlowDocumentScrollViewer Grid.Column="1" <FlowDocumentScrollViewer Grid.Column="1"
Grid.ColumnSpan="2"
Grid.Row="3"
BorderBrush="Black" BorderBrush="Black"
BorderThickness="1" BorderThickness="1"
Grid.Row="1"
MinHeight="400" MinHeight="400"
MinWidth="600" MinWidth="600"
Margin="5,10,10,10" Margin="5,10,10,10"
Document="{Binding DisplayDiff}" Document="{Binding DisplayDiff}"
Visibility="{Binding IsEditable, Converter={StaticResource InvertBoolToVisibility}}"/> Visibility="{Binding IsEditable, Converter={StaticResource InvertBoolToVisibility}}"/>
<Label Grid.Column="0" <Label Grid.Column="0"
Grid.Row="2" Grid.Row="4"
Content="Uri*" Content="Uri"
Margin="10,10,5,10"/> Margin="10,10,5,10"/>
<ui:TextBoxWithPlaceholder Grid.Column="1" <ui:TextBoxWithPlaceholder Grid.Column="1"
Grid.Row="2" Grid.ColumnSpan="2"
Grid.Row="4"
Text="{Binding Uri}" Text="{Binding Uri}"
IsReadOnly="{Binding IsEditable, Converter={StaticResource InvertBool}}" IsReadOnly="{Binding IsEditable, Converter={StaticResource InvertBool}}"
IsValidInput="{Binding IsUriValid}" IsValidInput="{Binding IsUriValid}"
...@@ -84,11 +113,12 @@ ...@@ -84,11 +113,12 @@
MinWidth="400" MinWidth="400"
Margin="5,10,10,10"/> Margin="5,10,10,10"/>
<Label Grid.Column="0" <Label Grid.Column="0"
Grid.Row="3" Grid.Row="5"
Content="Commit message*" Content="Commit message"
Margin="10,10,5,10"/> Margin="10,10,5,10"/>
<ui:TextBoxWithPlaceholder Grid.Column="1" <ui:TextBoxWithPlaceholder Grid.Column="1"
Grid.Row="3" Grid.ColumnSpan="2"
Grid.Row="5"
Text="{Binding CommitMessage}" Text="{Binding CommitMessage}"
IsReadOnly="{Binding IsEditable, Converter={StaticResource InvertBool}}" IsReadOnly="{Binding IsEditable, Converter={StaticResource InvertBool}}"
IsValidInput="{Binding IsCommitMessageValid}" IsValidInput="{Binding IsCommitMessageValid}"
...@@ -96,19 +126,20 @@ ...@@ -96,19 +126,20 @@
MinWidth="400" MinWidth="400"
Margin="5,10,10,10"/> Margin="5,10,10,10"/>
<Label Grid.Column="0" <Label Grid.Column="0"
Grid.Row="4" Grid.Row="6"
Content="Tag" Content="Tag"
Margin="10,10,5,10"/> Margin="10,10,5,10"/>
<ui:TextBoxWithPlaceholder Grid.Column="1" <ui:TextBoxWithPlaceholder Grid.Column="1"
Grid.Row="4" Grid.ColumnSpan="2"
Grid.Row="6"
Text="{Binding Tag}" Text="{Binding Tag}"
IsReadOnly="{Binding IsEditable, Converter={StaticResource InvertBool}}" IsReadOnly="{Binding IsEditable, Converter={StaticResource InvertBool}}"
Placeholder="Tag (optional)" Placeholder="Tag (optional)"
MinWidth="400" MinWidth="400"
Margin="5,10,10,10"/> Margin="5,10,10,10"/>
<StackPanel Grid.Column="0" <StackPanel Grid.Column="0"
Grid.ColumnSpan="2" Grid.ColumnSpan="3"
Grid.Row="5" Grid.Row="7"
Orientation="Horizontal" Orientation="Horizontal"
HorizontalAlignment="Center"> HorizontalAlignment="Center">
<Button Content="{Binding OKButtonText}" <Button Content="{Binding OKButtonText}"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment