Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Commit

Permalink
ui: build and release tabs tables view (#2852)
Browse files Browse the repository at this point in the history
* ui: initial build/release tables

* ui: added tests for build and release tables and table row component

* ui: added changelog

* ui: updated tests and cleaned up styling of table views

* ui: added link to deployments column
  • Loading branch information
sabrinako authored Jan 10, 2022
1 parent b99c6fe commit 52b404c
Show file tree
Hide file tree
Showing 14 changed files with 418 additions and 153 deletions.
4 changes: 4 additions & 0 deletions .changelog/2852.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
```release-note:feature
ui: Update UI of builds and releases tab
```

88 changes: 66 additions & 22 deletions ui/app/components/app-item/build.hbs
Original file line number Diff line number Diff line change
@@ -1,24 +1,68 @@
<li class="app-item" data-test-app-item-build>
<LinkTo @route="workspace.projects.project.app.build" @models={{array @build.sequence}}>
<b class="badge badge--version">v{{@build.sequence}}</b>
<small class="app-item__meta__secondary">
{{#let (or @build.pushedArtifact @build) as |operation|}}
<OperationStatusIndicator::Build @operation={{operation}} @isDetailed={{true}}/>
{{/let}}
</small>
</LinkTo>

{{#if (and (eq @build.status.state 2) (eq @build.pushedArtifact.status.state 2))}}
<b class="badge badge--info">
<FlightIcon @name="clock" class="icon" />
<span>
{{t "app_item_build.built_in"
duration=(date-format-distance
@build.status.startTime.seconds
@build.status.completeTime.seconds
)
<tr>
<th data-test-id-column scope="row" class="table__id-column">
<LinkTo title={{ concat (t "page.build.title") " v" @build.sequence}}
@route="workspace.projects.project.app.build"
@models={{array @build.sequence}}
>
<b data-test-version-badge class="badge badge--version">v{{@build.sequence}}</b>
{{@build.id}}
</LinkTo>
</th>
{{#let (or @build.pushedArtifact @build) as |operation|}}
<td>
<span data-test-status class="table__icon-text-cell-span">
{{#if operation.status}}
<FlightIcon
data-test-status-icon
@name={{or
(and (eq operation.status.state 1) "delay")
(and (eq operation.status.state 2) "check-circle")
(and (eq operation.status.state 3) "x-circle")
(and (eq operation.status.state 0) "delay")
}}
@size="16"
/>
{{t
(concat
"app_item_build.status"
".state-" operation.status.state
)
}}
{{else}}
<FlightIcon
data-test-status-icon
@name="x-circle"
@size="16"
/>
{{t "app_item_build.status.state-unavailable"}}
{{/if}}
</span>
</td>
<td data-test-matching-deployment class="table__deployment-info-cell">
{{!-- TODO: add popover here --}}
{{#if @matchingDeployment}}
<LinkTo
title={{concat (t "page.deployment.title") " v" @matchingDeployment}}
@route="workspace.projects.project.app.deployment.deployment-seq"
@models={{array @matchingDeployment}}
>
Deployment <b class="badge badge--version">v{{@matchingDeployment}}</b>
</LinkTo>
{{else}}
{{t
"app_item_build.not_deployed"
}}
{{/if}}
</td>
<td data-test-provider>
<span class="table__icon-text-cell-span">
<FlightIcon
data-test-icon-type={{icon-for-component operation.component.name}}
@name={{icon-for-component operation.component.name}}
@size="16"
/>
{{component-name operation.component.name}}
</span>
</b>
{{/if}}
</li>
</td>
{{/let}}
</tr>
94 changes: 69 additions & 25 deletions ui/app/components/app-item/release.hbs
Original file line number Diff line number Diff line change
@@ -1,25 +1,69 @@
<li class="app-item">
<LinkTo @route="workspace.projects.project.app.release" @models={{array @release.sequence}}>
<p>
<b class="badge badge--version">v{{@release.sequence}}</b>
</p>
<small class="app-item__meta__secondary">
<OperationStatusIndicator::Release @operation={{@release}} />
</small>
</LinkTo>

{{#if (and (not-eq @release.state 4) @release.statusReport)}}
<small>
<StatusReportIndicator @statusReport={{@release.statusReport}} />
</small>
{{/if}}

{{#if (and @isLatest @release.url)}}
<ExternalLink
href={{enforce-protocol @release.url}}
class="button button--primary button--external-link">
<span>{{@release.url}}</span>
<FlightIcon @name="external-link" class="icon" />
</ExternalLink>
{{/if}}
</li>
<tr>
<th data-test-id-column scope="row" class="table__id-column">
<LinkTo
title={{ concat (t "page.release.title") " v" @build.sequence}}
@route="workspace.projects.project.app.release"
@models={{array @release.sequence}}
>
<b data-test-version-badge class="badge badge--version">v{{@release.sequence}}</b>
{{@release.id}}
</LinkTo>
</th>
{{#let (or @release.pushedArtifact @release) as |operation|}}
<td>
<span data-test-status class="table__icon-text-cell-span">
{{#if operation.status}}
<FlightIcon
data-test-status-icon
@name={{or
(and (eq operation.status.state 1) "delay")
(and (eq operation.status.state 2) "check-circle")
(and (eq operation.status.state 3) "x-circle")
(and (eq operation.status.state 0) "delay")
}}
@size="16"
/>
{{t
(concat
"app_item_release.status"
".state-" operation.status.state
)
}}
{{else}}
<FlightIcon
data-test-status-icon
@name="x-circle"
@size="16"
/>
{{t "app_item_release.status.state-unavailable"}}
{{/if}}
</span>
</td>
<td data-test-matching-deployment>
{{!-- TODO: add popover here --}}
{{#if @matchingDeployment}}
<LinkTo
title={{concat (t "page.deployment.title") " v" @matchingDeployment}}
@route="workspace.projects.project.app.deployment.deployment-seq"
@models={{array @matchingDeployment}}
>
Deployment <b class="badge badge--version">v{{@matchingDeployment}}</b>
</LinkTo>
{{else}}
{{t
"app_item_build.not_deployed"
}}
{{/if}}
</td>
<td data-test-provider>
<span class="table__icon-text-cell-span">
<FlightIcon
data-test-icon-type={{icon-for-component operation.component.name}}
@name={{icon-for-component operation.component.name}}
@size="16"
/>
{{component-name operation.component.name}}
</span>
</td>
{{/let}}
</tr>
24 changes: 22 additions & 2 deletions ui/app/routes/workspace/projects/project/app/builds.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,31 @@
import Route from '@ember/routing/route';
import { Model as AppRouteModel } from '../app';

type Model = AppRouteModel['builds'];
type Model = {
builds: AppRouteModel['builds'];
buildDeploymentPairs: Record<number, number>;
};

export default class Builds extends Route {
async model(): Promise<Model> {
let app = this.modelFor('workspace.projects.project.app') as AppRouteModel;
return app.builds;
let bdPairs = {};
for (let build of app.builds) {
let matchingDeployment = app.deployments.find((obj) => {
if (obj.preload && obj.preload.artifact) {
return obj.preload.artifact.id === build.pushedArtifact?.id;
}
return obj.artifactId === build.pushedArtifact?.id;
});

if (matchingDeployment) {
bdPairs[build.sequence] = matchingDeployment.sequence;
}
}

return {
builds: app.builds,
buildDeploymentPairs: bdPairs,
};
}
}
18 changes: 16 additions & 2 deletions ui/app/routes/workspace/projects/project/app/releases.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
import Route from '@ember/routing/route';
import { Model as AppRouteModel } from '../app';

type Model = AppRouteModel['releases'];
type Model = {
releases: AppRouteModel['releases'];
releaseDeploymentPairs: Record<number, number>;
};

export default class Releases extends Route {
async model(): Promise<Model> {
let app = this.modelFor('workspace.projects.project.app') as AppRouteModel;
return app.releases;
let rdPairs = {};
for (let release of app.releases) {
let matchingDeployment = app.deployments.find((obj) => obj.id === release?.deploymentId);
if (matchingDeployment) {
rdPairs[release.sequence] = matchingDeployment.sequence;
}
}

return {
releases: app.releases,
releaseDeploymentPairs: rdPairs,
};
}
}
29 changes: 29 additions & 0 deletions ui/app/styles/components/table.scss
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,35 @@
}
}

&__icon-text-cell-span {
display: inline-flex;
align-items: flex-end;
height: inherit;
margin-top: 1px;

svg {
margin-right: scale.$sm-3;
}
}

&__deployment-info-cell {
> .pds-button {
height: 1%;
padding: scale.$sm-4 scale.$sm-2;
}
}

&__id-column {
a {
display: block;
width: 100%;
height: 100%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}

.w-1\/2 {
width: 50%;
}
Expand Down
49 changes: 32 additions & 17 deletions ui/app/templates/workspace/projects/project/app/builds.hbs
Original file line number Diff line number Diff line change
@@ -1,20 +1,35 @@
{{page-title (concat @model.application.application "Builds")}}

<h2 class="list-heading">{{t "page.builds.title"}}</h2>

<ul data-test-build-list class="list">
{{#each @model key="id" as |build|}}
<AppItem::Build @build={{build}} />
{{else}}
<EmptyState>
<p>There are no builds to display for this app yet</p>
<p>To create your first build, you can run
<CopyableCode @ref="empty-build" @inline="true">
<code id="empty-build">waypoint build</code>
</CopyableCode>
from the CLI</p>
</EmptyState>
{{/each}}
</ul>
{{#if @model.builds}}
<Table class="table--artifact-list">
<colgroup>
<col class="w-2/5">
<col class="w-1/5">
<col class="w-1/5">
<col class="w-1/5">
</colgroup>
<thead>
<tr>
<th>{{t 'page.builds.table.row-header'}}</th>
<th>{{t 'page.builds.table.status'}}</th>
<th>{{t 'page.builds.table.deployment'}}</th>
<th>{{t 'page.builds.table.provider'}}</th>
</tr>
</thead>
<tbody data-test-build-list>
{{#each @model.builds key="id" as |build|}}
<AppItem::Build @build={{build}} @matchingDeployment={{get @model.buildDeploymentPairs build.sequence}} />
{{/each}}
</tbody>
</Table>
{{else}}
<EmptyState>
<p>{{t 'page.builds.table.empty-state.line-1'}}</p>
<p>{{t 'page.builds.table.empty-state.line-2'}}
<CopyableCode @ref="empty-build" @inline="true">
<code id="empty-build">waypoint build</code>
</CopyableCode>
{{t 'page.builds.table.empty-state.line-3'}}</p>
</EmptyState>
{{/if}}

{{outlet}}
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@
<tr>
<th scope="row">{{t "page.artifact.overview.status"}}</th>
<td>
<Pds::Icon @type={{icon-for-component @model.component.name}} class="icon" />
<span>Deployed by <b>{{component-name @model.component.name}}</b>
{{date-format-distance-to-now @model.status.startTime.seconds }}
</span>
<OperationStatusIndicator::Deployment @operation={{@model}} />
</td>
</tr>
</StatusReportMetaTable>
Expand Down
Loading

0 comments on commit 52b404c

Please sign in to comment.