{{#if redirectedReason}}
  <div class="alert alert-info">{{redirectedReason}}</div>
{{/if}}

{{#if showDismissAtTop}}
  <div class="row">
    {{#if showDismissRead}}
      <button title="{{i18n topics.bulk.dismiss_topics_tooltip}}" id='dismiss-topics-top' class='btn dismiss-read' {{action "dismissRead" "topics"}}>{{i18n topics.bulk.dismiss_topics}}</button>
      <button title="{{i18n topics.bulk.dismiss_posts_tooltip}}" id='dismiss-posts-top' class='btn dismiss-read' {{action "dismissRead" "posts"}}>{{i18n topics.bulk.dismiss_posts}}</button>
    {{/if}}
    {{#if showResetNew}}
      <button id='dismiss-new-top' class='btn dismiss-read' {{action "resetNew"}}>{{i18n topics.bulk.dismiss_new}}</button>
    {{/if}}
  </div>
{{/if}}

{{#if selected}}
  <div id='bulk-select'>
    <button class='btn no-text' {{action "showBulkActions"}}><i class="fa fa-wrench"></i></button>
  </div>
{{/if}}

<div class='contents'>
  {{#if top}}
    <div class='top-lists'>
      {{top-period-chooser period=period}}
    </div>
  {{/if}}
  {{#if showTable}}
    <table class='topic-list'>
      <thead>
      <tr>
        {{#if currentUser}}
        <th class='star'>
          {{#if canBulkSelect}}
          <button class='btn bulk-select' {{action "toggleBulkSelect"}} title="{{i18n topics.bulk.toggle}}"><i class='fa fa-list'></i></button>
          {{/if}}
        </th>
        {{/if}}
        {{#sortable-heading class="default"}} {{i18n topic.title}} {{/sortable-heading}}
        {{#unless controller.hideCategory}}
          {{#sortable-heading sortBy="category" action="changeSort" order=order ascending=ascending}}
            {{i18n category_title}}
          {{/sortable-heading}}
        {{/unless}}
        {{#sortable-heading class="posters"}} {{i18n users}} {{/sortable-heading}}
        {{#sortable-heading sortBy="posts" number=true action="changeSort" order=order ascending=ascending}}
          {{i18n posts}}
        {{/sortable-heading}}
        {{#sortable-heading sortBy="views" number=true action="changeSort" order=order ascending=ascending}}
          {{i18n views}}
        {{/sortable-heading}}
        {{#sortable-heading sortBy="activity" number=true action="changeSort" order=order ascending=ascending}}
          {{i18n activity}}
        {{/sortable-heading}}
      </tr>
      </thead>

      {{#if topicTrackingState.hasIncoming}}
        <tbody>
          <tr>
            <td colspan="9">
              <div class='alert alert-info clickable' {{action "showInserted"}}>
                {{countI18n topic_count_ suffix=topicTrackingState.filter count=topicTrackingState.incomingCount}}
                {{i18n click_to_show}}
              </div>
            </td>
          </tr>
        </tbody>
      {{/if}}

      <tbody>
        {{each topics itemController="topic-list-item" itemView="topic-list-item"}}
      </tbody>

    </table>
  {{/if}}
</div>

<footer class='topic-list-bottom'>
  {{#if loadingMore}}
    <div class='topics-loading'></div>
  {{/if}}
  {{#if allLoaded}}
    {{#if showDismissRead}}
      <button title="{{i18n topics.bulk.dismiss_topics_tooltip}}" id='dismiss-topics' class='btn dismiss-read' {{action "dismissRead" "topics"}}>{{i18n topics.bulk.dismiss_topics}}</button>
      <button title="{{i18n topics.bulk.dismiss_posts_tooltip}}" id='dismiss-posts' class='btn dismiss-read' {{action "dismissRead" "posts"}}>{{i18n topics.bulk.dismiss_posts}}</button>
    {{/if}}
    {{#if showResetNew}}
      <button id='dismiss-new' class='btn dismiss-read' {{action "resetNew"}}>{{i18n topics.bulk.dismiss_new}}</button>
    {{/if}}

    {{#if latest}}
      <div class="education">
        {{{footerEducation}}}
      </div>
      <h3>
        {{footerMessage}}
        {{#if can_create_topic}}<a href='#' {{action "createTopic"}}>{{i18n topic.suggest_create_topic}}</a>{{/if}}
      </h3>
    {{else}}
      {{#if top}}
        <h3>
          {{#link-to "discovery.categories"}}{{i18n topic.browse_all_categories}}{{/link-to}}, {{#link-to 'discovery.latest'}}{{i18n topic.view_latest_topics}}{{/link-to}} {{i18n or}} {{i18n filters.top.other_periods}}
        {{top-period-buttons period=period}}
        </h3>
      {{else}}
        <div class="education">
            {{{footerEducation}}}
        </div>
        <h3>
          {{footerMessage}}{{#link-to "discovery.categories"}} {{i18n topic.browse_all_categories}}{{/link-to}} {{i18n or}} {{#link-to 'discovery.latest'}}{{i18n topic.view_latest_topics}}{{/link-to}}
        </h3>
      {{/if}}
    {{/if}}
  {{/if}}
</footer>
