-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update request for project related resources; Cleanup to match back-e…
…nd (#408) * Basic "clear type errors" commit * Mark todos; cleanup Mirage config * Add JiraIssue and HermesDocument * Cleanup * Fix v1 reference and related-resource URL * Update config.ts
- Loading branch information
Showing
12 changed files
with
92 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,30 @@ | ||
import Route from "@ember/routing/route"; | ||
import { inject as service } from "@ember/service"; | ||
import ConfigService from "hermes/services/config"; | ||
import FetchService from "hermes/services/fetch"; | ||
import { HermesProject } from "hermes/types/project"; | ||
|
||
export default class AuthenticatedProjectsIndexRoute extends Route { | ||
@service("fetch") declare fetchSvc: FetchService; | ||
@service("config") declare configSvc: ConfigService; | ||
|
||
async model(): Promise<Record<string, HermesProject>> { | ||
return await this.fetchSvc | ||
.fetch("/api/v1/projects") | ||
async model() { | ||
const projects = await this.fetchSvc | ||
.fetch(`/api/${this.configSvc.config.api_version}/projects`) | ||
.then((response) => response?.json()); | ||
|
||
return await Promise.all( | ||
projects.map(async (project: HermesProject) => { | ||
const resources = await this.fetchSvc | ||
.fetch( | ||
`/api/${this.configSvc.config.api_version}/projects/${project.id}/related-resources`, | ||
) | ||
.then((response) => response?.json()); | ||
|
||
const { hermesDocuments, externalLinks } = resources; | ||
|
||
return { ...project, hermesDocuments, externalLinks }; | ||
}), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,32 @@ | ||
import Route from "@ember/routing/route"; | ||
import { inject as service } from "@ember/service"; | ||
import ConfigService from "hermes/services/config"; | ||
import FetchService from "hermes/services/fetch"; | ||
import { HermesProject } from "hermes/types/project"; | ||
|
||
export default class AuthenticatedProjectsProjectRoute extends Route { | ||
@service("fetch") declare fetchSvc: FetchService; | ||
@service("config") declare configSvc: ConfigService; | ||
|
||
async model(params: { project_id: string }): Promise<HermesProject> { | ||
return await this.fetchSvc | ||
.fetch("/api/v1/projects/" + params.project_id) | ||
const project = await this.fetchSvc | ||
.fetch( | ||
`/api/${this.configSvc.config.api_version}/projects/${params.project_id}`, | ||
) | ||
.then((response) => response?.json()); | ||
|
||
const projectResources = await this.fetchSvc | ||
.fetch( | ||
`/api/${this.configSvc.config.api_version}/projects/${params.project_id}/related-resources`, | ||
) | ||
.then((response) => response?.json()); | ||
|
||
const { hermesDocuments, externalLinks } = projectResources; | ||
|
||
return { | ||
...project, | ||
hermesDocuments, | ||
externalLinks, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,25 +4,25 @@ import { HermesProject } from "hermes/types/project"; | |
export default Factory.extend({ | ||
id: (i: number) => i, | ||
title: (i: number) => `Test Project ${i}`, | ||
dateCreated: 1, | ||
dateModified: 1, | ||
createdDate: 1, | ||
modifiedDate: 1, | ||
creator: "[email protected]", | ||
status: "active", | ||
|
||
// @ts-ignore - Bug https://github.com/miragejs/miragejs/issues/1052 | ||
afterCreate(project: ModelInstance<HermesProject>, server: any): void { | ||
server.createList("related-hermes-document", 1); | ||
server.create("jira-object"); | ||
server.create("jira-issue"); | ||
|
||
const relatedHermesDocuments = server.schema.relatedHermesDocument | ||
.all() | ||
.models.map((doc: ModelInstance) => doc.attrs); | ||
|
||
const jiraObject = server.schema.jiraObjects.first()?.attrs; | ||
const jiraIssue = server.schema.jiraIssues.first()?.attrs; | ||
|
||
project.update({ | ||
hermesDocuments: relatedHermesDocuments, | ||
jiraObject, | ||
jiraIssue, | ||
}); | ||
}, | ||
}); |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters