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

Commit

Permalink
ui/deployments: add deploymentsByGeneration
Browse files Browse the repository at this point in the history
  • Loading branch information
jgwhite committed May 27, 2021
1 parent 3cff756 commit 19de853
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
24 changes: 24 additions & 0 deletions ui/app/controllers/workspace/projects/project/app/deployments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,32 @@ export default class WorkspaceProjectsProjectAppDeployments extends Controller {
}
}

get deploymentsByGeneration(): GenerationGroup[] {
let result: GenerationGroup[] = [];

for (let deployment of this.deployments) {
let id = deployment.generation?.id ?? deployment.id;
let group = result.find((group) => group.generationID === id);

if (!group) {
group = new GenerationGroup(id);
result.push(group);
}

group.deployments.push(deployment);
}

return result;
}

@action
showDestroyed(): void {
this.destroyed = true;
}
}

class GenerationGroup {
deployments: Deployment.AsObject[] = [];

constructor(public generationID: string) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
</h3>

<ul data-test-deployment-list=true class="list">
{{#each this.deployments as |deployment|}}
<AppItem::Deployment @deployment={{deployment}} />
{{#each this.deploymentsByGeneration as |group|}}
{{#each group.deployments as |deployment|}}
<AppItem::Deployment @deployment={{deployment}} />
{{/each}}
{{else}}
<EmptyState>
<p>There are no deployments to display for this app yet</p>
Expand Down

0 comments on commit 19de853

Please sign in to comment.