@using ZelWiki.Models
@model ZelWiki.Models.ViewModels.File.PageFileRevisionsViewModel
@{
    Layout = "/Views/Shared/_Layout.cshtml";
    var sessionState = ViewData["SessionState"] as ZelWiki.SessionState ?? throw new Exception("Wiki State Context cannot be null.");
}

<h3>
    Page File Revisions
</h3>

<p>
    All changes that have been made to the attached file. <br /><br />
</p>

@if (!string.IsNullOrEmpty(Model.ErrorMessage))
{
    <div class="alert alert-danger">@Html.Raw(Model.ErrorMessage)</div>
}
@if (!string.IsNullOrEmpty(Model.SuccessMessage))
{
    <div class="alert alert-success">@Html.Raw(Model.SuccessMessage)</div>
}

@using (Html.BeginForm(null, null, FormMethod.Get, new { action = $"{GlobalConfiguration.BasePath}{Context.Request.Path}" }))
{
    <table class="table fixedTable100 table-striped" border="0" cellspacing="0" cellpadding="0">
        <thead>
            <tr>
                <td><strong>Revision</strong></td>
                <td><strong>Modified By</strong></td>
                <td><strong>Modified Date</strong></td>
                <td><strong>Summary</strong></td>
            </tr>
        </thead>

        <tbody>
            @foreach (var h in Model.Revisions)
            {
                <tr>
                    <td><a href="@GlobalConfiguration.BasePath/File/Binary/@Model.PageNavigation/@Model.FileNavigation/@h.FileRevision" target="_blank" rel="noopener">@Html.DisplayTextFor(x => h.FileRevision)</a></td>
                    <td><a href="@GlobalConfiguration.BasePath/Profile/@h.CreatedByUserName/Public">@Html.DisplayTextFor(x => h.CreatedByUserName)</a></td>
                    <td>@Html.DisplayTextFor(x => h.CreatedDate)</td>
                    <td>@Html.DisplayTextFor(x => h.FriendlySize)</td>
                </tr>
            }
        </tbody>
    </table>

    @Html.Raw(ZelWiki.Library.PageSelectorGenerator.Generate(Context.Request.QueryString, Model.PaginationPageCount))
}
