diff --git a/.changelog/2777.txt b/.changelog/2777.txt new file mode 100644 index 00000000000..4444989956c --- /dev/null +++ b/.changelog/2777.txt @@ -0,0 +1,3 @@ +```release-note:feature +ui: Added a tab with an overview of the resources provisioned by operations +``` diff --git a/ui/app/components/resources-table-extended.hbs b/ui/app/components/resources-table-extended.hbs new file mode 100644 index 00000000000..391cc500b6d --- /dev/null +++ b/ui/app/components/resources-table-extended.hbs @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + {{#each @resources key="resource.id" as |resourceObject|}} + {{#let resourceObject.resource as |resource|}} + + + + + + + + {{/let}} + {{/each}} + +
{{yield to="caption"}}
{{t "page.resources.table.headings.name"}}{{t "page.resources.table.headings.type"}}{{t "page.resources.table.headings.age"}}{{t "page.resources.table.headings.status"}}{{t "page.resources.table.headings.provisioned-by"}}
+ + {{resource.name}} + + {{resource.type}}{{date-format-distance-to-now resource.createdTime.seconds}} + {{#if (eq resourceObject.type 'deployment')}} + + {{t "page.resources.table.deployment"}} v{{resourceObject.source.sequence}} + + {{/if}} + {{#if (eq resourceObject.type 'release')}} + + {{t "page.resources.table.release"}}v{{resourceObject.source.sequence}} + + {{/if}} +
diff --git a/ui/app/components/resources-table.hbs b/ui/app/components/resources-table.hbs index fc2ee0e1667..6b970c8eaa4 100644 --- a/ui/app/components/resources-table.hbs +++ b/ui/app/components/resources-table.hbs @@ -13,10 +13,10 @@ - Name - Type - Age - Status + {{t "page.resources.table.headings.name"}} + {{t "page.resources.table.headings.type"}} + {{t "page.resources.table.headings.age"}} + {{t "page.resources.table.headings.status"}} diff --git a/ui/app/router.js b/ui/app/router.js index 51e0800e521..a99d2cc4ad6 100644 --- a/ui/app/router.js +++ b/ui/app/router.js @@ -58,6 +58,7 @@ Router.map(function () { this.route('resource', { path: 'resources/:resource_id' }); }); this.route('logs'); + this.route('resources'); this.route('exec'); this.route('deployments'); }); diff --git a/ui/app/routes/workspace/projects/project/app/resources.ts b/ui/app/routes/workspace/projects/project/app/resources.ts new file mode 100644 index 00000000000..3648421a963 --- /dev/null +++ b/ui/app/routes/workspace/projects/project/app/resources.ts @@ -0,0 +1,44 @@ +import { DeploymentExtended, ReleaseExtended } from 'waypoint/services/api'; + +import { Model as AppRouteModel } from '../app'; +import Route from '@ember/routing/route'; +import { StatusReport } from 'waypoint-pb'; + +type Model = ResourceMap[]; + +interface ResourceMap { + resource: StatusReport.Resource.AsObject; + type: string; + source: DeploymentExtended | ReleaseExtended; +} +export default class Resources extends Route { + async model(): Promise { + let app = this.modelFor('workspace.projects.project.app') as AppRouteModel; + + let deployments = app.deployments; + let releases = app.releases; + + let resources: ResourceMap[] = []; + + deployments.forEach((dep) => { + dep.statusReport?.resourcesList.forEach((resource) => { + resources.push({ + resource, + type: 'deployment', + source: dep, + } as ResourceMap); + }); + }); + releases.forEach((rel) => { + rel.statusReport?.resourcesList.forEach((resource) => { + resources.push({ + resource, + type: 'release', + source: rel, + } as ResourceMap); + }); + }); + + return resources; + } +} diff --git a/ui/app/templates/workspace/projects/project/app.hbs b/ui/app/templates/workspace/projects/project/app.hbs index 401ea36dda9..03bcc3a0bea 100644 --- a/ui/app/templates/workspace/projects/project/app.hbs +++ b/ui/app/templates/workspace/projects/project/app.hbs @@ -68,6 +68,11 @@ {{t "nav.logs"}} + + + {{t "nav.resources"}} + diff --git a/ui/app/templates/workspace/projects/project/app/resources.hbs b/ui/app/templates/workspace/projects/project/app/resources.hbs new file mode 100644 index 00000000000..c1fa1fabdb3 --- /dev/null +++ b/ui/app/templates/workspace/projects/project/app/resources.hbs @@ -0,0 +1,14 @@ +{{#if @model.length}} + +{{else}} + +

{{t 'page.resources.table.empty-state.line-1'}}

+

{{t 'page.resources.table.empty-state.line-2'}} + + waypoint up + + {{t 'page.resources.table.empty-state.line-3'}}

+
+{{/if}} diff --git a/ui/translations/en-us.yaml b/ui/translations/en-us.yaml index 26ff6711975..6b4f4b97390 100644 --- a/ui/translations/en-us.yaml +++ b/ui/translations/en-us.yaml @@ -11,6 +11,7 @@ nav: exec: 'Exec' settings: 'Settings' logs: 'Logs' + resources: 'Resources' auth: 'Authenticate' product: @@ -79,7 +80,20 @@ page: line-1: 'There are no releases to display for this app yet' line-2: 'To create your first release, you can run' line-3: 'from the CLI' - release: + resources: + table: + headings: + name: 'Name' + type: 'Type' + age: 'Age' + status: 'Status' + provisioned-by: 'Provisioned by' + empty-state: + line-1: 'There are no resources to display for this app yet' + line-2: 'To create your first release, you can run' + line-3: 'from the CLI' + release: 'Release' + deployment: 'Deployment' title: 'Release' resources: heading: Resources