{{page-title "Projects"}}

{{#if this.cli}}
<div class="flash flash--success">
  <div class="flash-header">
    <FlightIcon @name="check-circle-fill" class="icon" />
    <p>Authenticated successfully via the Waypoint CLI</p>
  </div>
</div>
{{/if}}

<PageHeader @className="projects-header">
  <div class="title">
    <h1>Projects</h1>
    <small>
      {{#if @model.length}}
      {{pluralize @model.length "project"}}
      {{else}}
      No projects created yet
      {{/if}}
    </small>
  </div>
  <Pds::CtaLink @route="workspace.projects.create" @variant="secondary "class="pds--iconStart">
    <FlightIcon @name="plus" class="pds-button__iconStart"/>
    &nbsp;{{t "form.project_create.title"}}
  </Pds::CtaLink>
</PageHeader>

<Hds::Alert class='deprecation-banner' @type='inline' @color='neutral' @icon='info' as |A|>
  <A.Title>
    {{t 'page.project.deprecation-banner.title'}}
  </A.Title>
  <A.Description>
    <div class='deprecation-description'>
      {{t 'page.project.deprecation-banner.description'}}
      <div>
        <Hds::Link::Standalone
          @icon='external-link'
          @iconPosition='trailing'
          @text={{
            t 'page.project.deprecation-banner.link'
          }}
          @href='https://discuss.hashicorp.com/t/deprecating-projects-or-how-i-learned-to-love-apps/40888'
        />
      </div>
    </div>
  </A.Description>
</Hds::Alert>

<div data-test-project-list>
  {{#each @model as |project|}}
  <Card>
    <LinkTo @route="workspace.projects.project" @model={{project.project}}>
      <div class="row">
        <Hds::IconTile @icon="folder" />
        <div class="meta">
          <h2>{{project.project}}</h2>
          {{!-- todo(pearkes): get full project objects from list api --}}
          {{!-- <small>{{pluralize project.applicationsList.length "application"}}</small> --}}
        </div>
      </div>
    </LinkTo>
  </Card>
  {{else}}
  <EmptyState>
    <p>There are no projects to display yet. <LinkTo @route="workspace.projects.create">Create your first project here</LinkTo>.</p>
    <p>Alternatively, you can run
      <CopyableCode @ref="empty-init" @inline="true">
        <code id="empty-init">waypoint init</code>
      </CopyableCode>
      from the CLI</p>
    <p>For more help getting started, refer to the <ExternalLink href="https://waypointproject.io/docs/getting-started">Waypoint documentation</ExternalLink></p>
  </EmptyState>
  {{/each}}
</div>
