{{!
  Copyright (c) HashiCorp, Inc.
  SPDX-License-Identifier: BUSL-1.1
~}}

<Hds::Table @caption="Known Secondaries" data-test-known-secondaries-table>
  <:head as |H|>
    <H.Tr>
      <H.Th>Secondary ID</H.Th>
      <H.Th>URL</H.Th>
      <H.Th>Connected?</H.Th>
    </H.Tr>
  </:head>
  <:body as |B|>
    {{#each this.secondaries as |secondary|}}
      <B.Tr>
        <B.Th data-test-secondaries-node={{or secondary.node_id secondary}}>{{secondary.node_id}}</B.Th>
        <B.Td data-test-secondaries-api-address={{or secondary.node_id secondary}}>
          {{#if secondary.api_address}}
            <Hds::Link::Standalone
              @icon="external-link"
              @text={{secondary.api_address}}
              @href={{concat secondary.api_address "/ui/"}}
              @iconPosition="trailing"
            />
          {{else}}
            <p class="has-text-grey">URL unavailable</p>
          {{/if}}
        </B.Td>
        <B.Td>
          <code data-test-secondaries-connection-status={{or secondary.node_id secondary}}>
            {{secondary.connection_status}}
          </code>
        </B.Td>
      </B.Tr>
    {{/each}}
  </:body>
</Hds::Table>