{{!
* 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="accordion-heading" {{action "onToggleBlock" category target="view"}}>
  <i {{bindAttr class=":pull-left :accordion-toggle view.category.isCollapsed:icon-caret-right:icon-caret-down"}}></i>
  <a class="accordion-toggle">{{view.category.displayName}}</a>
</div>

<div class="accordion-body collapse in" {{bindAttr style="view.isCategoryBodyVisible"}}>
  <div class="accordion-inner service-config-section">
    <form class="form-horizontal" autocomplete="off">

      {{#each view.categoryConfigs}}
        <div {{bindAttr class=":entry-row isHiddenByFilter:hide isOverridden:overridden-property hasCompareDiffs:overridden-property"}}>
          {{#if showLabel}}
            <span {{bindAttr class="errorMessage:error: :control-group :control-label-span"}}>
              <label class="control-label">
                {{formatWordBreak displayName}}
                {{#if isSecureConfig}}
                  <a href="javascript:void(null);"><i class="icon-lock" rel="tooltip" data-toggle="tooltip"
                                                      title="security knob"></i></a>
                {{/if}}
                {{#if view.supportsHostOverrides}}
                  {{#if isRestartRequired}}
                    <i class="icon-refresh restart-required-property"
                       rel="tooltip" {{bindAttr title="restartRequiredMessage"}}></i>
                  {{/if}}
                {{/if}}
              </label>
            </span>
          {{/if}}
          <div {{bindAttr class="showLabel:controls"}}>
            {{! Here serviceConfigBinding should ideally be serviceConfigPropertyBinding }}
            <div {{bindAttr class="errorMessage:error: warnMessage:warning: :control-group"}}>
              {{view viewClass serviceConfigBinding="this" categoryConfigsAllBinding="view.categoryConfigsAll" }}
              {{#if this.isComparison}}
                {{#if controller.selectedConfigGroup.isDefault}}
                  <span class="label label-info">{{t dashboard.configHistory.table.version.prefix}}{{controller.selectedVersion}}</span>
                  {{#if controller.isCurrentSelected}}
                    <span class="label label-success">{{t common.current}}</span>
                  {{/if}}
                {{else}}
                  <span class="label label-info">{{t common.default}}&nbsp;{{t services.service.config.configHistory.configGroup}}</span>
                {{/if}}
              {{/if}}
              {{#if supportsFinal}}
                <a href="#" data-toggle="tooltip"
                  {{bindAttr class=":btn :btn-small :btn-final isFinal:active hideFinalIcon:hidden" disabled="isNotEditable"}}
                  {{action "toggleFinalFlag" this target="view"}}
                  {{translateAttr data-original-title="services.service.config.final"}}>
                  <i class="icon-lock"></i>
                </a>
              {{/if}}
              {{#if view.canEdit}}
                {{#if isPropertyOverridable}}
                  {{#if view.supportsHostOverrides}}
                    {{#isAccessible ADMIN}}
                      {{#unless this.isComparison}}
                          <a class="btn btn-small" href="#" data-toggle="tooltip"
                            {{action "createOverrideProperty" this target="view"}}
                            {{translateAttr data-original-title="common.override"}}>
                              <i class="icon-plus-sign"></i>
                          </a>
                      {{/unless}}
                    {{/isAccessible}}
                  {{/if}}
                {{/if}}
                {{#unless cantBeUndone}}
                  {{#if isNotDefaultValue}}
                    <a class="btn btn-small" href="#" data-toggle="tooltip"
                      {{action "doRestoreDefaultValue" this target="view"}}
                      {{translateAttr data-original-title="common.undo"}}>
                      <i class="icon-undo"></i>
                    </a>
                  {{/if}}
                {{/unless}}
                {{#if isRemovable}}
                  {{#isAccessible ADMIN}}
                    {{#unless this.isComparison}}
                        <a class="btn btn-small" href="#" data-toggle="tooltip"
                          {{action "removeProperty" this target="view"}}
                          {{translateAttr data-original-title="common.remove"}}>
                            <i class="icon-minus-sign"></i>
                        </a>
                    {{/unless}}
                  {{/isAccessible}}
                {{/if}}
                {{#unless isEditable}}
                  {{#if group}}
                    <a rel='SwitchGroupTooltip' {{bindAttr data-original-title="this.group.switchGroupTextShort"}} class="action" {{action selectConfigGroup group target="controller"}}>
                      {{group.switchGroupTextShort}}
                    </a>
                  {{/if}}
                {{/unless}}
              {{/if}}
              <span class="help-inline">{{errorMessage}}</span>
              <span class="help-inline">{{warnMessage}}</span>
            </div>
            {{#if this.isOverridden}}
              {{view App.ServiceConfigView.SCPOverriddenRowsView serviceConfigPropertyBinding="this" isDefaultGroupSelectedBinding="controller.selectedConfigGroup.isDefault"}}
            {{/if}}
            {{#if this.isComparison}}
              {{view App.ServiceConfigView.SCPComparisonRowsView serviceConfigPropertyBinding="this"}}
            {{/if}}
          </div>
        </div>
        {{#if this.additionalView}}
          {{view additionalView}}
        {{/if}}
      {{/each}}

      {{! For Advanced, Advanced Core Site, Advanced HDFS Site sections, show the 'Add Property' link.}}
      {{#isAccessible ADMIN}}
        {{#if view.canEdit}}
          {{#if view.category.customCanAddProperty }}
            <div>
              <a href="#" {{action "showAddPropertyWindow" this target="view" }} >{{t installer.step7.config.addProperty}}...</a>
            </div>
          {{/if}}
        {{/if}}
      {{/isAccessible}}
    </form>
  </div>
</div>
