<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
-->

<div class="catalog-details">

    <div class="float-right">
      <% if (model.get("catalog") && model.get("catalog").planYaml) { %>
        <button data-name="<%- model.getIdentifierName() %>" class="btn composer"
            title="Open this blueprint in the Composer where the YAML can be edited and deployed.">YAML Composer</button>
        <button data-name="<%- model.getIdentifierName() %>" class="btn btn-danger delete">Delete</button>
      <% } else { %>
        <button class="btn composer" disabled
            title="This item is defined in properties and cannot be edited.">YAML Composer</button>
        <button class="btn btn-danger delete" disabled
            title="This item is defined in properties and cannot be deleted.">Delete</button>
      <% } %>
    </div>

    <% if (model.get("name") != model.getPrettyName()) { %>
        <h2><%- model.getPrettyName() %></h2>
        <p><%- model.get("name") %></p>
    <% } else { %>
        <h2><%- model.get("name") %></h2>
    <% } %>
    <% if (model.get("description")) { %>
        <p><%- model.get("description") %></p>
    <% } %>

    <br/>
    
    <table>
        <tr><td><strong>Implementation Spec:</strong>&nbsp;&nbsp;</td><td><%- model.get("spec") || "" %></td></tr>
        <tr><td><strong>Internal ID:</strong>&nbsp;&nbsp;</td><td><%- model.get("id") || "" %></td></tr>
    </table>
    
    <br/>
    
<% if (model.get("catalog") && model.get("catalog").planYaml) { %>

    <textarea rows="15" readonly><%- model.get("catalog").planYaml %></textarea>
      
<% } else if (!model.get("config") || _.isEmpty(model.get("config"))) { %>
    <p>
    <i>No configuration is defined explicitly on this item. All config is inherited or defined in properties.</i>
    <p>
    <i>This item is not editable.</i>
<% } else { %>

    <table class="table table-striped table-condensed nonDatatables">
        <thead><tr>
            <th>Configuration Key</th>
            <th>Value</th>
        </tr></thead>
        <tbody>
        <% _.each(model.get("config"), function(value, key) { %>
        <tr>
            <td style="border-left:none; width:50%;"><%- key%></td>
            <td><%- value%></td>
        </tr>
        <% }); %>
        </tbody>
    </table>
    
    <p>
    <i>Additional configuration may be inherited or defined in properties.</i>
    <p>
    <i>This item is not editable.</i>
<% } %>

</div>
