Skip to content

Commit

Permalink
Hide dashboard load download/view buttons in unsupported M-Files vers…
Browse files Browse the repository at this point in the history
…ions (#86)

* Hid dashboard load download/view buttons in unsupported M-Files versions.

* Added comment.
  • Loading branch information
CraigHawker committed Jan 11, 2023
1 parent 49ad07e commit fd2a006
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ protected virtual ILoggingDashboardContentRenderer GetLoggingDashboardContentRen
/// </summary>
/// <returns>The dashboard content. Can be null if no logging data is available or configured.</returns>
public virtual IDashboardContent GetLoggingDashboardContent(IConfigurationRequestContext context)
=> this.LoggingDashboardContentRenderer?.GetDashboardContent(this.GetLoggingConfiguration());
=> this.LoggingDashboardContentRenderer?.GetDashboardContent(context, this.GetLoggingConfiguration());

#endregion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Linq;
using MFiles.VAF.Configuration.Logging;
using MFiles.VAF.Configuration.Logging.Targets;
using MFiles.VAF.Configuration.AdminConfigurations;

namespace MFiles.VAF.Extensions.Dashboards.LoggingDashboardContent
{
Expand All @@ -27,7 +28,11 @@ public class DashboardListLoggingDashboardContentRenderer
/// </summary>
protected bool AllowDashboardLogEntryViewing { get; set; } = true;

public virtual DashboardPanelEx GetDashboardContent(ILoggingConfiguration loggingConfiguration)
public virtual DashboardPanelEx GetDashboardContent
(
IConfigurationRequestContext context,
ILoggingConfiguration loggingConfiguration
)
{
// If we don't have any logging configuration then return null.
if (loggingConfiguration == null)
Expand Down Expand Up @@ -106,25 +111,30 @@ public virtual DashboardPanelEx GetDashboardContent(ILoggingConfiguration loggin
{
// Add whatever buttons, according to app configuration.
var buttons = new DashboardContentCollection();
if (this.AllowDashboardLogFileDownload)

// If the M-Files version is old and can't provide a default log location then don't render the buttons.
if (false == string.IsNullOrWhiteSpace(Commands.DefaultLogDashboardCommandBase.ResolveRootLogPath(context?.Vault)))
{
buttons.Add(new DashboardDomainCommandEx
if (this.AllowDashboardLogFileDownload)
{
DomainCommandID = this.AllowUserToSelectLogFiles
? Dashboards.Commands.ShowSelectLogDownloadDashboardCommand.CommandId
: Dashboards.Commands.DownloadSelectedLogsDashboardCommand.CommandId,
Title = Resources.Dashboard.Logging_Table_DownloadLogs,
Icon = "Resources/Images/Download.png"
});
}
if (this.AllowDashboardLogEntryViewing)
{
buttons.Add(new DashboardDomainCommandEx
buttons.Add(new DashboardDomainCommandEx
{
DomainCommandID = this.AllowUserToSelectLogFiles
? Dashboards.Commands.ShowSelectLogDownloadDashboardCommand.CommandId
: Dashboards.Commands.DownloadSelectedLogsDashboardCommand.CommandId,
Title = Resources.Dashboard.Logging_Table_DownloadLogs,
Icon = "Resources/Images/Download.png"
});
}
if (this.AllowDashboardLogEntryViewing)
{
DomainCommandID = Dashboards.Commands.ShowLatestLogEntriesDashboardCommand.CommandId,
Title = Resources.Dashboard.Logging_Table_ShowLatestLogEntries,
Icon = "Resources/Images/viewlogs.png"
});
buttons.Add(new DashboardDomainCommandEx
{
DomainCommandID = Dashboards.Commands.ShowLatestLogEntriesDashboardCommand.CommandId,
Title = Resources.Dashboard.Logging_Table_ShowLatestLogEntries,
Icon = "Resources/Images/viewlogs.png"
});
}
}

// Add the buttons to the cell
Expand Down Expand Up @@ -163,7 +173,11 @@ public virtual DashboardPanelEx GetDashboardContent(ILoggingConfiguration loggin
};
}

IDashboardContent ILoggingDashboardContentRenderer.GetDashboardContent(ILoggingConfiguration loggingConfiguration)
=> this.GetDashboardContent(loggingConfiguration);
IDashboardContent ILoggingDashboardContentRenderer.GetDashboardContent
(
IConfigurationRequestContext context,
ILoggingConfiguration loggingConfiguration
)
=> this.GetDashboardContent(context, loggingConfiguration);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using MFiles.VAF.Configuration.Domain.Dashboards;
using MFiles.VAF.Configuration.AdminConfigurations;
using MFiles.VAF.Configuration.Domain.Dashboards;
using MFiles.VAF.Configuration.Logging;

namespace MFiles.VAF.Extensions.Dashboards.LoggingDashboardContent
Expand All @@ -9,6 +10,10 @@ public interface ILoggingDashboardContentRenderer
/// Gets the logging dashboard content.
/// </summary>
/// <returns>The content, or null if nothing to render.</returns>
IDashboardContent GetDashboardContent(ILoggingConfiguration loggingConfiguration);
IDashboardContent GetDashboardContent
(
IConfigurationRequestContext context,
ILoggingConfiguration loggingConfiguration
);
}
}

0 comments on commit fd2a006

Please sign in to comment.