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

Commit

Permalink
ui: updated the ui of list items on deployments tab
Browse files Browse the repository at this point in the history
  • Loading branch information
Sabrina Ko committed Jan 6, 2022
1 parent 8841437 commit cc02c91
Show file tree
Hide file tree
Showing 9 changed files with 170 additions and 59 deletions.
75 changes: 56 additions & 19 deletions ui/app/components/app-item/deployment.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,66 @@
<hr>
<LinkTo
data-test-deployment-list-item
title={{ concat
"v" @deployment.sequence ": "
(t (concat "page.deployments.status_prefix." @deployment.status.state))
(component-name @deployment.component.name)}}
title={{concat (t "page.deployment.title") " v" @deployment.sequence }}
@route="workspace.projects.project.app.deployment.deployment-seq"
@models={{array @deployment.sequence}}
>
<b class="badge badge--version">v{{@deployment.sequence}}</b>
<OperationStatusIndicator::Deployment @operation={{@deployment}}>
<:small-text>
{{#if (not-eq @latest.id @deployment.id)}}
<span class="replacement-info">
{{t "page.deployments.replaced_label"}}<b class="badge badge--version">v{{@latest.sequence}}</b>
<div class="app-item__deployment-state">
{{!-- ROW: status report + deployment url --}}
{{#if @deployment.statusReport.health}}
{{#let (hash
deploymentHealth=@deployment.statusReport.health.healthStatus
urlOrStatus=(or
(clean-up-url @deployment.preload.deployUrl)
(t (concat "status_report_indicator.label."
(downcase @deployment.statusReport.health.healthStatus))
)
)
) as |vars|}}
<span
data-test-health-status={{downcase vars.deploymentHealth}}
class="deploy-url__status deploy-url__status--{{downcase vars.deploymentHealth}}"
/>
<span class="deploy-url" title={{vars.urlOrStatus}}>
{{vars.urlOrStatus}}
</span>
{{/let}}
{{/if}}
{{!-- ROW: operation status --}}
{{#let @deployment.status as |status|}}
<FlightIcon
data-test-time-icon
@name={{or
(and (eq status.state 0) "help")
(and (eq status.state 1) "clock")
(and (eq status.state 2) "check")
(and (eq status.state 3) "alert-triangle")
}}
@size="16"
/>
<span data-test-operation-status>
{{t (concat "page.deployments.status_prefix." status.state)}}
{{#if (eq status.state 1)}} {{!-- RUNNING --}}
{{t "page.deployments.started_time_prefix"}} {{date-format-distance-to-now status.startTime.seconds}}
{{else}}
{{date-format-distance-to-now status.completeTime.seconds}}
{{/if}}
</span>
{{/if}}
</:small-text>
<:badge>
{{#if (eq @deployment.state 4)}}
<b data-test-destroyed-badge class="badge badge--destroyed">
<FlightIcon @name="trash" class="icon" />&nbsp; {{t "page.deployments.destroyed_label"}}
</b>
{{/if}}
</:badge>
</OperationStatusIndicator::Deployment>
{{/let}}
{{!-- ROW: git commit information --}}
{{#if @deployment.preload.jobDataSourceRef.git.commit}}
{{#let @deployment.preload.jobDataSourceRef.git.commit as |commit|}}
{{!-- TODO: change to if statement- if user profile picture available, use that. else use flight icon --}}
<FlightIcon @name="git-commit"/>
<span data-test-git-commit class="git-commit" title="Triggered by commit: {{commit}}">
<CopyButton @clipboardText={{commit}}>
<span class="git-commit__sha">{{truncate-commit commit}}</span>
</CopyButton>
{{!-- TODO: when commit message available, add to this --}}
</span>
{{/let}}
{{/if}}
</div>
</LinkTo>
</li>
11 changes: 0 additions & 11 deletions ui/app/components/operation-status-indicator/deployment.hbs

This file was deleted.

8 changes: 8 additions & 0 deletions ui/app/helpers/clean-up-url.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { helper } from '@ember/component/helper';

export function cleanUpUrl([str]: string[]) {
let cleanStr = str.replace('https://', '').replace('http://', '').replace('www.', '');
return cleanStr;
}

export default helper(cleanUpUrl);
1 change: 1 addition & 0 deletions ui/app/styles/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ $button-shadow: 0 3px 2px rgba(var(--shadow), 0.2);
--brand: #{dehex($brand-color)};
--background: #{dehex(color.$white)};
--text: #{dehex(color.$black)};
--text-deploy-url: #{dehex(color.$ui-gray-800)};
--text-muted: #{dehex(color.$ui-cool-gray-600)};
--text-subtle: #{dehex(color.$ui-cool-gray-400)};
--link: #{dehex(color.$blue-500)};
Expand Down
75 changes: 55 additions & 20 deletions ui/app/styles/components/app-item.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
margin-right: scale.$sm-2;
width: 100%;
border-radius: 5px;
@include Typography.Interface(M);

hr {
border: 0;
Expand Down Expand Up @@ -33,23 +34,10 @@
font-size: 1rem;
}

&.app-item--destroyed code {
color: rgb(var(--text-muted));
}

.badge--version {
margin-right: scale.$sm-2;
}

.badge--destroyed {
margin-left: auto;

@media (prefers-color-scheme: light) {
background: color.$ui-cool-gray-200;
color: color.$ui-cool-gray-800;
}
}

.button {
max-width: 100%;
margin-left: scale.$base;
Expand All @@ -61,13 +49,6 @@
}
}

.replacement-info {
@include Typography.Interface(S);
b {
text-transform: inherit;
}
}

.timestamp__label {
@include Typography.Interface(S);
}
Expand All @@ -76,6 +57,60 @@
background: rgb(var(--panel));
}

&__deployment-state {
display: grid;
align-items: center;
grid-template-columns: max-content 92%;
column-gap: scale.$sm--3;
row-gap: scale.$sm--3;

span {
width: 100%;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}

.deploy-url {
color: rgb(var(--text-deploy-url));

&__status {
width: scale.$sm--2;
height: scale.$sm--2;
border-radius: 50%;
background: color.$black;
justify-self: center;

&--alive {
background: color.$green-500;
animation: pulse 2s infinite;
@media (prefers-reduced-motion: reduce) {
animation: none;
}
}

&--ready {
background: color.$green-500;
}

&--down {
background: color.$red-500;
@media (prefers-color-scheme: dark) {
background: color.$red-400;
}
}

&--partial {
background: color.$orange-500;
}
}
}

.deployment-state {
color: rgb(var(--text-muted));
}
}

.operation-status-indicator {
display: inline-flex;
flex-direction: row;
Expand Down
1 change: 1 addition & 0 deletions ui/mirage/factories/deployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export default Factory.extend({
'common/vcs-ref-path': 'https://github.com/hashicorp/waypoint/commit/',
}),
gitCommitRef: '0d56a9f8456b088dd0e4a7b689b842876fd47352',
statusReport: association('alive'),

afterCreate(deployment) {
let url = `https://wildly-intent-honeybee--v${deployment.sequence}.waypoint.run`;
Expand Down
22 changes: 20 additions & 2 deletions ui/tests/acceptance/deployments-list-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,35 @@ const redirectUrl = '/default/microchip/app/wp-bandwidth/deployment/seq/'; // co

const page = create({
visit: visitable(url),
destroyedBadges: collection('[data-test-destroyed-badge]'),
showDestroyed: clickable('[data-test-display-destroyed-button]'),
linkList: collection('[data-test-deployment-list-item]'),
statusIndicators: collection('[data-test-health-status="alive"]'),
deployUrls: collection('.deploy-url'),
operationStatuses: collection('[data-test-operation-status]'),
gitCommits: collection('[data-test-git-commit]'),
});

module('Acceptance | deployments list', function (hooks) {
setupApplicationTest(hooks);
setupMirage(hooks);
setupSession(hooks);

test('happy path', async function (assert) {
let project = this.server.create('project', { name: 'microchip' });
let application = this.server.create('application', { name: 'wp-bandwidth', project });
this.server.createList('deployment', 4, 'random', { application });

await page.visit();

assert.equal(page.linkList.length, 4);
assert.equal(currentURL(), redirectUrl + '4');
assert.equal(page.statusIndicators.length, 4);
assert.equal(page.operationStatuses.length, 4);
assert.equal(page.gitCommits.length, 4);
// random list item url check
assert.equal(page.deployUrls[2].text, `wildly-intent-honeybee--v2.waypoint.run`);
});

test('visiting deployments page redirects to latest', async function (assert) {
let project = this.server.create('project', { name: 'microchip' });
let application = this.server.create('application', { name: 'wp-bandwidth', project });
Expand Down Expand Up @@ -107,6 +126,5 @@ module('Acceptance | deployments list', function (hooks) {
await page.showDestroyed();

assert.equal(page.linkList.length, 5);
assert.equal(page.destroyedBadges.length, 1);
});
});
24 changes: 24 additions & 0 deletions ui/tests/integration/helpers/clean-up-url-test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';

module('Integration | Helper | clean-up-url', function(hooks) {
setupRenderingTest(hooks);

test('it removes https:// from input', async function (assert) {
this.set('inputValue', 'https://wildly-intent-honeybee.waypoint.run');

await render(hbs`{{clean-up-url this.inputValue}}`);

assert.equal(this.element.textContent?.trim(), 'wildly-intent-honeybee.waypoint.run');
});

test('it removes http:// from input', async function (assert) {
this.set('inputValue', 'http://wildly-intent-honeybee.waypoint.run');

await render(hbs`{{clean-up-url this.inputValue}}`);

assert.equal(this.element.textContent?.trim(), 'wildly-intent-honeybee.waypoint.run');
});
});
12 changes: 5 additions & 7 deletions ui/translations/en-us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,13 @@ page:
heading: Build Logs
deployments:
title: 'Deployments'
destroyed_label: 'Destroyed'
replaced_label: 'Replaced by '
destroyed_and_hidden_state: 'Some deployments have been destroyed and are hidden'
display_destroyed: 'Show destroyed deployments'
started_time_prefix: 'started'
status_prefix:
0: 'Deploying by ' # UNKNOWN
1: 'Deploying by ' # RUNNING
2: 'Deployed by ' # SUCCESS
3: 'Failed to deploy by ' # ERROR
0: 'Deploying...' # UNKNOWN
1: 'Deploying...' # RUNNING
2: 'Deployed' # SUCCESS
3: 'Failed to deploy' # ERROR
deployment:
title: 'Deployment'
resources:
Expand Down

0 comments on commit cc02c91

Please sign in to comment.