{{/*
This file is part of SystemTestPortal.
Copyright (C) 2017  Institute of Software Technology, University of Stuttgart

SystemTestPortal is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

SystemTestPortal is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with SystemTestPortal.  If not, see <http://www.gnu.org/licenses/>.
*/}}

{{ define "tab-content"}}
<div class="modal fade" id="helpModal">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">Test Sequence History</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span>&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <table class="help-table">
                    <tr>
                        <td colspan="2">
                            {{T "This shows a list of all versions of a test sequence" .}}.
                            {{T "Click on a row to view the details of the selected version" .}}.
                        </td>
                    </tr>
                </table>
                <span class="mt-3 float-left">{{T "For more information visit our" .}} <a href="http://docs.systemtestportal.org" target="_blank">{{T "documentation" .}}</a>.</span>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">{{T "Close" .}}</button>
            </div>
        </div>
    </div>
</div>
<div class="tab-card card" id="tabTestsequences" xmlns:15="http://www.w3.org/1999/xhtml">
    <nav class="navbar navbar-light action-bar p-3">
        <div class="input-group flex-nowrap">
            <button class="btn btn-secondary" id="buttonBackToSequence">
                <i class="fa fa-long-arrow-left" aria-hidden="true"></i>
                <span class="d-none d-sm-inline"> {{T "Back" .}}</span>
            </button>
        </div>
    </nav>
    <div class="row tab-side-bar-row">
        <div class="col-12 p-3">
            <h4 class="mb-3">{{T "History of" .}} {{ .TestSequence.Name }}</h4>
            <div class="form-group">
                <ul class="list-group" id="commitHistory">
                    {{ range .TestSequence.SequenceVersions }}
                    <li class="list-group-item versionLine" id="{{ .VersionNr }}">
                        <div class="container">
                            <div class="row">
                                <div class="col-md-auto">
                                    <abbr title="Test Sequence Version">
                                                <span class="badge badge-primary mr-3">
                                                {{ .VersionNr }}
                                                </span>
                                    </abbr>
                                </div>
                                <div class="col">
                                    {{ if eq .Message "" }}
                                    <div class="text-muted">{{T "No commit message" .}}</div>
                                    {{ else }}
                                    {{ .Message }}
                                    {{ end }}
                                </div>
                                <div class="col-md-auto mr-4 mt-2 mt-md-0 mb-2 mb-md-0">
                                    {{ if eq .IsMinor true }}
                                    <span class="badge badge-info float-none float-md-right"><abbr
                                            title="{{T "This was a minor edit" .}}">{{T "Minor" .}}</abbr>
                                            </span>
                                    {{ end }}
                                </div>
                                <div class="col-md-auto">
                                    <abbr title="{{ .CreationDate.Format " Jan 02, 2006 15:04:05 UTC" }}">
                                    <span class="text-muted"><time class="timeago" datetime="">{{ .CreationDate }}</time></span>
                                    </abbr>
                                </div>
                            </div>
                        </div>
                    </li>
                    {{ end }}
                </ul>
            </div>
        </div>
    </div>
</div>

<!-- Import Scripts here -->
<script src="/static/js/project/testsequences.js" integrity="{{sha256 "/static/js/project/testsequences.js"}}"></script>

<script>
    assignButtonsTestSequence();

    $('.timeago').each(function(i, obj) {
        var timeString = $(this).text();
        timeString = timeString.replace(" ", 'T');
        timeString = timeString.replace(" ", '');
        timeString = timeString.replace(" CET", '');
        $(this).text(timeString);
        $(this).attr("datetime", timeString);
    });
    jQuery("time.timeago").timeago();
</script>
{{ end }}