mirror of
https://github.com/enso-org/enso.git
synced 2024-12-23 10:42:05 +03:00
Return Project Name when Creating a Project (#1908)
Add projectName field to the project/create result
This commit is contained in:
parent
e9523d8eda
commit
6af2338ad4
@ -362,8 +362,9 @@ interface ProjectCreateRequest {
|
||||
#### Result
|
||||
|
||||
```typescript
|
||||
interface ProjectOpenResponse {
|
||||
interface ProjectCreateResponse {
|
||||
projectId: UUID;
|
||||
projectName: string;
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -29,7 +29,7 @@ object ProjectManagementApi {
|
||||
missingComponentAction: Option[MissingComponentAction]
|
||||
)
|
||||
|
||||
case class Result(projectId: UUID)
|
||||
case class Result(projectId: UUID, projectName: String)
|
||||
|
||||
implicit val hasParams = new HasParams[this.type] {
|
||||
type Params = ProjectCreate.Params
|
||||
|
@ -52,14 +52,14 @@ class ProjectCreateHandler[F[+_, +_]: Exec: CovariantFlatMap: ErrorChannel](
|
||||
)
|
||||
}
|
||||
_ = logger.trace(s"Creating project using engine $actualVersion")
|
||||
projectId <- projectService.createUserProject(
|
||||
project <- projectService.createUserProject(
|
||||
progressTracker = self,
|
||||
name = params.name,
|
||||
engineVersion = actualVersion,
|
||||
projectTemplate = params.projectTemplate,
|
||||
missingComponentAction = missingComponentAction
|
||||
)
|
||||
} yield ProjectCreate.Result(projectId)
|
||||
} yield ProjectCreate.Result(project.id, project.name)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ class ProjectService[
|
||||
engineVersion: SemVer,
|
||||
projectTemplate: Option[String],
|
||||
missingComponentAction: MissingComponentAction
|
||||
): F[ProjectServiceFailure, UUID] = for {
|
||||
): F[ProjectServiceFailure, Project] = for {
|
||||
projectId <- gen.randomUUID()
|
||||
_ <- log.debug(
|
||||
"Creating project [{}, {}, {}].",
|
||||
@ -131,7 +131,7 @@ class ProjectService[
|
||||
.mapError(toServiceFailure)
|
||||
_ <- log.debug("Project [{}] updated in repository [{}].", projectId, repo)
|
||||
_ <- log.info("Project created [{}].", project)
|
||||
} yield projectId
|
||||
} yield project
|
||||
|
||||
/** @inheritdoc */
|
||||
override def deleteUserProject(
|
||||
|
@ -9,6 +9,7 @@ import org.enso.projectmanager.data.{
|
||||
ProjectMetadata,
|
||||
RunningLanguageServerInfo
|
||||
}
|
||||
import org.enso.projectmanager.model.Project
|
||||
|
||||
/** A contract for the Project Service.
|
||||
*
|
||||
@ -23,7 +24,7 @@ trait ProjectServiceApi[F[+_, +_]] {
|
||||
* @param engineVersion Enso version to use for the new project
|
||||
* @param projectTemplate the name of the project template
|
||||
* @param missingComponentAction specifies how to handle missing components
|
||||
* @return projectId
|
||||
* @return project
|
||||
*/
|
||||
def createUserProject(
|
||||
progressTracker: ActorRef,
|
||||
@ -31,7 +32,7 @@ trait ProjectServiceApi[F[+_, +_]] {
|
||||
engineVersion: SemVer,
|
||||
projectTemplate: Option[String],
|
||||
missingComponentAction: MissingComponentAction
|
||||
): F[ProjectServiceFailure, UUID]
|
||||
): F[ProjectServiceFailure, Project]
|
||||
|
||||
/** Deletes a user project.
|
||||
*
|
||||
|
@ -17,6 +17,7 @@ trait ProjectManagementOps { this: BaseServerSpec =>
|
||||
|
||||
def createProject(
|
||||
name: String,
|
||||
nameSuffix: Option[Int] = None,
|
||||
projectTemplate: Option[String] = None,
|
||||
missingComponentAction: Option[MissingComponentAction] = None
|
||||
)(implicit client: WsTestClient): UUID = {
|
||||
@ -37,13 +38,15 @@ trait ProjectManagementOps { this: BaseServerSpec =>
|
||||
}
|
||||
"""
|
||||
client.send(request)
|
||||
val projectId = getGeneratedUUID
|
||||
val projectId = getGeneratedUUID
|
||||
val projectName = nameSuffix.fold(name)(n => s"${name}_$n")
|
||||
client.expectJson(json"""
|
||||
{
|
||||
"jsonrpc":"2.0",
|
||||
"id":0,
|
||||
"result": {
|
||||
"projectId": $projectId
|
||||
"projectId": $projectId,
|
||||
"projectName": $projectName
|
||||
}
|
||||
}
|
||||
""")
|
||||
|
@ -129,7 +129,8 @@ class ProjectManagementApiSpec
|
||||
"jsonrpc" : "2.0",
|
||||
"id" : 1,
|
||||
"result" : {
|
||||
"projectId" : $getGeneratedUUID
|
||||
"projectId" : $getGeneratedUUID,
|
||||
"projectName" : "Foo"
|
||||
}
|
||||
}
|
||||
""")
|
||||
@ -213,7 +214,11 @@ class ProjectManagementApiSpec
|
||||
implicit val client = new WsTestClient(address)
|
||||
|
||||
createProject(projectName, projectTemplate = Some("default"))
|
||||
createProject(projectName, projectTemplate = Some("default"))
|
||||
createProject(
|
||||
projectName,
|
||||
projectTemplate = Some("default"),
|
||||
nameSuffix = Some(1)
|
||||
)
|
||||
|
||||
val projectDir = new File(userProjectDir, "Foo_1")
|
||||
val packageFile = new File(projectDir, "package.yaml")
|
||||
@ -238,7 +243,8 @@ class ProjectManagementApiSpec
|
||||
"jsonrpc" : "2.0",
|
||||
"id" : 1,
|
||||
"result" : {
|
||||
"projectId" : $getGeneratedUUID
|
||||
"projectId" : $getGeneratedUUID,
|
||||
"projectName" : "Foo"
|
||||
}
|
||||
}
|
||||
""")
|
||||
|
@ -33,7 +33,7 @@ abstract class ProjectOpenSpecBase
|
||||
engineVersion = defaultVersion,
|
||||
missingComponentAction = MissingComponentAction.Fail
|
||||
)
|
||||
ordinaryProject = Runtime.default.unsafeRun(ordinaryAction)
|
||||
ordinaryProject = Runtime.default.unsafeRun(ordinaryAction).id
|
||||
val brokenName = "Projbroken"
|
||||
val brokenAction = projectService.createUserProject(
|
||||
progressTracker = blackhole,
|
||||
@ -42,7 +42,7 @@ abstract class ProjectOpenSpecBase
|
||||
engineVersion = defaultVersion,
|
||||
missingComponentAction = MissingComponentAction.Fail
|
||||
)
|
||||
brokenProject = Runtime.default.unsafeRun(brokenAction)
|
||||
brokenProject = Runtime.default.unsafeRun(brokenAction).id
|
||||
|
||||
// TODO [RW] this hack should not be necessary with #1273
|
||||
val projectDir = new File(userProjectDir, brokenName)
|
||||
|
Loading…
Reference in New Issue
Block a user