Commit 82177e2a authored by Thomas's avatar Thomas
Browse files

Move the patch button to backstage

parent e5f5de6b
...@@ -20,7 +20,7 @@ namespace pEp.DPE ...@@ -20,7 +20,7 @@ namespace pEp.DPE
/// <param name="me">The own identity that rejects the patch.</param> /// <param name="me">The own identity that rejects the patch.</param>
/// <exception cref="ArgumentNullException">The post URI is null.</exception> /// <exception cref="ArgumentNullException">The post URI is null.</exception>
/// <exception cref="HttpRequestException">The HTTP request failed.</exception> /// <exception cref="HttpRequestException">The HTTP request failed.</exception>
/// <returns>The Http response.</returns> /// <returns>The HTTP response.</returns>
public static async Task<HttpResponseMessage> RejectPatch(Patch patch, PEPIdentity me) public static async Task<HttpResponseMessage> RejectPatch(Patch patch, PEPIdentity me)
{ {
// POST http://localhost:port/pEpDPE/patches/patch_id/reject // POST http://localhost:port/pEpDPE/patches/patch_id/reject
...@@ -46,9 +46,9 @@ namespace pEp.DPE ...@@ -46,9 +46,9 @@ namespace pEp.DPE
/// </summary> /// </summary>
/// <param name="patch">The patch to suggest.</param> /// <param name="patch">The patch to suggest.</param>
/// <param name="me">The own identity that suggests the patch.</param> /// <param name="me">The own identity that suggests the patch.</param>
/// <exception cref="ArgumentNullException" /> /// <exception cref="ArgumentNullException">The post URI is null.</exception>
/// <exception cref="HttpRequestException" /> /// <exception cref="HttpRequestException">The HTTP request failed.</exception>
/// <returns>The Http response.</returns> /// <returns>The HTTP response.</returns>
public static async Task<HttpResponseMessage> SuggestPatch(Patch patch, PEPIdentity me) public static async Task<HttpResponseMessage> SuggestPatch(Patch patch, PEPIdentity me)
{ {
// POST http://localhost:port/pEpDPE/patches/ // POST http://localhost:port/pEpDPE/patches/
...@@ -74,9 +74,9 @@ namespace pEp.DPE ...@@ -74,9 +74,9 @@ namespace pEp.DPE
/// </summary> /// </summary>
/// <param name="patch">The patch to support.</param> /// <param name="patch">The patch to support.</param>
/// <param name="me">The own identity that supports the patch.</param> /// <param name="me">The own identity that supports the patch.</param>
/// <exception cref="ArgumentNullException" /> /// <exception cref="ArgumentNullException">The post URI is null.</exception>
/// <exception cref="HttpRequestException" /> /// <exception cref="HttpRequestException">The HTTP request failed.</exception>
/// <returns>The Http response.</returns> /// <returns>The HTTP response.</returns>
public static async Task<HttpResponseMessage> SupportPatch(Patch patch, PEPIdentity me) public static async Task<HttpResponseMessage> SupportPatch(Patch patch, PEPIdentity me)
{ {
// POST http://localhost:port/pEpDPE/patches/patch_id/support // POST http://localhost:port/pEpDPE/patches/patch_id/support
......
...@@ -211,20 +211,27 @@ namespace pEp.DPE ...@@ -211,20 +211,27 @@ namespace pEp.DPE
{ {
// Determine the correct method to execute // Determine the correct method to execute
HttpResponseMessage httpResponseMessage = null; HttpResponseMessage httpResponseMessage = null;
switch (postAction) try
{ {
case PostAction.Reject: switch (postAction)
httpResponseMessage = await DPEWebClient.RejectPatch(patch, me); {
break; case PostAction.Reject:
case PostAction.Suggest: httpResponseMessage = await DPEWebClient.RejectPatch(patch, me);
httpResponseMessage = await DPEWebClient.SuggestPatch(patch, me); break;
break; case PostAction.Suggest:
case PostAction.Support: httpResponseMessage = await DPEWebClient.SuggestPatch(patch, me);
httpResponseMessage = await DPEWebClient.SupportPatch(patch, me); break;
break; case PostAction.Support:
default: httpResponseMessage = await DPEWebClient.SupportPatch(patch, me);
Log.ErrorAndFailInDebugMode("PostAsync: Unknown post action."); break;
break; default:
Log.ErrorAndFailInDebugMode("PostAsync: Unknown post action.");
break;
}
}
catch (HttpRequestException ex)
{
throw ex;
} }
if (httpResponseMessage.StatusCode != HttpStatusCode.OK) if (httpResponseMessage.StatusCode != HttpStatusCode.OK)
......
...@@ -72,7 +72,7 @@ namespace pEp.UI.Models ...@@ -72,7 +72,7 @@ namespace pEp.UI.Models
/// <param name="patchAction">The action to perform with the patch.</param> /// <param name="patchAction">The action to perform with the patch.</param>
/// <param name="patch">The patch to manage.</param> /// <param name="patch">The patch to manage.</param>
/// <param name="isEditable">Whether the patch can be edited.</param> /// <param name="isEditable">Whether the patch can be edited.</param>
public static async Task ShowDialog(PatchDialog.PatchAction patchAction, Patch patch, bool isEditable = false) public static async void ShowDialog(PatchDialog.PatchAction patchAction, Patch patch, bool isEditable = false)
{ {
// If needed, make sure we have a valid own identity // If needed, make sure we have a valid own identity
PEPIdentity me = null; PEPIdentity me = null;
......
...@@ -1360,6 +1360,14 @@ namespace pEp ...@@ -1360,6 +1360,14 @@ namespace pEp
return (Properties.Resources.ImageBackstageCompatibility); return (Properties.Resources.ImageBackstageCompatibility);
} }
/// <summary>
/// Callback to get the image for the ButtonDPE.
/// </summary>
public System.Drawing.Bitmap ButtonDPE_GetImage(Office.IRibbonControl control)
{
return (Properties.Resources.ImageLogoGreen);
}
/// <summary> /// <summary>
/// Callback to get the image for the ButtonCompatibility. /// Callback to get the image for the ButtonCompatibility.
/// </summary> /// </summary>
...@@ -1408,6 +1416,30 @@ namespace pEp ...@@ -1408,6 +1416,30 @@ namespace pEp
return (Properties.Resources.Ribbon_GroupCompatibilityLabel); return (Properties.Resources.Ribbon_GroupCompatibilityLabel);
} }
/// <summary>
/// Callback to get the label text for the GroupDPE.
/// </summary>
public string GroupDPE_GetLabel(Office.IRibbonControl control)
{
return "Patch management";
}
/// <summary>
/// Callback to get the helper text for the GroupDPE.
/// </summary>
public string GroupDPE_GetHelperText(Office.IRibbonControl control)
{
return "Manage patches and change the configuration";
}
/// <summary>
/// Callback to get the visibility of the GroupDPE.
/// </summary>
public bool GroupDPE_GetIsVisible(Office.IRibbonControl control)
{
return true;
}
/// <summary> /// <summary>
/// Callback to get the visibility of the GroupPEPHome. /// Callback to get the visibility of the GroupPEPHome.
/// </summary> /// </summary>
...@@ -1453,6 +1485,11 @@ namespace pEp ...@@ -1453,6 +1485,11 @@ namespace pEp
return (Properties.Resources.Ribbon_ButtonAccountsLabel); return (Properties.Resources.Ribbon_ButtonAccountsLabel);
} }
public void ButtonDPE_Click(Office.IRibbonControl control)
{
PatchDialog.ShowDialog(PatchDialog.PatchAction.NewPatch, new DPE.Patch(), true);
}
/// <summary> /// <summary>
/// Callback to get the label text for the ButtonCompatibility. /// Callback to get the label text for the ButtonCompatibility.
/// </summary> /// </summary>
...@@ -1461,6 +1498,14 @@ namespace pEp ...@@ -1461,6 +1498,14 @@ namespace pEp
return (Properties.Resources.Ribbon_ButtonCompatibilityLabel); return (Properties.Resources.Ribbon_ButtonCompatibilityLabel);
} }
/// <summary>
/// Callback to get the label text for the ButtonDPE.
/// </summary>
public string ButtonDPE_GetLabel(Office.IRibbonControl control)
{
return "Patch management";
}
/// <summary> /// <summary>
/// Callback to get the label text for the LabelControlName. /// Callback to get the label text for the LabelControlName.
/// </summary> /// </summary>
......
...@@ -118,6 +118,19 @@ ...@@ -118,6 +118,19 @@
getLabel="ButtonCompatibility_GetLabel"/> getLabel="ButtonCompatibility_GetLabel"/>
</primaryItem> </primaryItem>
</group> </group>
<!--Patch Management-->
<group id="GroupDPE"
getLabel="GroupDPE_GetLabel"
getHelperText="GroupDPE_GetHelperText"
getVisible="GroupDPE_GetIsVisible">
<primaryItem>
<button id="ButtonDPE"
isDefinitive="true"
onAction="ButtonDPE_Click"
getImage="ButtonDPE_GetImage"
getLabel="ButtonDPE_GetLabel"/>
</primaryItem>
</group>
</firstColumn> </firstColumn>
<secondColumn> <secondColumn>
<!-- About --> <!-- About -->
......
...@@ -60,6 +60,19 @@ ...@@ -60,6 +60,19 @@
getLabel="ButtonCompatibility_GetLabel"/> getLabel="ButtonCompatibility_GetLabel"/>
</primaryItem> </primaryItem>
</group> </group>
<!--Patch Management-->
<group id="GroupDPE"
getLabel="GroupDPE_GetLabel"
getHelperText="GroupDPE_GetHelperText"
getVisible="GroupDPE_GetIsVisible">
<primaryItem>
<button id="ButtonDPE"
isDefinitive="true"
onAction="ButtonDPE_Click"
getImage="ButtonDPE_GetImage"
getLabel="ButtonDPE_GetLabel"/>
</primaryItem>
</group>
</firstColumn> </firstColumn>
<secondColumn> <secondColumn>
<!-- About --> <!-- About -->
......
...@@ -40,7 +40,6 @@ namespace pEp.UI.ViewModels ...@@ -40,7 +40,6 @@ namespace pEp.UI.ViewModels
private RelayCommand _CommandButtonDeleteGroup = null; private RelayCommand _CommandButtonDeleteGroup = null;
private RelayCommand _CommandButtonExportKeys = null; private RelayCommand _CommandButtonExportKeys = null;
private RelayCommand _CommandButtonImportKeys = null; private RelayCommand _CommandButtonImportKeys = null;
private RelayCommand _CommandButtonNewPatch = null;
private RelayCommand _CommandButtonOK = null; private RelayCommand _CommandButtonOK = null;
private RelayCommand _CommandButtonRefreshLogs = null; private RelayCommand _CommandButtonRefreshLogs = null;
private RelayCommand _CommandButtonResetPEPStore = null; private RelayCommand _CommandButtonResetPEPStore = null;
...@@ -205,22 +204,6 @@ namespace pEp.UI.ViewModels ...@@ -205,22 +204,6 @@ namespace pEp.UI.ViewModels
} }
} }
/// <summary>
/// Gets the command to execute when the New patch button is clicked.
/// </summary>
public RelayCommand CommandButtonNewPatch
{
get
{
if (this._CommandButtonNewPatch == null)
{
this._CommandButtonNewPatch = new RelayCommand(async p => await PatchDialog.ShowDialog(PatchDialog.PatchAction.NewPatch, new Patch(), true));
}
return this._CommandButtonNewPatch;
}
}
/// <summary> /// <summary>
/// Gets the command to execute when the OK button is clicked. /// Gets the command to execute when the OK button is clicked.
/// </summary> /// </summary>
......
...@@ -157,20 +157,6 @@ ...@@ -157,20 +157,6 @@
VerticalAlignment="Center" /> VerticalAlignment="Center" />
</StackPanel> </StackPanel>
</ListBoxItem>--> </ListBoxItem>-->
<!--<ListBoxItem Visibility="{Binding Path=IsDPEEnabled, Converter={StaticResource BoolToVisibility}}">-->
<ListBoxItem>
<StackPanel Orientation="Horizontal"
Height="{StaticResource PageSelectorHeight}">
<Image Source="pack://application:,,,/pEp;component/Resources/ImageOptionsGroupEncryption.png"
Width="26"
Height="13"
HorizontalAlignment="Left"
VerticalAlignment="Center" />
<TextBlock Text="Patch management"
HorizontalAlignment="Left"
VerticalAlignment="Center" />
</StackPanel>
</ListBoxItem>
<ListBoxItem Visibility="{Binding Path=IsDeveloperModeEnabled, Converter={StaticResource BoolToVisibility}}"> <ListBoxItem Visibility="{Binding Path=IsDeveloperModeEnabled, Converter={StaticResource BoolToVisibility}}">
<StackPanel Orientation="Horizontal" <StackPanel Orientation="Horizontal"
Height="{StaticResource PageSelectorHeight}"> Height="{StaticResource PageSelectorHeight}">
...@@ -965,26 +951,6 @@ ...@@ -965,26 +951,6 @@
</StackPanel> </StackPanel>
</TabItem>--> </TabItem>-->
<!--Distributed Policy Management-->
<TabItem>
<StackPanel Margin="{StaticResource PagePadding}">
<!-- DPE title -->
<TextBlock Text="Distributed Policy Management"
Margin="6,6,0,0"
FontWeight="Bold"
FontSize="16" />
<Separator />
<!--New patch button-->
<Button Content="New patch"
Style="{StaticResource StyleButtonGray}"
Margin="10,5,5,5"
Command="{Binding CommandButtonNewPatch}"
HorizontalAlignment="Left"/>
</StackPanel>
</TabItem>
<!-- Developer --> <!-- Developer -->
<TabItem> <TabItem>
<Grid Margin="{StaticResource PagePadding}"> <Grid Margin="{StaticResource PagePadding}">
......
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