<%!
    title = 'User interface'
%>
<%namespace name="lib" file="//lib.html" import="*"/>
<%inherit file="//layout/admin.html" />
<%
import splunk
from splunk.appserver.mrsparkle.lib import util, i18n
import splunk.entity as en
%>

<%def name="addNewLink(pathList)">
    <%
        entities = en.getEntities('/'.join(pathList), namespace=namespace)
        try:
            hasCreateLink = filter((lambda x: x[0] == 'create'), entities.links)
        except:
            hasCreateLink = False

        newPath = ''
        if hasCreateLink:
            newPath = make_url(['manager', namespace] + pathList + ['_new'], _qs=dict(action='edit'))
    %>
    
    % if hasCreateLink:
        <a href="${newPath}">${_('Add new')}</a>
    % endif
</%def>

<div class="dataInputsWrapper">
    <div class="dataInputsDesc">${_('Create and edit views, dashboards, and navigation menus.')}</div>

    <table class="splTable">
            <tr>
                <th>${_('')}</th>
                <th>${_('Actions')}</th>
            </tr>
            % if not util.isLite():
            <tr>
                <td class="input_name"><a href="${make_url(['manager', namespace, 'data', 'ui', 'times'])}">${_('Time ranges')}</a></td>
                <td><a href="${make_url(['manager', namespace, 'data', 'ui', 'times', '_new'], _qs=dict(action='edit'))}">${_('Add new')}</a></td>
            </tr>
            <tr>
                <td class="input_name"><a href="${make_url(['manager', namespace, 'data', 'ui', 'views'])}">${_('Views')}</a></td>
                <td><a href="${make_url(['manager', namespace, 'data', 'ui', 'views', '_new'], _qs=dict(action='edit'))}">${_('Add new')}</a></td>
            </tr>
            <tr>
                <td class="input_name"><a href="${make_url(['manager', namespace, 'scheduled', 'views'])}">${_('View PDF scheduling')}</a></td>
                <td></td>
            </tr>
            <tr>
                <td class="input_name"><a href="${make_url(['manager', namespace, 'data', 'ui', 'nav'])}">${_('Navigation menus')}</a></td>
                <td></td>
            </tr>
            <tr>
                <td class="input_name"><a href="${make_url(['manager', namespace, 'data', 'ui', 'panels'])}">${_('Prebuilt panels')}</a></td>
                <td><a href="${make_url(['manager', namespace, 'data', 'ui', 'panels', '_new'], _qs=dict(action='edit'))}">${_('Add new')}</a></td>
            </tr>
           % endif
           <tr>
                <td class="input_name"><a href="${make_url(['manager', namespace, 'messages'])}">${_('Bulletin messages')}</a></td>
                <td><%call expr="addNewLink(['messages'])"/></td>
           </tr>

    </table>
</div>
