diff --git a/amber/src/main/scala/org/apache/texera/web/TexeraWebApplication.scala b/amber/src/main/scala/org/apache/texera/web/TexeraWebApplication.scala index 5438eea4d0f..7713fee34c8 100644 --- a/amber/src/main/scala/org/apache/texera/web/TexeraWebApplication.scala +++ b/amber/src/main/scala/org/apache/texera/web/TexeraWebApplication.scala @@ -40,11 +40,6 @@ import org.apache.texera.web.resource.dashboard.admin.settings.AdminSettingsReso import org.apache.texera.web.resource.dashboard.admin.user.AdminUserResource import org.apache.texera.web.resource.dashboard.hub.HubResource import org.apache.texera.web.resource.dashboard.user.UserResource -import org.apache.texera.web.resource.dashboard.user.project.{ - ProjectAccessResource, - ProjectResource, - PublicProjectResource -} import org.apache.texera.web.resource.dashboard.user.quota.UserQuotaResource import org.apache.texera.web.resource.dashboard.user.workflow.{ WorkflowAccessResource, @@ -145,14 +140,11 @@ class TexeraWebApplication environment.jersey.register(classOf[GoogleAuthResource]) environment.jersey.register(classOf[UserConfigResource]) environment.jersey.register(classOf[AdminUserResource]) - environment.jersey.register(classOf[PublicProjectResource]) environment.jersey.register(classOf[WorkflowAccessResource]) environment.jersey.register(classOf[WorkflowResource]) environment.jersey.register(classOf[HubResource]) environment.jersey.register(classOf[UserResource]) environment.jersey.register(classOf[WorkflowVersionResource]) - environment.jersey.register(classOf[ProjectResource]) - environment.jersey.register(classOf[ProjectAccessResource]) environment.jersey.register(classOf[WorkflowExecutionsResource]) environment.jersey.register(classOf[DashboardResource]) environment.jersey.register(classOf[GmailResource]) diff --git a/amber/src/main/scala/org/apache/texera/web/resource/dashboard/DashboardResource.scala b/amber/src/main/scala/org/apache/texera/web/resource/dashboard/DashboardResource.scala index 704219fc2d3..8ef040b4a81 100644 --- a/amber/src/main/scala/org/apache/texera/web/resource/dashboard/DashboardResource.scala +++ b/amber/src/main/scala/org/apache/texera/web/resource/dashboard/DashboardResource.scala @@ -38,7 +38,6 @@ object DashboardResource { case class DashboardClickableFileEntry( resourceType: String, workflow: Option[DashboardWorkflow] = None, - project: Option[Project] = None, dataset: Option[DashboardDataset] = None ) @@ -54,7 +53,7 @@ object DashboardResource { The following class describe the available params from the frontend for full text search. * @param user The authenticated user performing the search. * @param keywords A list of search keywords. The API will return resources that match any of these keywords. - * @param resourceType The type of the resources to include in the search results. Acceptable values are "workflow", "project", "file" and "" (for all types). + * @param resourceType The type of the resources to include in the search results. Acceptable values are "workflow", "dataset" and "" (for all types). * @param creationStartDate The start of the date range for the creation time filter. It should be provided in 'yyyy-MM-dd' format. * @param creationEndDate The end of the date range for the creation time filter. It should be provided in 'yyyy-MM-dd' format. * @param modifiedStartDate The start of the date range for the modification time filter. It should be provided in 'yyyy-MM-dd' format. @@ -62,7 +61,6 @@ object DashboardResource { * @param owners A list of owner names to include in the search results. * @param workflowIDs A list of workflow IDs to include in the search results. * @param operators A list of operators to include in the search results. - * @param projectIds A list of project IDs to include in the search results. * @param offset The number of initial results to skip. This is useful for implementing pagination. * @param count The maximum number of results to return. * @param orderBy The order in which to sort the results. Acceptable values are 'NameAsc', 'NameDesc', 'CreateTimeDesc', and 'EditTimeDesc'. @@ -77,7 +75,6 @@ object DashboardResource { @QueryParam("owner") owners: java.util.List[String] = new util.ArrayList(), @QueryParam("id") workflowIDs: java.util.List[Integer] = new util.ArrayList(), @QueryParam("operator") operators: java.util.List[String] = new util.ArrayList(), - @QueryParam("projectId") projectIds: java.util.List[Integer] = new util.ArrayList(), @QueryParam("datasetId") datasetIds: java.util.List[Integer] = new util.ArrayList(), @QueryParam("start") @DefaultValue("0") offset: Int = 0, @QueryParam("count") @DefaultValue("20") count: Int = 20, @@ -95,15 +92,12 @@ object DashboardResource { val query = params.resourceType match { case SearchQueryBuilder.WORKFLOW_RESOURCE_TYPE => WorkflowSearchQueryBuilder.constructQuery(uid, params, includePublic) - case SearchQueryBuilder.PROJECT_RESOURCE_TYPE => - ProjectSearchQueryBuilder.constructQuery(uid, params, includePublic) case SearchQueryBuilder.DATASET_RESOURCE_TYPE => DatasetSearchQueryBuilder.constructQuery(uid, params, includePublic) case SearchQueryBuilder.ALL_RESOURCE_TYPE => - val q1 = WorkflowSearchQueryBuilder.constructQuery(uid, params, includePublic) - val q3 = ProjectSearchQueryBuilder.constructQuery(uid, params, includePublic) - val q4 = DatasetSearchQueryBuilder.constructQuery(uid, params, includePublic) - q1.unionAll(q3).unionAll(q4) + val workflowQuery = WorkflowSearchQueryBuilder.constructQuery(uid, params, includePublic) + val datasetQuery = DatasetSearchQueryBuilder.constructQuery(uid, params, includePublic) + workflowQuery.unionAll(datasetQuery) case _ => throw new IllegalArgumentException(s"Unknown resource type: ${params.resourceType}") } @@ -118,8 +112,6 @@ object DashboardResource { resourceType match { case SearchQueryBuilder.WORKFLOW_RESOURCE_TYPE => WorkflowSearchQueryBuilder.toEntry(uid, record) - case SearchQueryBuilder.PROJECT_RESOURCE_TYPE => - ProjectSearchQueryBuilder.toEntry(uid, record) case SearchQueryBuilder.DATASET_RESOURCE_TYPE => DatasetSearchQueryBuilder.toEntry(uid, record) } @@ -179,10 +171,10 @@ object DashboardResource { class DashboardResource { /** - * This method performs a full-text search across all resources - workflows, projects, and files - + * This method performs a full-text search across all resources - workflows and datasets - * that match the specified keywords. * It supports advanced filters such as resource type, creation and modification dates, owner, - * workflow IDs, operators, project IDs and allows to specify the number of results and their ordering. + * workflow IDs and operators, and allows specifying the number of results and their ordering. * * This method utilizes MySQL Boolean Full-Text Searches * reference: https://dev.mysql.com/doc/refman/8.0/en/fulltext-boolean.html diff --git a/amber/src/main/scala/org/apache/texera/web/resource/dashboard/ProjectSearchQueryBuilder.scala b/amber/src/main/scala/org/apache/texera/web/resource/dashboard/ProjectSearchQueryBuilder.scala deleted file mode 100644 index 5e247f87172..00000000000 --- a/amber/src/main/scala/org/apache/texera/web/resource/dashboard/ProjectSearchQueryBuilder.scala +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.texera.web.resource.dashboard - -import org.apache.texera.dao.jooq.generated.Tables.{PROJECT, PROJECT_USER_ACCESS} -import org.apache.texera.dao.jooq.generated.tables.pojos.Project -import org.apache.texera.web.resource.dashboard.DashboardResource.DashboardClickableFileEntry -import org.apache.texera.web.resource.dashboard.FulltextSearchQueryUtils.{ - getContainsFilter, - getDateFilter, - getFullTextSearchFilter -} -import org.jooq.impl.DSL -import org.jooq.{Condition, GroupField, Record, TableLike} - -import scala.jdk.CollectionConverters.CollectionHasAsScala - -object ProjectSearchQueryBuilder extends SearchQueryBuilder { - - override val mappedResourceSchema: UnifiedResourceSchema = UnifiedResourceSchema( - resourceType = DSL.inline(SearchQueryBuilder.PROJECT_RESOURCE_TYPE), - name = PROJECT.NAME, - description = PROJECT.DESCRIPTION, - creationTime = PROJECT.CREATION_TIME, - lastModifiedTime = PROJECT.CREATION_TIME, - pid = PROJECT.PID, - ownerId = PROJECT.OWNER_ID, - projectColor = PROJECT.COLOR - ) - - override protected def constructFromClause( - uid: Integer, - params: DashboardResource.SearchQueryParams, - includePublic: Boolean = false - ): TableLike[_] = { - PROJECT - .leftJoin(PROJECT_USER_ACCESS) - .on(PROJECT_USER_ACCESS.PID.eq(PROJECT.PID)) - .where(PROJECT_USER_ACCESS.UID.eq(uid)) - } - - override protected def constructWhereClause( - uid: Integer, - params: DashboardResource.SearchQueryParams - ): Condition = { - val splitKeywords = params.keywords.asScala - .flatMap(_.split("[+\\-()<>~*@\"]")) - .filter(_.nonEmpty) - .toSeq - - getDateFilter( - params.creationStartDate, - params.creationEndDate, - PROJECT.CREATION_TIME - ) - .and(getContainsFilter(params.projectIds, PROJECT.PID)) - .and( - getFullTextSearchFilter(splitKeywords, List(PROJECT.NAME, PROJECT.DESCRIPTION)) - ) - } - - override protected def getGroupByFields: Seq[GroupField] = Seq.empty - - override def toEntryImpl( - uid: Integer, - record: Record - ): DashboardResource.DashboardClickableFileEntry = { - val dp = record.into(PROJECT).into(classOf[Project]) - DashboardClickableFileEntry(SearchQueryBuilder.PROJECT_RESOURCE_TYPE, project = Some(dp)) - } -} diff --git a/amber/src/main/scala/org/apache/texera/web/resource/dashboard/SearchQueryBuilder.scala b/amber/src/main/scala/org/apache/texera/web/resource/dashboard/SearchQueryBuilder.scala index e19755e6116..ce2e1cd34d8 100644 --- a/amber/src/main/scala/org/apache/texera/web/resource/dashboard/SearchQueryBuilder.scala +++ b/amber/src/main/scala/org/apache/texera/web/resource/dashboard/SearchQueryBuilder.scala @@ -35,7 +35,6 @@ object SearchQueryBuilder { .createDSLContext() val FILE_RESOURCE_TYPE = "file" val WORKFLOW_RESOURCE_TYPE = "workflow" - val PROJECT_RESOURCE_TYPE = "project" val DATASET_RESOURCE_TYPE = "dataset" val ALL_RESOURCE_TYPE = "" } diff --git a/amber/src/main/scala/org/apache/texera/web/resource/dashboard/UnifiedResourceSchema.scala b/amber/src/main/scala/org/apache/texera/web/resource/dashboard/UnifiedResourceSchema.scala index 8c4ecda946b..5a5211ebc28 100644 --- a/amber/src/main/scala/org/apache/texera/web/resource/dashboard/UnifiedResourceSchema.scala +++ b/amber/src/main/scala/org/apache/texera/web/resource/dashboard/UnifiedResourceSchema.scala @@ -60,13 +60,9 @@ object UnifiedResourceSchema { ownerId: Field[Integer] = DSL.cast(null, classOf[Integer]), wid: Field[Integer] = DSL.cast(null, classOf[Integer]), workflowUserAccess: Field[PrivilegeEnum] = DSL.castNull(classOf[PrivilegeEnum]), - projectsOfWorkflow: Field[String] = DSL.inline(""), uid: Field[Integer] = DSL.cast(null, classOf[Integer]), userName: Field[String] = DSL.inline(""), userEmail: Field[String] = DSL.inline(""), - pid: Field[Integer] = DSL.cast(null, classOf[Integer]), - projectOwnerId: Field[Integer] = DSL.cast(null, classOf[Integer]), - projectColor: Field[String] = DSL.inline(""), did: Field[Integer] = DSL.cast(null, classOf[Integer]), datasetStoragePath: Field[String] = DSL.cast(null, classOf[String]), repositoryName: Field[String] = DSL.inline(""), @@ -85,13 +81,9 @@ object UnifiedResourceSchema { ownerId -> ownerId.as(resourceOwnerIdAlias), wid -> wid.as("wid"), workflowUserAccess -> workflowUserAccess.as("workflow_privilege"), - projectsOfWorkflow -> projectsOfWorkflow.as("projects"), uid -> uid.as("uid"), userName -> userName.as("userName"), userEmail -> userEmail.as("email"), - pid -> pid.as("pid"), - projectOwnerId -> projectOwnerId.as("owner_uid"), - projectColor -> projectColor.as("color"), did -> did.as("did"), datasetStoragePath -> datasetStoragePath.as("dataset_storage_path"), repositoryName -> repositoryName.as("repository_name"), @@ -108,7 +100,7 @@ object UnifiedResourceSchema { * Refer to /sql/texera_ddl.sql to understand what each attribute is * * Attributes common across all resource types: - * - `resourceType`: The type of the resource (e.g., project, workflow, file) as a `String`. + * - `resourceType`: The type of the resource (e.g., workflow, dataset) as a `String`. * - `name`: The name of the resource as a `String`. * - `description`: A textual description of the resource as a `String`. * - `creationTime`: The timestamp when the resource was created, as a `Timestamp`. @@ -118,16 +110,10 @@ object UnifiedResourceSchema { * Attributes specific to workflows: * - `wid`: Workflow ID, as an `Integer`. * - `workflowUserAccess`: Access privileges associated with the workflow, as a `PrivilegeEnum`. - * - `projectsOfWorkflow`: IDs of projects associated with the workflow, concatenated as a `String`. * - `uid`: User ID associated with the workflow, as an `Integer`. * - `userName`: Name of the user associated with the workflow, as a `String`. * - `userEmail`: Email of the user associated with the workflow, as a `String`. * - * Attributes specific to projects: - * - `pid`: Project ID, as an `Integer`. - * - `projectOwnerId`: ID of the project owner, as an `Integer`. - * - `projectColor`: Color associated with the project, as a `String`. - * * Attributes specific to files: * - `fid`: File ID, as an `Integer`. * - `fileUploadTime`: Timestamp when the file was uploaded, as a `Timestamp`. diff --git a/amber/src/main/scala/org/apache/texera/web/resource/dashboard/WorkflowSearchQueryBuilder.scala b/amber/src/main/scala/org/apache/texera/web/resource/dashboard/WorkflowSearchQueryBuilder.scala index 0c862c0509b..0354253fec2 100644 --- a/amber/src/main/scala/org/apache/texera/web/resource/dashboard/WorkflowSearchQueryBuilder.scala +++ b/amber/src/main/scala/org/apache/texera/web/resource/dashboard/WorkflowSearchQueryBuilder.scala @@ -25,7 +25,6 @@ import org.apache.texera.web.resource.dashboard.DashboardResource.DashboardClick import org.apache.texera.web.resource.dashboard.FulltextSearchQueryUtils._ import org.apache.texera.web.resource.dashboard.user.workflow.WorkflowResource.DashboardWorkflow import org.jooq.impl.DSL -import org.jooq.impl.DSL.groupConcatDistinct import org.jooq.{Condition, GroupField, Record, TableLike} import scala.jdk.CollectionConverters.CollectionHasAsScala @@ -44,8 +43,7 @@ object WorkflowSearchQueryBuilder extends SearchQueryBuilder { workflowUserAccess = WORKFLOW_USER_ACCESS.PRIVILEGE, uid = WORKFLOW_OF_USER.UID, ownerId = WORKFLOW_OF_USER.UID, - userName = USER.NAME, - projectsOfWorkflow = groupConcatDistinct(WORKFLOW_OF_PROJECT.PID) + userName = USER.NAME ) } @@ -62,18 +60,12 @@ object WorkflowSearchQueryBuilder extends SearchQueryBuilder { .on(WORKFLOW_OF_USER.WID.eq(WORKFLOW.WID)) .leftJoin(USER) .on(USER.UID.eq(WORKFLOW_OF_USER.UID)) - .leftJoin(WORKFLOW_OF_PROJECT) - .on(WORKFLOW_OF_PROJECT.WID.eq(WORKFLOW.WID)) - .leftJoin(PROJECT_USER_ACCESS) - .on(PROJECT_USER_ACCESS.PID.eq(WORKFLOW_OF_PROJECT.PID)) - .and(if (uid == null) DSL.falseCondition() else PROJECT_USER_ACCESS.UID.eq(uid)) var condition: Condition = DSL.trueCondition() if (uid == null) { condition = WORKFLOW.IS_PUBLIC.eq(true) } else { - val privateAccessCondition = - WORKFLOW_USER_ACCESS.UID.eq(uid).or(PROJECT_USER_ACCESS.UID.isNotNull) + val privateAccessCondition = WORKFLOW_USER_ACCESS.UID.eq(uid) if (includePublic) { condition = privateAccessCondition.or(WORKFLOW.IS_PUBLIC.eq(true)) } else { @@ -111,8 +103,6 @@ object WorkflowSearchQueryBuilder extends SearchQueryBuilder { .and(getContainsFilter(params.owners, USER.EMAIL)) // Apply operators filter .and(getOperatorsFilter(params.operators, WORKFLOW.CONTENT)) - // Apply projectId filter - .and(getContainsFilter(params.projectIds, WORKFLOW_OF_PROJECT.PID)) // Apply fulltext search filter .and( getFullTextSearchFilter( @@ -139,7 +129,6 @@ object WorkflowSearchQueryBuilder extends SearchQueryBuilder { uid: Integer, record: Record ): DashboardResource.DashboardClickableFileEntry = { - val pidField = groupConcatDistinct(WORKFLOW_OF_PROJECT.PID) val dw = DashboardWorkflow( record.into(WORKFLOW_OF_USER).getUid == uid, Option(record.get(WORKFLOW_USER_ACCESS.PRIVILEGE, classOf[PrivilegeEnum])) @@ -147,16 +136,6 @@ object WorkflowSearchQueryBuilder extends SearchQueryBuilder { .getOrElse(PrivilegeEnum.NONE.toString), record.into(USER).getName, record.into(WORKFLOW).into(classOf[Workflow]), - if (record.get(pidField) == null) { - List[Integer]() - } else { - record - .get(pidField) - .asInstanceOf[String] - .split(',') - .map(number => Integer.valueOf(number)) - .toList - }, record.into(USER).getUid ) DashboardClickableFileEntry(SearchQueryBuilder.WORKFLOW_RESOURCE_TYPE, workflow = Some(dw)) diff --git a/amber/src/main/scala/org/apache/texera/web/resource/dashboard/hub/HubResource.scala b/amber/src/main/scala/org/apache/texera/web/resource/dashboard/hub/HubResource.scala index 33ba16c6e14..09e3bfc8482 100644 --- a/amber/src/main/scala/org/apache/texera/web/resource/dashboard/hub/HubResource.scala +++ b/amber/src/main/scala/org/apache/texera/web/resource/dashboard/hub/HubResource.scala @@ -494,7 +494,6 @@ class HubResource { DashboardClickableFileEntry( resourceType = entityType.value, workflow = Some(w), - project = None, dataset = None ) } @@ -503,7 +502,6 @@ class HubResource { DashboardClickableFileEntry( resourceType = entityType.value, workflow = None, - project = None, dataset = Some(d) ) } diff --git a/amber/src/main/scala/org/apache/texera/web/resource/dashboard/user/project/ProjectAccessResource.scala b/amber/src/main/scala/org/apache/texera/web/resource/dashboard/user/project/ProjectAccessResource.scala deleted file mode 100644 index cf7e2cadc42..00000000000 --- a/amber/src/main/scala/org/apache/texera/web/resource/dashboard/user/project/ProjectAccessResource.scala +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.texera.web.resource.dashboard.user.project - -import io.dropwizard.auth.Auth -import org.apache.texera.auth.SessionUser -import org.apache.texera.dao.SqlServer -import org.apache.texera.dao.jooq.generated.Tables.{PROJECT_USER_ACCESS, USER} -import org.apache.texera.dao.jooq.generated.enums.PrivilegeEnum -import org.apache.texera.dao.jooq.generated.tables.daos.{ProjectDao, ProjectUserAccessDao, UserDao} -import org.apache.texera.dao.jooq.generated.tables.pojos.ProjectUserAccess -import org.apache.texera.web.model.common.AccessEntry -import org.apache.texera.web.resource.dashboard.user.project.ProjectAccessResource.{ - userHasWriteAccess -} -import org.jooq.DSLContext - -import java.util -import javax.annotation.security.RolesAllowed -import javax.ws.rs._ -import javax.ws.rs.core.MediaType - -object ProjectAccessResource { - private def context: DSLContext = - SqlServer - .getInstance() - .createDSLContext() - - def userHasWriteAccess(pid: Integer, uid: Integer): Boolean = { - getProjectAccessPrivilege(pid, uid) == PrivilegeEnum.WRITE - } - - def getProjectAccessPrivilege(pid: Integer, uid: Integer): PrivilegeEnum = { - Option( - context - .select(PROJECT_USER_ACCESS.PRIVILEGE) - .from(PROJECT_USER_ACCESS) - .where( - PROJECT_USER_ACCESS.PID - .eq(pid) - .and(PROJECT_USER_ACCESS.UID.eq(uid)) - ) - .fetchOneInto(classOf[PrivilegeEnum]) - ).getOrElse(PrivilegeEnum.NONE) - } -} - -@Produces(Array(MediaType.APPLICATION_JSON)) -@RolesAllowed(Array("REGULAR", "ADMIN")) -@Path("/access/project") -class ProjectAccessResource() { - private def context: DSLContext = - SqlServer - .getInstance() - .createDSLContext() - private def userDao = new UserDao(context.configuration()) - private def projectDao = new ProjectDao(context.configuration) - private def projectUserAccessDao = new ProjectUserAccessDao(context.configuration) - - /** - * This method returns the owner of a project - * - * @param pid , project id - * @return ownerEmail, the owner's email - */ - @GET - @Path("/owner/{pid}") - def getOwner(@PathParam("pid") pid: Integer): String = { - userDao.fetchOneByUid(projectDao.fetchOneByPid(pid).getOwnerId).getEmail - } - - /** - * Returns information about all current shared access of the given project - * - * @param pid project id - * @return a List of email/permission pair - */ - @GET - @Path("/list/{pid}") - def getAccessList( - @PathParam("pid") pid: Integer - ): util.List[AccessEntry] = { - context - .select( - USER.EMAIL, - USER.NAME, - PROJECT_USER_ACCESS.PRIVILEGE - ) - .from(PROJECT_USER_ACCESS) - .join(USER) - .on(USER.UID.eq(PROJECT_USER_ACCESS.UID)) - .where( - PROJECT_USER_ACCESS.PID - .eq(pid) - .and(PROJECT_USER_ACCESS.UID.notEqual(projectDao.fetchOneByPid(pid).getOwnerId)) - ) - .fetchInto(classOf[AccessEntry]) - } - - /** - * This method shares a project to a user with a specific access type - * - * @param pid the given project - * @param email the email which the access is given to - * @param privilege the type of Access given to the target user - * @return rejection if user not permitted to share the project or Success Message - */ - @PUT - @Path("/grant/{pid}/{email}/{privilege}") - def grantAccess( - @PathParam("pid") pid: Integer, - @PathParam("email") email: String, - @PathParam("privilege") privilege: String, - @Auth user: SessionUser - ): Unit = { - if (!userHasWriteAccess(pid, user.getUid)) { - throw new ForbiddenException(s"You do not have permission to modify project $pid") - } - - projectUserAccessDao.merge( - new ProjectUserAccess( - userDao.fetchOneByEmail(email).getUid, - pid, - PrivilegeEnum.valueOf(privilege) - ) - ) - } - - /** - * Revoke a user's access to a file - * - * @param pid the id of the file - * @param email the email of target user whose access is about to be revoked - * @return A successful resp if granted, failed resp otherwise - */ - @DELETE - @Path("/revoke/{pid}/{email}") - def revokeAccess( - @PathParam("pid") pid: Integer, - @PathParam("email") email: String, - @Auth user: SessionUser - ): Unit = { - if (!userHasWriteAccess(pid, user.getUid)) { - throw new ForbiddenException(s"You do not have permission to modify project $pid") - } - - context - .delete(PROJECT_USER_ACCESS) - .where( - PROJECT_USER_ACCESS.UID - .eq(userDao.fetchOneByEmail(email).getUid) - .and(PROJECT_USER_ACCESS.PID.eq(pid)) - ) - .execute() - } -} diff --git a/amber/src/main/scala/org/apache/texera/web/resource/dashboard/user/project/ProjectResource.scala b/amber/src/main/scala/org/apache/texera/web/resource/dashboard/user/project/ProjectResource.scala deleted file mode 100644 index be72fd21d02..00000000000 --- a/amber/src/main/scala/org/apache/texera/web/resource/dashboard/user/project/ProjectResource.scala +++ /dev/null @@ -1,337 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.texera.web.resource.dashboard.user.project - -import io.dropwizard.auth.Auth -import org.apache.commons.lang3.StringUtils -import org.apache.texera.auth.SessionUser -import org.apache.texera.dao.SqlServer -import org.apache.texera.dao.jooq.generated.Tables._ -import org.apache.texera.dao.jooq.generated.enums.PrivilegeEnum -import org.apache.texera.dao.jooq.generated.tables.daos.{ - ProjectDao, - ProjectUserAccessDao, - WorkflowOfProjectDao -} -import org.apache.texera.dao.jooq.generated.tables.pojos._ -import org.apache.texera.web.resource.dashboard.DashboardResource -import org.apache.texera.web.resource.dashboard.DashboardResource.SearchQueryParams -import org.apache.texera.web.resource.dashboard.user.project.ProjectResource._ -import org.apache.texera.web.resource.dashboard.user.workflow.WorkflowAccessResource.hasReadAccess -import org.apache.texera.web.resource.dashboard.user.workflow.WorkflowResource.DashboardWorkflow - -import java.sql.Timestamp -import java.util -import javax.annotation.security.RolesAllowed -import javax.ws.rs._ -import javax.ws.rs.core.MediaType -import scala.jdk.CollectionConverters.IterableHasAsScala - -/** - * This file handles various request related to projects. - * It sends mysql queries to the MysqlDB regarding the 'user_project', - * 'workflow_of_project', and 'file_of_project' Tables - * The details of these tables can be found in /sql/texera_ddl.sql - */ - -object ProjectResource { - private def context = - SqlServer - .getInstance() - .createDSLContext() - private def userProjectDao = new ProjectDao(context.configuration) - private def workflowOfProjectDao = new WorkflowOfProjectDao(context.configuration) - private def projectUserAccessDao = new ProjectUserAccessDao(context.configuration) - - /** - * This method is used to insert any CSV files created from ResultExportService - * handleCSVRequest function into all project(s) that the workflow belongs to. - * - * No insertion occurs if the workflow does not belong to any projects. - * - * @param uid user ID - * @param wid workflow ID - * @param fileName name of exported file - * @return String containing status of adding exported file to project(s) - */ - def addExportedFileToProject(uid: Integer, wid: Integer, fileName: String): String = { - // get map of PIDs and project names - val pidMap = context - .select(WORKFLOW_OF_PROJECT.PID, PROJECT.NAME) - .from(WORKFLOW_OF_PROJECT) - .leftJoin(PROJECT) - .on(WORKFLOW_OF_PROJECT.PID.eq(PROJECT.PID)) - .where(WORKFLOW_OF_PROJECT.WID.eq(wid)) - .fetch() - .intoMap(WORKFLOW_OF_PROJECT.PID, PROJECT.NAME) - - if (pidMap.size() > 0) { // workflow belongs to project(s) - // generate string for ResultExportResponse - if (pidMap.size() == 1) { - s"and added to project: ${pidMap.values().toArray()(0)}" - } else { - s"and added to projects: ${pidMap.values().asScala.mkString(", ")}" - } - } else { // workflow does not belong to a project - "" - } - } - - private def workflowOfProjectExists(wid: Integer, pid: Integer): Boolean = { - workflowOfProjectDao.existsById( - context - .newRecord(WORKFLOW_OF_PROJECT.WID, WORKFLOW_OF_PROJECT.PID) - .values(wid, pid) - ) - } - - case class DashboardProject( - pid: Integer, - name: String, - description: String, - ownerID: Integer, - creationTime: Timestamp, - color: String, - accessLevel: String - ) -} - -@Path("/project") -@RolesAllowed(Array("REGULAR", "ADMIN")) -@Produces(Array(MediaType.APPLICATION_JSON)) -class ProjectResource { - - /** - * This method returns the specified project - * - * @param pid project id - * @return project specified by the project id - */ - @GET - @Path("/{pid}") - def getProject(@PathParam("pid") pid: Integer): Project = { - userProjectDao.fetchOneByPid(pid) - } - - /** - * This method returns the list of projects owned by the session user. - * - * @param user the session user - * @return a list of projects belonging to owner - */ - @GET - @Path("/list") - def getProjectList(@Auth user: SessionUser): util.List[DashboardProject] = { - context - .selectDistinct( - PROJECT.PID, - PROJECT.NAME, - PROJECT.DESCRIPTION, - PROJECT.OWNER_ID, - PROJECT.CREATION_TIME, - PROJECT.COLOR, - PROJECT_USER_ACCESS.PRIVILEGE - ) - .from(PROJECT_USER_ACCESS) - .join(PROJECT) - .on(PROJECT_USER_ACCESS.PID.eq(PROJECT.PID)) - .where(PROJECT.OWNER_ID.eq(user.getUid).or(PROJECT_USER_ACCESS.UID.eq(user.getUid))) - .fetchInto(classOf[DashboardProject]) - } - - /** - * This method returns a list of DashboardWorkflow objects, which represents - * all the workflows that are part of the specified project. - * - * @param pid project ID - * @param user the session user - * @return list of DashboardWorkflow objects - */ - @GET - @Path("/{pid}/workflows") - def listProjectWorkflows( - @PathParam("pid") pid: Integer, - @Auth user: SessionUser - ): List[DashboardWorkflow] = { - val result = DashboardResource.searchAllResources( - user, - SearchQueryParams(resourceType = "workflow", projectIds = util.Arrays.asList(pid)) - ) - result.results.map(_.workflow.get) - } - - /** - * This method inserts a new project into the database belonging to the session user - * and with the specified name. - * - * @param user the session user - * @param name project name - */ - @POST - @Path("/create/{name}") - def createProject( - @Auth user: SessionUser, - @PathParam("name") name: String - ): Project = { - val project = new Project(null, name, null, user.getUid, null, null) - try { - userProjectDao.insert(project) - projectUserAccessDao.merge( - new ProjectUserAccess(user.getUid, project.getPid, PrivilegeEnum.WRITE) - ) - } catch { - case _: Throwable => - throw new BadRequestException("Cannot create a new project with provided name."); - } - userProjectDao.fetchOneByPid(project.getPid) - } - - /** - * This method adds a mapping between the specified workflow to the specified project into the database. - * - * @param pid project ID - * @param wid workflow ID - */ - @POST - @Path("/{pid}/workflow/{wid}/add") - def addWorkflowToProject( - @PathParam("pid") pid: Integer, - @PathParam("wid") wid: Integer, - @Auth user: SessionUser - ): Unit = { - if (!hasReadAccess(wid, user.getUid)) { - throw new ForbiddenException("No sufficient access privilege to workflow.") - } - - if (!workflowOfProjectExists(wid, pid)) { - workflowOfProjectDao.insert(new WorkflowOfProject(wid, pid)) - } - } - - /** - * This method updates the project name of the specified, existing project - * - * @param pid project ID - * @param name new name - */ - @POST - @Path("/{pid}/rename/{name}") - def updateProjectName( - @PathParam("pid") pid: Integer, - @PathParam("name") name: String - ): Unit = { - val userProject: Project = userProjectDao.fetchOneByPid(pid) - if (StringUtils.isBlank(name)) { - throw new BadRequestException("Cannot rename project to empty or blank name.") - } - - try { - userProject.setName(name) - userProjectDao.update(userProject) - } catch { - case _: Throwable => throw new BadRequestException("Cannot rename project to provided name."); - } - } - - /** - * This method updates the description of a specified, existing project - * - * @param pid project ID - */ - @POST - @Path("/{pid}/update/description") - @Consumes(Array(MediaType.TEXT_PLAIN)) - def updateProjectDescription( - @PathParam("pid") pid: Integer, - description: String - ): Unit = { - val userProject: Project = userProjectDao.fetchOneByPid(pid) - try { - userProject.setDescription(description) - userProjectDao.update(userProject) - } catch { - case _: Throwable => - throw new BadRequestException("Cannot update project description to provided text."); - } - } - - /** - * This method updates a project's color. - * - * @param pid id of project to be updated - * @param colorHex new HEX formatted color to be set - */ - @POST - @Path("/{pid}/color/{colorHex}/add") - def updateProjectColor( - @PathParam("pid") pid: Integer, - @PathParam("colorHex") colorHex: String, - @Auth sessionUser: SessionUser - ): Unit = { - val userProject: Project = userProjectDao.fetchOneByPid(pid) - if ( - colorHex == null || colorHex.length != 6 && colorHex.length != 3 || !colorHex.matches( - "^[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3}$" - ) - ) { - throw new BadRequestException("Cannot assign invalid HEX format color to project.") - } - - userProject.setColor(colorHex) - userProjectDao.update(userProject) - } - - @POST - @Path("/{pid}/color/delete") - def deleteProjectColor(@PathParam("pid") pid: Integer): Unit = { - val userProject: Project = userProjectDao.fetchOneByPid(pid) - userProject.setColor(null) - userProjectDao.update(userProject) - } - - /** - * This method deletes an existing project from the database - * - * @param pid projectID - */ - @DELETE - @Path("/delete/{pid}") - def deleteProject(@PathParam("pid") pid: Integer): Unit = { - userProjectDao.deleteById(pid) - } - - /** - * This method deletes an existing mapping between a workflow and project from - * the database - * - * @param pid project ID - * @param wid workflow ID - */ - @DELETE - @Path("/{pid}/workflow/{wid}/delete") - def deleteWorkflowFromProject( - @PathParam("pid") pid: Integer, - @PathParam("wid") wid: Integer - ): Unit = { - workflowOfProjectDao.deleteById( - context.newRecord(WORKFLOW_OF_PROJECT.WID, WORKFLOW_OF_PROJECT.PID).values(wid, pid) - ) - } -} diff --git a/amber/src/main/scala/org/apache/texera/web/resource/dashboard/user/project/PublicProjectResource.scala b/amber/src/main/scala/org/apache/texera/web/resource/dashboard/user/project/PublicProjectResource.scala deleted file mode 100644 index 6983bf13ee0..00000000000 --- a/amber/src/main/scala/org/apache/texera/web/resource/dashboard/user/project/PublicProjectResource.scala +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.texera.web.resource.dashboard.user.project - -import io.dropwizard.auth.Auth -import org.apache.texera.auth.SessionUser -import org.apache.texera.dao.SqlServer -import org.apache.texera.dao.jooq.generated.Tables.{PROJECT, PUBLIC_PROJECT, USER} -import org.apache.texera.dao.jooq.generated.enums.PrivilegeEnum -import org.apache.texera.dao.jooq.generated.tables.daos.{ProjectUserAccessDao, PublicProjectDao} -import org.apache.texera.dao.jooq.generated.tables.pojos.{ProjectUserAccess, PublicProject} -import org.jooq.DSLContext - -import java.sql.Timestamp -import java.util -import javax.annotation.security.RolesAllowed -import javax.ws.rs._ - -case class DashboardPublicProject( - pid: Integer, - name: String, - owner: String, - creationTime: Timestamp -) {} - -@Path("/public/project") -class PublicProjectResource { - - private def context: DSLContext = - SqlServer - .getInstance() - .createDSLContext() - private def publicProjectDao = new PublicProjectDao(context.configuration) - private def projectUserAccessDao = new ProjectUserAccessDao(context.configuration) - - @GET - @RolesAllowed(Array("ADMIN")) - @Path("/type/{pid}") - def getType(@PathParam("pid") pid: Integer): String = { - if (publicProjectDao.fetchOneByPid(pid) == null) - "Private" - else - "Public" - } - - @PUT - @RolesAllowed(Array("ADMIN")) - @Path("/public/{pid}") - def makePublic(@PathParam("pid") pid: Integer, @Auth user: SessionUser): Unit = { - publicProjectDao.insert(new PublicProject(pid, user.getUid)) - } - - @PUT - @RolesAllowed(Array("ADMIN")) - @Path("/private/{pid}") - def makePrivate(@PathParam("pid") pid: Integer): Unit = { - publicProjectDao.deleteById(pid) - } - - @PUT - @RolesAllowed(Array("REGULAR", "ADMIN")) - @Path("/add") - def addPublicProjects(checkedList: util.List[Integer], @Auth user: SessionUser): Unit = { - checkedList.forEach(pid => { - projectUserAccessDao.merge( - new ProjectUserAccess( - user.getUid, - pid, - PrivilegeEnum.READ - ) - ) - }) - } - - @GET - @RolesAllowed(Array("REGULAR", "ADMIN")) - @Path("/list") - def listPublicProjects(): util.List[DashboardPublicProject] = { - context - .select(PUBLIC_PROJECT.PID, PROJECT.NAME, USER.NAME, PROJECT.CREATION_TIME) - .from(PUBLIC_PROJECT) - .leftJoin(PROJECT) - .on(PUBLIC_PROJECT.PID.eq(PROJECT.PID)) - .leftJoin(USER) - .on(USER.UID.eq(PUBLIC_PROJECT.UID)) - .fetchInto(classOf[DashboardPublicProject]) - } -} diff --git a/amber/src/main/scala/org/apache/texera/web/resource/dashboard/user/workflow/WorkflowAccessResource.scala b/amber/src/main/scala/org/apache/texera/web/resource/dashboard/user/workflow/WorkflowAccessResource.scala index a439238aae0..9332aa26fe9 100644 --- a/amber/src/main/scala/org/apache/texera/web/resource/dashboard/user/workflow/WorkflowAccessResource.scala +++ b/amber/src/main/scala/org/apache/texera/web/resource/dashboard/user/workflow/WorkflowAccessResource.scala @@ -86,18 +86,7 @@ object WorkflowAccessResource { .where(WORKFLOW_USER_ACCESS.WID.eq(wid).and(WORKFLOW_USER_ACCESS.UID.eq(uid))) .fetchOneInto(classOf[WorkflowUserAccess]) if (access == null) { - val projectAccess = context - .select() - .from(PROJECT_USER_ACCESS) - .join(WORKFLOW_OF_PROJECT) - .on(WORKFLOW_OF_PROJECT.PID.eq(PROJECT_USER_ACCESS.PID)) - .where(WORKFLOW_OF_PROJECT.WID.eq(wid).and(PROJECT_USER_ACCESS.UID.eq(uid))) - .fetchOneInto(classOf[WorkflowUserAccess]) - if (projectAccess == null) { - PrivilegeEnum.NONE - } else { - projectAccess.getPrivilege - } + PrivilegeEnum.NONE } else { access.getPrivilege } diff --git a/amber/src/main/scala/org/apache/texera/web/resource/dashboard/user/workflow/WorkflowResource.scala b/amber/src/main/scala/org/apache/texera/web/resource/dashboard/user/workflow/WorkflowResource.scala index ee559048c97..b9eebb7e1b1 100644 --- a/amber/src/main/scala/org/apache/texera/web/resource/dashboard/user/workflow/WorkflowResource.scala +++ b/amber/src/main/scala/org/apache/texera/web/resource/dashboard/user/workflow/WorkflowResource.scala @@ -31,7 +31,6 @@ import org.apache.texera.dao.jooq.generated.Tables._ import org.apache.texera.dao.jooq.generated.enums.PrivilegeEnum import org.apache.texera.dao.jooq.generated.tables.daos.{ WorkflowDao, - WorkflowOfProjectDao, WorkflowOfUserDao, WorkflowUserAccessDao } @@ -39,10 +38,9 @@ import org.apache.texera.dao.jooq.generated.tables.pojos._ import org.apache.texera.service.util.LargeBinaryManager import org.apache.texera.web.resource.dashboard.hub.EntityType import org.apache.texera.web.resource.dashboard.hub.HubResource.recordCloneAction -import org.apache.texera.web.resource.dashboard.user.workflow.WorkflowAccessResource.hasReadAccess import org.apache.texera.web.resource.dashboard.user.workflow.WorkflowResource._ -import org.jooq.impl.DSL.{groupConcatDistinct, noCondition} -import org.jooq.{Condition, DSLContext, Record9, Result, SelectOnConditionStep} +import org.jooq.impl.DSL.noCondition +import org.jooq.{Condition, DSLContext, Record8, Result, SelectOnConditionStep} import java.sql.Timestamp import java.util @@ -75,7 +73,6 @@ object WorkflowResource { new WorkflowUserAccessDao( context.configuration() ) - private def workflowOfProjectDao = new WorkflowOfProjectDao(context.configuration) def getWorkflowName(wid: Integer): String = { val workflow = workflowDao.fetchOneByWid(wid) @@ -105,20 +102,11 @@ object WorkflowResource { ) } - private def workflowOfProjectExists(wid: Integer, pid: Integer): Boolean = { - workflowOfProjectDao.existsById( - context - .newRecord(WORKFLOW_OF_PROJECT.WID, WORKFLOW_OF_PROJECT.PID) - .values(wid, pid) - ) - } - case class DashboardWorkflow( isOwner: Boolean, accessLevel: String, ownerName: String, workflow: Workflow, - projectIDs: List[Integer], ownerId: Integer ) @@ -133,7 +121,7 @@ object WorkflowResource { readonly: Boolean ) - case class WorkflowIDs(wids: List[Integer], pid: Option[Integer]) + case class WorkflowIDs(wids: List[Integer]) private def updateWorkflowField( workflow: Workflow, @@ -185,7 +173,7 @@ object WorkflowResource { } } - def baseWorkflowSelect(): SelectOnConditionStep[Record9[ + def baseWorkflowSelect(): SelectOnConditionStep[Record8[ Integer, String, String, @@ -193,7 +181,6 @@ object WorkflowResource { Timestamp, PrivilegeEnum, Integer, - String, String ]] = { context @@ -205,8 +192,7 @@ object WorkflowResource { WORKFLOW.LAST_MODIFIED_TIME, WORKFLOW_USER_ACCESS.PRIVILEGE, WORKFLOW_OF_USER.UID, - USER.NAME, - groupConcatDistinct(WORKFLOW_OF_PROJECT.PID).as("projects") + USER.NAME ) .from(WORKFLOW) .leftJoin(WORKFLOW_USER_ACCESS) @@ -215,12 +201,10 @@ object WorkflowResource { .on(WORKFLOW_OF_USER.WID.eq(WORKFLOW.WID)) .leftJoin(USER) .on(USER.UID.eq(WORKFLOW_OF_USER.UID)) - .leftJoin(WORKFLOW_OF_PROJECT) - .on(WORKFLOW.WID.eq(WORKFLOW_OF_PROJECT.WID)) } def mapWorkflowEntries( - workflowEntries: Result[Record9[ + workflowEntries: Result[Record8[ Integer, String, String, @@ -228,7 +212,6 @@ object WorkflowResource { Timestamp, PrivilegeEnum, Integer, - String, String ]], uid: Integer @@ -246,9 +229,6 @@ object WorkflowResource { .toString, workflowRecord.into(USER).getName, workflowRecord.into(WORKFLOW).into(classOf[Workflow]), - if (workflowRecord.component9() == null) List[Integer]() - else - workflowRecord.component9().split(',').map(str => Integer.valueOf(str)).toList, workflowRecord.into(WORKFLOW_OF_USER).getUid ) ) @@ -483,7 +463,6 @@ class WorkflowResource extends LazyLogging { } val resultWorkflows: ListBuffer[DashboardWorkflow] = ListBuffer() - val addToProject = workflowIDs.pid.nonEmpty // then start a transaction and do the duplication try { context.transaction { txConfig => @@ -501,19 +480,6 @@ class WorkflowResource extends LazyLogging { ), sessionUser ) - // if workflows also need to be added to the project - if (addToProject) { - val newWid = newWorkflow.workflow.getWid - if (!hasReadAccess(newWid, user.getUid)) { - throw new ForbiddenException("No sufficient access privilege to workflow.") - } - val pid = workflowIDs.pid.get - if (!workflowOfProjectExists(newWid, pid)) { - workflowOfProjectDao.insert(new WorkflowOfProject(newWid, pid)) - } else { - throw new BadRequestException("Workflow already exists in the project") - } - } resultWorkflows += newWorkflow } } @@ -577,7 +543,6 @@ class WorkflowResource extends LazyLogging { PrivilegeEnum.WRITE.toString, user.getName, workflowDao.fetchOneByWid(workflow.getWid), - List[Integer](), user.getUid ) } diff --git a/amber/src/test/scala/org/apache/texera/web/resource/dashboard/file/WorkflowResourceSpec.scala b/amber/src/test/scala/org/apache/texera/web/resource/dashboard/file/WorkflowResourceSpec.scala index 30eefb41c3b..d61b224a269 100644 --- a/amber/src/test/scala/org/apache/texera/web/resource/dashboard/file/WorkflowResourceSpec.scala +++ b/amber/src/test/scala/org/apache/texera/web/resource/dashboard/file/WorkflowResourceSpec.scala @@ -21,12 +21,11 @@ package org.apache.texera.web.resource.dashboard.file import org.apache.texera.auth.SessionUser import org.apache.texera.dao.MockTexeraDB -import org.apache.texera.dao.jooq.generated.Tables.{USER, WORKFLOW, WORKFLOW_OF_PROJECT} +import org.apache.texera.dao.jooq.generated.Tables.{USER, WORKFLOW} import org.apache.texera.dao.jooq.generated.enums.UserRoleEnum import org.apache.texera.dao.jooq.generated.tables.daos.UserDao -import org.apache.texera.dao.jooq.generated.tables.pojos.{Project, User, Workflow} +import org.apache.texera.dao.jooq.generated.tables.pojos.{User, Workflow} import org.apache.texera.web.resource.dashboard.DashboardResource.SearchQueryParams -import org.apache.texera.web.resource.dashboard.user.project.ProjectResource import org.apache.texera.web.resource.dashboard.user.workflow.WorkflowResource import org.apache.texera.web.resource.dashboard.user.workflow.WorkflowResource.{ DashboardWorkflow, @@ -112,13 +111,6 @@ class WorkflowResourceSpec workflow } - private val testProject1: Project = { - val project = new Project() - project.setName("test_project1") - project.setDescription("this is project description") - project - } - private val exampleEmailAddress = "name@example.com" private val exampleWord1 = "Lorem" private val exampleWord2 = "Ipsum" @@ -144,10 +136,6 @@ class WorkflowResourceSpec new WorkflowResource() } - private val projectResource: ProjectResource = { - new ProjectResource() - } - private val dashboardResource: DashboardResource = { new DashboardResource() } @@ -172,7 +160,7 @@ class WorkflowResourceSpec var workflows = workflowResource.retrieveWorkflowsBySessionUser(sessionUser1) workflows.foreach(workflow => workflowResource.deleteWorkflow( - WorkflowIDs(List(workflow.workflow.getWid), None), + WorkflowIDs(List(workflow.workflow.getWid)), sessionUser1 ) ) @@ -180,18 +168,10 @@ class WorkflowResourceSpec workflows = workflowResource.retrieveWorkflowsBySessionUser(sessionUser2) workflows.foreach(workflow => workflowResource.deleteWorkflow( - WorkflowIDs(List(workflow.workflow.getWid), None), + WorkflowIDs(List(workflow.workflow.getWid)), sessionUser2 ) ) - - // delete all projects in the database - var projects = projectResource.getProjectList(sessionUser1) - projects.forEach(project => projectResource.deleteProject(project.pid)) - - projects = projectResource.getProjectList(sessionUser2) - projects.forEach(project => projectResource.deleteProject(project.pid)) - } override protected def afterAll(): Unit = { @@ -535,27 +515,6 @@ class WorkflowResourceSpec assert(ownerFilter.toString == USER.EMAIL.eq("owner1").or(USER.EMAIL.eq("owner2")).toString) } - it should "return a proper condition for a single projectId" in { - val projectIdList = new java.util.ArrayList[Integer](util.Arrays.asList(Integer.valueOf(1))) - val projectFilter: Condition = - FulltextSearchQueryUtils.getContainsFilter(projectIdList, WORKFLOW_OF_PROJECT.PID) - assert(projectFilter.toString == WORKFLOW_OF_PROJECT.PID.eq(Integer.valueOf(1)).toString) - } - - it should "return a proper condition for multiple projectIds" in { - val projectIdList = new java.util.ArrayList[Integer]( - util.Arrays.asList(Integer.valueOf(1), Integer.valueOf(2)) - ) - val projectFilter: Condition = - FulltextSearchQueryUtils.getContainsFilter(projectIdList, WORKFLOW_OF_PROJECT.PID) - assert( - projectFilter.toString == WORKFLOW_OF_PROJECT.PID - .eq(Integer.valueOf(1)) - .or(WORKFLOW_OF_PROJECT.PID.eq(Integer.valueOf(2))) - .toString - ) - } - it should "return a proper condition for a single workflowID" in { val workflowIdList = new java.util.ArrayList[Integer](util.Arrays.asList(Integer.valueOf(1))) val workflowIdFilter: Condition = @@ -657,10 +616,8 @@ class WorkflowResourceSpec ) } - "/search API" should "be able to search for resources in different tables" in { + "/search API" should "be able to search for resources by keyword" in { - // create different types of resources, project, workflow, and file - projectResource.createProject(sessionUser1, "test project1") workflowResource.persistWorkflow(testWorkflow1, sessionUser1) // search val DashboardClickableFileEntryList = @@ -668,88 +625,95 @@ class WorkflowResourceSpec sessionUser1, SearchQueryParams(getKeywordsArray("test")) ) - assert(DashboardClickableFileEntryList.results.length == 2) + assert(DashboardClickableFileEntryList.results.length == 1) } it should "return all resources when no keyword provided" in { - projectResource.createProject(sessionUser1, "test project1") workflowResource.persistWorkflow(testWorkflow1, sessionUser1) val DashboardClickableFileEntryList = dashboardResource.searchAllResourcesCall( sessionUser1, SearchQueryParams(getKeywordsArray("")) ) - assert(DashboardClickableFileEntryList.results.length == 2) + assert(DashboardClickableFileEntryList.results.length == 1) } it should "return multiple matching resources from a single resource type" in { workflowResource.persistWorkflow(testWorkflow1, sessionUser1) - projectResource.createProject(sessionUser1, "common project1") - projectResource.createProject(sessionUser1, "common project2") + workflowResource.persistWorkflow(testWorkflow2, sessionUser1) val DashboardClickableFileEntryList = dashboardResource.searchAllResourcesCall( sessionUser1, - SearchQueryParams(getKeywordsArray("common")) + SearchQueryParams(getKeywordsArray("test")) ) assert(DashboardClickableFileEntryList.results.length == 2) } it should "handle multiple keywords correctly" in { - projectResource.createProject(sessionUser1, "test project1") workflowResource.persistWorkflow(testWorkflow1, sessionUser1) + workflowResource.persistWorkflow(testWorkflow2, sessionUser1) val DashboardClickableFileEntryList = dashboardResource.searchAllResourcesCall( sessionUser1, - SearchQueryParams(getKeywordsArray("test", "project1")) + SearchQueryParams(getKeywordsArray("test", "workflow1")) ) assert( DashboardClickableFileEntryList.results.length == 1 - ) // should only return the project + ) // should only return test_workflow1 } it should "filter results by different resourceType" in { - // create different types of resources - // 3 projects, 2 file, and 1 workflow, - projectResource.createProject(sessionUser1, "test project1") - projectResource.createProject(sessionUser1, "test project2") - projectResource.createProject(sessionUser1, "test project3") + // create 3 workflows workflowResource.persistWorkflow(testWorkflow1, sessionUser1) + workflowResource.persistWorkflow(testWorkflow2, sessionUser1) + workflowResource.persistWorkflow(testWorkflow3, sessionUser1) // search resources with all resourceType var DashboardClickableFileEntryList = dashboardResource.searchAllResourcesCall( sessionUser1, SearchQueryParams(getKeywordsArray("test")) ) - assert(DashboardClickableFileEntryList.results.length == 4) + assert(DashboardClickableFileEntryList.results.length == 3) // filter resources by workflow DashboardClickableFileEntryList = dashboardResource.searchAllResourcesCall( sessionUser1, SearchQueryParams(resourceType = "workflow", keywords = getKeywordsArray("test")) ) - assert(DashboardClickableFileEntryList.results.length == 1) + assert(DashboardClickableFileEntryList.results.length == 3) - // filter resources by project + // filter resources by dataset DashboardClickableFileEntryList = dashboardResource.searchAllResourcesCall( sessionUser1, - SearchQueryParams(resourceType = "project", keywords = getKeywordsArray("test")) + SearchQueryParams(resourceType = "dataset", keywords = getKeywordsArray("test")) ) - assert(DashboardClickableFileEntryList.results.length == 3) + assert(DashboardClickableFileEntryList.results.isEmpty) + + // The counts above cannot distinguish a working filter from an ignored one, because every + // seeded row is a workflow and the only other searchable types are LakeFS-backed (a seeded + // dataset is dropped during hydration when LakeFS is unreachable, so it cannot be counted + // here -- DatasetSearchQueryBuilderSpec covers that path against a stub). Asserting that an + // unrecognised value is rejected pins that resourceType is dispatched on, not ignored. + assertThrows[IllegalArgumentException] { + dashboardResource.searchAllResourcesCall( + sessionUser1, + SearchQueryParams(resourceType = "project", keywords = getKeywordsArray("test")) + ) + } } it should "return resources that match any of all provided keywords" in { // This test is designed to verify that the searchAllResources function correctly // returns resources that match all of the provided keywords - // Create different types of resources, a project, a workflow, and a file - projectResource.createProject(sessionUser1, "test project") workflowResource.persistWorkflow(testWorkflow1, sessionUser1) + workflowResource.persistWorkflow(testWorkflow2, sessionUser1) // Perform search with multiple keywords val DashboardClickableFileEntryList = dashboardResource.searchAllResourcesCall( sessionUser1, - SearchQueryParams(keywords = getKeywordsArray("test", "project")) + SearchQueryParams(keywords = getKeywordsArray("test", "workflow2")) ) // Assert that the search results include resources that match any of the provided keywords @@ -759,8 +723,8 @@ class WorkflowResourceSpec it should "not return resources that belong to a different user" in { // This test is designed to verify that the searchAllResources function does not return resources that belong to a different user - // Create a project for a different user (sessionUser2) - projectResource.createProject(sessionUser2, "test project2") + // Create a workflow for a different user (sessionUser2) + workflowResource.persistWorkflow(testWorkflow1, sessionUser2) // Perform search for resources using sessionUser1 val DashboardClickableFileEntryList = @@ -769,7 +733,7 @@ class WorkflowResourceSpec SearchQueryParams(keywords = getKeywordsArray("test")) ) - // Assert that the search results do not include the project that belongs to the different user + // Assert that the search results do not include the workflow that belongs to the different user // Assuming that DashboardClickableFileEntryList is a list of resources where each resource has a `user` property assert(DashboardClickableFileEntryList.results.isEmpty) } @@ -777,10 +741,13 @@ class WorkflowResourceSpec it should "paginate results correctly" in { // This test is designed to verify that the pagination works correctly - // Create 1 workflow, 10 projects - workflowResource.persistWorkflow(testWorkflow1, sessionUser1) - for (i <- 1 to 10) { - projectResource.createProject(sessionUser1, s"test project $i") + // Create 11 workflows + for (i <- 1 to 11) { + val workflow = new Workflow() + workflow.setName(s"test_pagination_workflow$i") + workflow.setDescription("") + workflow.setContent(exampleContent) + workflowResource.persistWorkflow(workflow, sessionUser1) } // Request the first page of results (page size is 10) diff --git a/amber/src/test/scala/org/apache/texera/web/resource/dashboard/user/project/ProjectAccessResourceSpec.scala b/amber/src/test/scala/org/apache/texera/web/resource/dashboard/user/project/ProjectAccessResourceSpec.scala deleted file mode 100644 index 185d5afcd1d..00000000000 --- a/amber/src/test/scala/org/apache/texera/web/resource/dashboard/user/project/ProjectAccessResourceSpec.scala +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.texera.web.resource.dashboard.user.project - -import org.apache.texera.auth.SessionUser -import org.apache.texera.dao.MockTexeraDB -import org.apache.texera.dao.jooq.generated.Tables.{PROJECT, PROJECT_USER_ACCESS, USER} -import org.apache.texera.dao.jooq.generated.enums.{PrivilegeEnum, UserRoleEnum} -import org.apache.texera.dao.jooq.generated.tables.daos.{ProjectUserAccessDao, UserDao} -import org.apache.texera.dao.jooq.generated.tables.pojos.{ProjectUserAccess, User} -import org.scalatest.flatspec.AnyFlatSpec -import org.scalatest.{BeforeAndAfterAll, BeforeAndAfterEach} - -class ProjectAccessResourceSpec - extends AnyFlatSpec - with BeforeAndAfterAll - with BeforeAndAfterEach - with MockTexeraDB { - - private val ownerUid = 7101 - private val readerUid = 7102 - - private var owner: User = _ - private var reader: User = _ - private var userDao: UserDao = _ - private var projectUserAccessDao: ProjectUserAccessDao = _ - private var projectResource: ProjectResource = _ - - override protected def beforeAll(): Unit = { - initializeDBAndReplaceDSLContext() - } - - override protected def beforeEach(): Unit = { - userDao = new UserDao(getDSLContext.configuration()) - projectUserAccessDao = new ProjectUserAccessDao(getDSLContext.configuration()) - projectResource = new ProjectResource() - - owner = createUser(ownerUid, "project_owner", "project-owner@test.com") - reader = createUser(readerUid, "project_reader", "project-reader@test.com") - - cleanupTestData() - - userDao.insert(owner) - userDao.insert(reader) - } - - override protected def afterEach(): Unit = { - cleanupTestData() - } - - override protected def afterAll(): Unit = { - shutdownDB() - } - - private def createUser(uid: Int, name: String, email: String): User = { - val user = new User - user.setUid(uid) - user.setName(name) - user.setEmail(email) - user.setPassword("password") - user.setRole(UserRoleEnum.REGULAR) - user - } - - private def cleanupTestData(): Unit = { - getDSLContext - .deleteFrom(PROJECT_USER_ACCESS) - .where(PROJECT_USER_ACCESS.UID.in(ownerUid, readerUid)) - .execute() - - getDSLContext - .deleteFrom(PROJECT) - .where(PROJECT.OWNER_ID.eq(ownerUid)) - .execute() - - getDSLContext - .deleteFrom(USER) - .where(USER.UID.in(ownerUid, readerUid)) - .execute() - } - - "ProjectAccessResource.getProjectAccessPrivilege" should "return WRITE if granted" in { - val project = projectResource.createProject(new SessionUser(owner), "write-project") - val privilege = ProjectAccessResource.getProjectAccessPrivilege(project.getPid, ownerUid) - - assert(privilege == PrivilegeEnum.WRITE) - assert(ProjectAccessResource.userHasWriteAccess(project.getPid, ownerUid)) - } - - it should "return READ if a project access row grants READ" in { - val project = projectResource.createProject(new SessionUser(owner), "read-project") - projectUserAccessDao.merge( - new ProjectUserAccess(readerUid, project.getPid, PrivilegeEnum.READ) - ) - - val privilege = ProjectAccessResource.getProjectAccessPrivilege(project.getPid, readerUid) - - assert(privilege == PrivilegeEnum.READ) - assert(!ProjectAccessResource.userHasWriteAccess(project.getPid, readerUid)) - } - - it should "return NONE if the user only has access to another project" in { - val sharedProject = projectResource.createProject(new SessionUser(owner), "shared-project") - val privateProject = projectResource.createProject(new SessionUser(owner), "private-project") - projectUserAccessDao.merge( - new ProjectUserAccess(readerUid, sharedProject.getPid, PrivilegeEnum.READ) - ) - - val privilege = - ProjectAccessResource.getProjectAccessPrivilege(privateProject.getPid, readerUid) - - assert(privilege == PrivilegeEnum.NONE) - assert(!ProjectAccessResource.userHasWriteAccess(privateProject.getPid, readerUid)) - } -} diff --git a/common/config/src/main/resources/default.conf b/common/config/src/main/resources/default.conf index 62e533e694c..c99d36a79a1 100644 --- a/common/config/src/main/resources/default.conf +++ b/common/config/src/main/resources/default.conf @@ -55,9 +55,6 @@ gui { your_work_enabled = true your_work_enabled = ${?GUI_TABS_YOUR_WORK_ENABLED} - projects_enabled = false - projects_enabled = ${?GUI_TABS_PROJECTS_ENABLED} - workflows_enabled = true workflows_enabled = ${?GUI_TABS_WORKFLOWS_ENABLED} diff --git a/common/dao/src/test/scala/org/apache/texera/dao/MockTexeraDB.scala b/common/dao/src/test/scala/org/apache/texera/dao/MockTexeraDB.scala index 3ae97b62e03..3724d85dbbc 100644 --- a/common/dao/src/test/scala/org/apache/texera/dao/MockTexeraDB.scala +++ b/common/dao/src/test/scala/org/apache/texera/dao/MockTexeraDB.scala @@ -127,15 +127,6 @@ trait MockTexeraDB { | ) | ); | - |CREATE INDEX idx_user_project_name_description - | ON project - | USING GIN ( - | to_tsvector('english', - | COALESCE(name, '') || ' ' || - | COALESCE(description, '') - | ) - | ); - | |CREATE INDEX idx_dataset_name_description | ON dataset | USING GIN ( diff --git a/frontend/README.md b/frontend/README.md index be4e6b403b3..af1a932a777 100644 --- a/frontend/README.md +++ b/frontend/README.md @@ -59,7 +59,7 @@ The full testing reference (Vitest stack, recipes, anti-patterns, coverage troub | Path | What lives here | | ---------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | | `src/app/workspace/` | Workflow editor — operator graph, property panel, result panel, code editor. | -| `src/app/dashboard/` | User dashboard — workflows, datasets, projects, computing units, admin. | +| `src/app/dashboard/` | User dashboard — workflows, datasets, computing units, admin. | | `src/app/hub/` | Public hub — discover and share workflows. | | `src/app/common/` | Cross-cutting services, types, formly extensions, and shared test helpers (`common/testing/test-utils.ts`). | | `src/app/workspace/service/operator-metadata/` | Operator metadata service + the `Stub…Service` test doubles other specs reuse. | diff --git a/frontend/src/app/app-routing.constant.ts b/frontend/src/app/app-routing.constant.ts index 6e06f725201..4a1e97a0d15 100644 --- a/frontend/src/app/app-routing.constant.ts +++ b/frontend/src/app/app-routing.constant.ts @@ -29,7 +29,6 @@ export const HUB_DATASET_RESULT = `${HUB_DATASET}/result`; export const HUB_DATASET_RESULT_DETAIL = `${HUB_DATASET_RESULT}/detail`; export const USER = "/user"; -export const USER_PROJECT = `${USER}/project`; export const USER_WORKSPACE = `${USER}/workflow`; export const USER_WORKFLOW = `${USER}/workflow`; export const USER_DATASET = `${USER}/dataset`; diff --git a/frontend/src/app/app-routing.module.ts b/frontend/src/app/app-routing.module.ts index 8e5a44903e3..39a782e5d7d 100644 --- a/frontend/src/app/app-routing.module.ts +++ b/frontend/src/app/app-routing.module.ts @@ -22,8 +22,6 @@ import { RouterModule, Routes } from "@angular/router"; import { DashboardComponent } from "./dashboard/component/dashboard.component"; import { UserWorkflowComponent } from "./dashboard/component/user/user-workflow/user-workflow.component"; import { UserQuotaComponent } from "./dashboard/component/user/user-quota/user-quota.component"; -import { UserProjectSectionComponent } from "./dashboard/component/user/user-project/user-project-section/user-project-section.component"; -import { UserProjectComponent } from "./dashboard/component/user/user-project/user-project.component"; import { UserComputingUnitComponent } from "./dashboard/component/user/user-computing-unit/user-computing-unit.component"; import { WorkspaceComponent } from "./workspace/component/workspace.component"; import { AboutComponent } from "./hub/component/about/about.component"; @@ -96,14 +94,6 @@ routes.push({ path: "user", canActivate: [AuthGuardService], children: [ - { - path: "project", - component: UserProjectComponent, - }, - { - path: "project/:pid", - component: UserProjectSectionComponent, - }, { path: "workflow", component: UserWorkflowComponent, diff --git a/frontend/src/app/app.module.ts b/frontend/src/app/app.module.ts index 511395365df..963471e25ad 100644 --- a/frontend/src/app/app.module.ts +++ b/frontend/src/app/app.module.ts @@ -88,10 +88,6 @@ import { VersionsListComponent } from "./workspace/component/left-panel/versions import { NzPaginationModule } from "ng-zorro-antd/pagination"; import { JwtModule } from "@auth0/angular-jwt"; import { AuthService } from "./common/service/user/auth.service"; -import { UserProjectComponent } from "./dashboard/component/user/user-project/user-project.component"; -import { UserProjectSectionComponent } from "./dashboard/component/user/user-project/user-project-section/user-project-section.component"; -import { NgbdModalAddProjectWorkflowComponent } from "./dashboard/component/user/user-project/user-project-section/ngbd-modal-add-project-workflow/ngbd-modal-add-project-workflow.component"; -import { NgbdModalRemoveProjectWorkflowComponent } from "./dashboard/component/user/user-project/user-project-section/ngbd-modal-remove-project-workflow/ngbd-modal-remove-project-workflow.component"; import { PresetWrapperComponent } from "./common/formly/preset-wrapper/preset-wrapper.component"; import { MarkdownDescriptionComponent } from "./dashboard/component/user/markdown-description/markdown-description.component"; import { NzModalCommentBoxComponent } from "./workspace/component/workflow-editor/comment-box-modal/nz-modal-comment-box.component"; @@ -121,7 +117,6 @@ import { FileSaverService } from "./dashboard/service/user/file/file-saver.servi import { DragDropModule } from "@angular/cdk/drag-drop"; import { ScrollingModule } from "@angular/cdk/scrolling"; import { UserWorkflowListItemComponent } from "./dashboard/component/user/user-workflow/user-workflow-list-item/user-workflow-list-item.component"; -import { UserProjectListItemComponent } from "./dashboard/component/user/user-project/user-project-list-item/user-project-list-item.component"; import { SortButtonComponent } from "./dashboard/component/user/sort-button/sort-button.component"; import { FiltersComponent } from "./dashboard/component/user/filters/filters.component"; import { FiltersInstructionsComponent } from "./dashboard/component/user/filters-instructions/filters-instructions.component"; @@ -129,7 +124,6 @@ import { SearchComponent } from "./dashboard/component/user/search/search.compon import { SearchResultsComponent } from "./dashboard/component/user/search-results/search-results.component"; import { PortPropertyEditFrameComponent } from "./workspace/component/property-editor/port-property-edit-frame/port-property-edit-frame.component"; import { AdminGmailComponent } from "./dashboard/component/admin/gmail/admin-gmail.component"; -import { PublicProjectComponent } from "./dashboard/component/user/user-project/public-project/public-project.component"; import { FormlyNgZorroAntdModule } from "@ngx-formly/ng-zorro-antd"; import { FlarumComponent } from "./dashboard/component/user/flarum/flarum.component"; import { NzAlertModule } from "ng-zorro-antd/alert"; @@ -269,7 +263,6 @@ registerLocaleData(en); FormlyRepeatDndComponent, UiUdfParametersComponent, AdminGmailComponent, - PublicProjectComponent, WorkspaceComponent, MenuComponent, OperatorMenuComponent, @@ -308,10 +301,6 @@ registerLocaleData(en); ErrorFrameComponent, ResultTableFrameComponent, OperatorPropertyEditFrameComponent, - UserProjectComponent, - UserProjectSectionComponent, - NgbdModalAddProjectWorkflowComponent, - NgbdModalRemoveProjectWorkflowComponent, FilesUploaderComponent, ConflictingFileModalContentComponent, UserDatasetComponent, @@ -336,7 +325,6 @@ registerLocaleData(en); CollabWrapperComponent, AboutComponent, UserWorkflowListItemComponent, - UserProjectListItemComponent, SortButtonComponent, FiltersComponent, FiltersInstructionsComponent, diff --git a/frontend/src/app/common/service/workflow-persist/workflow-persist.service.ts b/frontend/src/app/common/service/workflow-persist/workflow-persist.service.ts index 5e738c5add2..0e3c8d34c24 100644 --- a/frontend/src/app/common/service/workflow-persist/workflow-persist.service.ts +++ b/frontend/src/app/common/service/workflow-persist/workflow-persist.service.ts @@ -107,13 +107,11 @@ export class WorkflowPersistService { /** * creates a workflow and insert it to backend database and return its information * @param targetWids - * @param pid */ - public duplicateWorkflow(targetWids: number[], pid?: number): Observable { + public duplicateWorkflow(targetWids: number[]): Observable { return this.http .post(`${AppSettings.getApiEndpoint()}/${WORKFLOW_DUPLICATE_URL}`, { wids: targetWids, - ...(pid !== undefined && { pid }), }) .pipe(filter((createdWorkflows: DashboardWorkflow[]) => createdWorkflows != null && createdWorkflows.length > 0)); } diff --git a/frontend/src/app/common/type/gui-config.ts b/frontend/src/app/common/type/gui-config.ts index 63531ee91ba..f57b21dfd38 100644 --- a/frontend/src/app/common/type/gui-config.ts +++ b/frontend/src/app/common/type/gui-config.ts @@ -52,7 +52,6 @@ export interface SidebarTabs { workflow_enabled: boolean; dataset_enabled: boolean; your_work_enabled: boolean; - projects_enabled: boolean; workflows_enabled: boolean; compute_enabled: boolean; datasets_enabled: boolean; diff --git a/frontend/src/app/dashboard/component/admin/settings/admin-settings.component.html b/frontend/src/app/dashboard/component/admin/settings/admin-settings.component.html index fd2fea7f753..a482f90973c 100644 --- a/frontend/src/app/dashboard/component/admin/settings/admin-settings.component.html +++ b/frontend/src/app/dashboard/component/admin/settings/admin-settings.component.html @@ -163,15 +163,6 @@

General Settings

- - diff --git a/frontend/src/app/dashboard/component/user/user-workflow/user-workflow.component.spec.ts b/frontend/src/app/dashboard/component/user/user-workflow/user-workflow.component.spec.ts index f082ed9dc2a..81500484a51 100644 --- a/frontend/src/app/dashboard/component/user/user-workflow/user-workflow.component.spec.ts +++ b/frontend/src/app/dashboard/component/user/user-workflow/user-workflow.component.spec.ts @@ -50,8 +50,6 @@ import { } from "../../user-dashboard-test-fixtures"; import { FiltersComponent } from "../filters/filters.component"; import { UserWorkflowListItemComponent } from "./user-workflow-list-item/user-workflow-list-item.component"; -import { UserProjectService } from "../../../service/user/project/user-project.service"; -import { StubUserProjectService } from "../../../service/user/project/stub-user-project.service"; import { SearchService } from "../../../service/user/search.service"; import { StubSearchService } from "../../../service/user/stub-search.service"; import { SearchResultsComponent } from "../search-results/search-results.component"; @@ -76,7 +74,6 @@ describe("SavedWorkflowSectionComponent", () => { providers: [ NzModalService, { provide: WorkflowPersistService, useValue: new StubWorkflowPersistService(testWorkflowEntries) }, - { provide: UserProjectService, useValue: new StubUserProjectService() }, ShareAccessService, { provide: OperatorMetadataService, useClass: StubOperatorMetadataService }, { provide: NZ_I18N, useValue: en_US }, @@ -187,23 +184,6 @@ describe("SavedWorkflowSectionComponent", () => { expect(component.filters.masterFilterList).toEqual(["id: 1", "id: 2", "id: 3"]); }); - it("searchByProjects", async () => { - component.filters.userProjectsDropdown = [ - { pid: 1, name: "Project1", checked: false }, - { pid: 2, name: "Project2", checked: false }, - { pid: 3, name: "Project3", checked: false }, - ]; - - // If the project filter is applied, only those workflows belonging to those projects should be returned. - component.filters.userProjectsDropdown[0].checked = true; - component.filters.updateSelectedProjects(); - await waitForLoading(); - expect(component.searchResultsComponent.loading).toBe(false); - const SortedCase = component.searchResultsComponent.entries.map(workflow => workflow.name); - expect(SortedCase).toEqual(["workflow 1", "workflow 2", "workflow 3"]); - expect(component.filters.masterFilterList).toEqual(["project: Project1"]); - }); - it("searchByCreationTime", async () => { // If the creation time filter is applied, only those workflows matching the date range should be returned. component.filters.selectedCtime = [new Date(1970, 0, 3), new Date(1981, 2, 13)]; @@ -266,29 +246,22 @@ describe("SavedWorkflowSectionComponent", () => { }); it("searchByManyParameters", async () => { - // Apply the project, ID, owner, and operator filter all at once. + // Apply the ID, owner, and operator filters all at once. component.filters.masterFilterList = ["1"]; const operatorGroup = component.filters.operators.get("Analysis"); if (operatorGroup) { operatorGroup[3].checked = true; // Aggregation operator component.filters.updateSelectedOperators(); - component.filters.userProjectsDropdown = [ - { pid: 1, name: "Project1", checked: false }, - { pid: 2, name: "Project2", checked: false }, - { pid: 3, name: "Project3", checked: false }, - ]; component.filters.owners[0].checked = true; //Texera component.filters.owners[1].checked = true; //Angular component.filters.wids[0].checked = true; component.filters.wids[1].checked = true; component.filters.wids[2].checked = true; //id 1,2,3 - component.filters.userProjectsDropdown[0].checked = true; //Project 1 component.filters.selectedCtime = [new Date(1970, 0, 1), new Date(1973, 2, 11)]; component.filters.selectedMtime = [new Date(1970, 0, 1), new Date(1982, 3, 14)]; //add/select new search parameter here - component.filters.updateSelectedProjects(); component.filters.updateSelectedIDs(); component.filters.updateSelectedOwners(); } @@ -305,7 +278,6 @@ describe("SavedWorkflowSectionComponent", () => { "id: 2", "id: 3", "operator: Aggregation", - "project: Project1", "ctime: 1970-01-01 ~ 1973-03-11", "mtime: 1970-01-01 ~ 1982-04-14", ]) @@ -320,7 +292,6 @@ describe("SavedWorkflowSectionComponent", () => { // StubWorkflowPersistService doesn't define createWorkflow — assign the // method here so the component's call resolves to a controlled observable. persist.createWorkflow = vi.fn().mockReturnValue(of({ workflow: { wid: 99 } })); - component.pid = undefined; component.onClickCreateNewWorkflowFromDashboard(); diff --git a/frontend/src/app/dashboard/component/user/user-workflow/user-workflow.component.ts b/frontend/src/app/dashboard/component/user/user-workflow/user-workflow.component.ts index 584191f8bf5..092c188b7d2 100644 --- a/frontend/src/app/dashboard/component/user/user-workflow/user-workflow.component.ts +++ b/frontend/src/app/dashboard/component/user/user-workflow/user-workflow.component.ts @@ -17,7 +17,7 @@ * under the License. */ -import { AfterViewInit, Component, Input, ViewChild } from "@angular/core"; +import { AfterViewInit, Component, ViewChild } from "@angular/core"; import { Router } from "@angular/router"; import { NzModalService } from "ng-zorro-antd/modal"; import { firstValueFrom, from, lastValueFrom, Observable, of } from "rxjs"; @@ -25,8 +25,6 @@ import { DEFAULT_WORKFLOW_NAME, WorkflowPersistService, } from "../../../../common/service/workflow-persist/workflow-persist.service"; -import { NgbdModalAddProjectWorkflowComponent } from "../user-project/user-project-section/ngbd-modal-add-project-workflow/ngbd-modal-add-project-workflow.component"; -import { NgbdModalRemoveProjectWorkflowComponent } from "../user-project/user-project-section/ngbd-modal-remove-project-workflow/ngbd-modal-remove-project-workflow.component"; import { DashboardEntry, UserInfo } from "../../../type/dashboard-entry"; import { UserService } from "../../../../common/service/user/user.service"; import { UntilDestroy, untilDestroyed } from "@ngneat/until-destroy"; @@ -38,9 +36,7 @@ import { FiltersComponent } from "../filters/filters.component"; import { SearchResultsComponent } from "../search-results/search-results.component"; import { SearchService } from "../../../service/user/search.service"; import { SortMethod } from "../../../type/sort-method"; -import { isDefined } from "../../../../common/util/predicate"; -import { UserProjectService } from "../../../service/user/project/user-project.service"; -import { map, mergeMap, switchMap, tap } from "rxjs/operators"; +import { map, switchMap, tap } from "rxjs/operators"; import { DashboardWorkflow } from "../../../type/dashboard-workflow.interface"; import { DownloadService } from "../../../service/user/download/download.service"; import { USER_WORKSPACE } from "../../../../app-routing.constant"; @@ -61,7 +57,7 @@ import { FormsModule } from "@angular/forms"; /** * Saved-workflow-section component contains information and functionality - * of the saved workflows section and is re-used in the user projects section when a project is clicked + * of the saved workflows section: the list of workflows the user owns or has access to * * This component: * - displays the workflows the user has access to @@ -137,16 +133,12 @@ export class UserWorkflowComponent implements AfterViewInit { } private masterFilterList: ReadonlyArray | null = null; - // receive input from parent components (UserProjectSection), if any - @Input() public pid?: number = undefined; - @Input() public accessLevel?: string = undefined; public sortMethod = SortMethod.EditTimeDesc; lastSortMethod: SortMethod | null = null; constructor( private userService: UserService, private workflowPersistService: WorkflowPersistService, - private userProjectService: UserProjectService, private notificationService: NotificationService, private modalService: NzModalService, private router: Router, @@ -186,34 +178,6 @@ export class UserWorkflowComponent implements AfterViewInit { .subscribe(() => this.search()); } - /** - * open the Modal to add workflow(s) to project - */ - public onClickOpenAddWorkflow() { - const modalRef = this.modalService.create({ - nzContent: NgbdModalAddProjectWorkflowComponent, - nzData: { projectId: this.pid }, - nzFooter: null, - nzTitle: "Add Workflows To Project", - nzCentered: true, - }); - modalRef.afterClose.pipe(untilDestroyed(this)).subscribe(() => this.search(true)); - } - - /** - * open the Modal to remove workflow(s) from project - */ - public onClickOpenRemoveWorkflow() { - const modalRef = this.modalService.create({ - nzContent: NgbdModalRemoveProjectWorkflowComponent, - nzData: { projectId: this.pid }, - nzFooter: null, - nzTitle: "Remove Workflows From Project", - nzCentered: true, - }); - modalRef.afterClose.pipe(untilDestroyed(this)).subscribe(() => this.search(true)); - } - /** * Searches workflows with keywords and filters given in the masterFilterList. * @returns @@ -230,10 +194,6 @@ export class UserWorkflowComponent implements AfterViewInit { this.lastSortMethod = this.sortMethod; this.masterFilterList = this.filters.masterFilterList; let filterParams = this.filters.getSearchFilterParameters(); - if (isDefined(this.pid)) { - // force the project id in the search query to be the current pid. - filterParams.projectIds = [this.pid]; - } this.searchResultsComponent.reset((start, count) => { return firstValueFrom( this.searchService @@ -267,7 +227,6 @@ export class UserWorkflowComponent implements AfterViewInit { executionMode: this.config.env.defaultExecutionMode, }, }; - let localPid = this.pid; this.workflowPersistService .createWorkflow(emptyWorkflowContent, DEFAULT_WORKFLOW_NAME) .pipe( @@ -276,18 +235,7 @@ export class UserWorkflowComponent implements AfterViewInit { throw new Error("Workflow creation failed."); } }), - mergeMap(createdWorkflow => { - // Check if localPid is defined; if so, add the workflow to the project - if (localPid) { - return this.userProjectService.addWorkflowToProject(localPid, createdWorkflow.workflow.wid!).pipe( - // Regardless of the project addition outcome, pass the wid downstream - map(() => createdWorkflow.workflow.wid) - ); - } else { - // If there's no localPid, skip adding to the project and directly pass the wid downstream - return of(createdWorkflow.workflow.wid); - } - }), + map(createdWorkflow => createdWorkflow.workflow.wid), untilDestroyed(this) ) .subscribe({ @@ -302,24 +250,13 @@ export class UserWorkflowComponent implements AfterViewInit { /** * duplicate the current workflow. A new record will appear in frontend * workflow list and backend database. - * - * for workflow components inside a project-section, it will also add - * the workflow to the project */ public async onClickDuplicateWorkflow(entry: DashboardEntry): Promise { if (entry.workflow.workflow.wid) { try { - let duplicatedWorkflowsInfo: DashboardWorkflow[] = []; - if (!isDefined(this.pid)) { - duplicatedWorkflowsInfo = await firstValueFrom( - this.workflowPersistService.duplicateWorkflow([entry.workflow.workflow.wid]) - ); - } else { - const localPid = this.pid; - duplicatedWorkflowsInfo = await firstValueFrom( - this.workflowPersistService.duplicateWorkflow([entry.workflow.workflow.wid], localPid) - ); - } + const duplicatedWorkflowsInfo: DashboardWorkflow[] = await firstValueFrom( + this.workflowPersistService.duplicateWorkflow([entry.workflow.workflow.wid]) + ); const userIds = new Set(); duplicatedWorkflowsInfo.forEach(workflow => { @@ -501,38 +438,20 @@ export class UserWorkflowComponent implements AfterViewInit { } if (targetWids.length > 0) { - if (!isDefined(this.pid)) { - this.workflowPersistService - .duplicateWorkflow(targetWids) - .pipe(untilDestroyed(this)) - .subscribe({ - next: duplicatedWorkflowsInfo => { - this.searchResultsComponent.entries = [ - ...duplicatedWorkflowsInfo.map(duplicatedWorkflowInfo => new DashboardEntry(duplicatedWorkflowInfo)), - ...this.searchResultsComponent.entries, - ]; - - // this.searchResultsComponent.clearAllSelections(); - }, // TODO: fix this with notification component - error: (err: unknown) => alert(err), - }); - } else { - const localPid = this.pid; - this.workflowPersistService - .duplicateWorkflow(targetWids, localPid) - .pipe(untilDestroyed(this)) - .subscribe({ - next: duplicatedWorkflowsInfo => { - this.searchResultsComponent.entries = [ - ...duplicatedWorkflowsInfo.map(duplicatedWorkflowInfo => new DashboardEntry(duplicatedWorkflowInfo)), - ...this.searchResultsComponent.entries, - ]; - - // this.searchResultsComponent.clearAllSelections(); - }, // TODO: fix this with notification component - error: (err: unknown) => alert(err), - }); - } + this.workflowPersistService + .duplicateWorkflow(targetWids) + .pipe(untilDestroyed(this)) + .subscribe({ + next: duplicatedWorkflowsInfo => { + this.searchResultsComponent.entries = [ + ...duplicatedWorkflowsInfo.map(duplicatedWorkflowInfo => new DashboardEntry(duplicatedWorkflowInfo)), + ...this.searchResultsComponent.entries, + ]; + + // this.searchResultsComponent.clearAllSelections(); + }, // TODO: fix this with notification component + error: (err: unknown) => alert(err), + }); } } diff --git a/frontend/src/app/dashboard/service/user/project/stub-user-project.service.ts b/frontend/src/app/dashboard/service/user/project/stub-user-project.service.ts deleted file mode 100644 index 8689cd326ed..00000000000 --- a/frontend/src/app/dashboard/service/user/project/stub-user-project.service.ts +++ /dev/null @@ -1,120 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { Observable } from "rxjs"; -import { DashboardProject } from "../../../type/dashboard-project.interface"; -import { DashboardWorkflow } from "../../../type/dashboard-workflow.interface"; -import { DashboardFile } from "../../../type/dashboard-file.interface"; -import { UserProjectService } from "./user-project.service"; -import { testUserProjects } from "../../../component/user-dashboard-test-fixtures"; - -export class StubUserProjectService { - public getProjectList(): Observable { - return new Observable(observer => observer.next(testUserProjects.slice())); - } - - public retrieveWorkflowsOfProject(pid: number): Observable { - throw new Error("Not implemented."); - } - - public retrieveFilesOfProject(pid: number): Observable { - throw new Error("Not implemented."); - } - - public getProjectFiles(): ReadonlyArray { - throw new Error("Not implemented."); - } - - public refreshFilesOfProject(pid: number): void { - throw new Error("Not implemented."); - } - - public retrieveProject(pid: number): Observable { - throw new Error("Not implemented."); - } - - public updateProjectName(pid: number, name: string): Observable { - throw new Error("Not implemented."); - } - - public updateProjectDescription(pid: number, description: string): Observable { - throw new Error("Not implemented."); - } - - public deleteProject(pid: number): Observable { - throw new Error("Not implemented."); - } - - public createProject(name: string): Observable { - throw new Error("Not implemented."); - } - - public addWorkflowToProject(pid: number, wid: number): Observable { - throw new Error("Not implemented."); - } - - public removeWorkflowFromProject(pid: number, wid: number): Observable { - throw new Error("Not implemented."); - } - - public addFileToProject(pid: number, fid: number): Observable { - throw new Error("Not implemented."); - } - - public updateProjectColor(pid: number, colorHex: string): Observable { - throw new Error("Not implemented."); - } - - public deleteProjectColor(pid: number): Observable { - throw new Error("Not implemented."); - } - - public removeFileFromProject(pid: number, fid: number): Observable { - throw new Error("Not implemented."); - } - - /** - * same as UserFileService"s deleteDashboardUserFileEntry method, except - * it is modified to refresh the project"s list of files - */ - public deleteDashboardUserFileEntry(pid: number, targetUserFileEntry: DashboardFile): void { - throw new Error("Not implemented."); - } - - /** - * Helper function to determine if a project color is light - * or dark, which can be helpful for styling decisions - * - * @param color (HEX formatted color string) - * @returns boolean indicating whether color is "light" or "dark" - */ - public isLightColor(color: string): boolean { - return UserProjectService.isLightColor(color); - } - - /** - * Helper function to validate if a project color is in HEX format - * - * @param color - * @returns boolean indicating whether color is in valid HEX format - */ - public isInvalidColorFormat(color: string): boolean { - return UserProjectService.isInvalidColorFormat(color); - } -} diff --git a/frontend/src/app/dashboard/service/user/project/user-project.service.ts b/frontend/src/app/dashboard/service/user/project/user-project.service.ts deleted file mode 100644 index dbac0ae2603..00000000000 --- a/frontend/src/app/dashboard/service/user/project/user-project.service.ts +++ /dev/null @@ -1,170 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { HttpClient } from "@angular/common/http"; -import { Injectable } from "@angular/core"; -import { Observable } from "rxjs"; -import { AppSettings } from "../../../../common/app-setting"; -import { DashboardWorkflow } from "../../../type/dashboard-workflow.interface"; -import { DashboardFile } from "../../../type/dashboard-file.interface"; -import { DashboardProject } from "../../../type/dashboard-project.interface"; -import { NotificationService } from "../../../../common/service/notification/notification.service"; - -export const USER_PROJECT_BASE_URL = `${AppSettings.getApiEndpoint()}/project`; -export const USER_PROJECT_LIST_URL = `${USER_PROJECT_BASE_URL}/list`; -export const DELETE_PROJECT_URL = `${USER_PROJECT_BASE_URL}/delete`; -export const CREATE_PROJECT_URL = `${USER_PROJECT_BASE_URL}/create`; -export const USER_FILE_BASE_URL = `${AppSettings.getApiEndpoint()}/user/file`; -export const USER_FILE_DELETE_URL = `${USER_FILE_BASE_URL}/delete`; - -@Injectable({ - providedIn: "root", -}) -export class UserProjectService { - private files: ReadonlyArray = []; - - constructor( - private http: HttpClient, - private notificationService: NotificationService - ) {} - - public getProjectList(): Observable { - return this.http.get(`${USER_PROJECT_LIST_URL}`); - } - - public retrieveWorkflowsOfProject(pid: number): Observable { - return this.http.get(`${USER_PROJECT_BASE_URL}/${pid}/workflows`); - } - - public retrieveFilesOfProject(pid: number): Observable { - return this.http.get(`${USER_PROJECT_BASE_URL}/${pid}/files`); - } - - public getProjectFiles(): ReadonlyArray { - return this.files; - } - - public refreshFilesOfProject(pid: number): void { - this.retrieveFilesOfProject(pid).subscribe(files => { - this.files = files; - }); - } - - public retrieveProject(pid: number): Observable { - return this.http.get(`${USER_PROJECT_BASE_URL}/${pid}`); - } - - public updateProjectName(pid: number, name: string): Observable { - return this.http.post(`${USER_PROJECT_BASE_URL}/${pid}/rename/${name}`, {}); - } - - public updateProjectDescription(pid: number, description: string): Observable { - return this.http.post(`${USER_PROJECT_BASE_URL}/${pid}/update/description`, `${description}`); - } - - public deleteProject(pid: number): Observable { - return this.http.delete(`${DELETE_PROJECT_URL}/` + pid); - } - - public createProject(name: string): Observable { - return this.http.post(`${CREATE_PROJECT_URL}/` + name, {}); - } - - public addWorkflowToProject(pid: number, wid: number): Observable { - return this.http.post(`${USER_PROJECT_BASE_URL}/${pid}/workflow/${wid}/add`, {}); - } - - public removeWorkflowFromProject(pid: number, wid: number): Observable { - return this.http.delete(`${USER_PROJECT_BASE_URL}/${pid}/workflow/${wid}/delete`, {}); - } - - public addFileToProject(pid: number, fid: number): Observable { - return this.http.post(`${USER_PROJECT_BASE_URL}/${pid}/user-file/${fid}/add`, {}); - } - - public updateProjectColor(pid: number, colorHex: string): Observable { - return this.http.post(`${USER_PROJECT_BASE_URL}/${pid}/color/${colorHex}/add`, {}); - } - - public deleteProjectColor(pid: number): Observable { - return this.http.post(`${USER_PROJECT_BASE_URL}/${pid}/color/delete`, {}); - } - - public removeFileFromProject(pid: number, fid: number): Observable { - return this.http.delete(`${USER_PROJECT_BASE_URL}/${pid}/user-file/${fid}/delete`, {}); - } - - /** - * same as UserFileService"s deleteDashboardUserFileEntry method, except - * it is modified to refresh the project"s list of files - */ - public deleteDashboardUserFileEntry(pid: number, targetUserFileEntry: DashboardFile): void { - this.http - .delete(`${USER_FILE_DELETE_URL}/${targetUserFileEntry.file.name}/${targetUserFileEntry.ownerEmail}`) - .subscribe({ - next: () => { - this.refreshFilesOfProject(pid); // refresh files within project - }, - // @ts-ignore // TODO: fix this with notification component - error: (err: unknown) => alert("Cannot delete the file entry: " + err.error), - }); - } - - /** - * Helper function to determine if a project color is light - * or dark, which can be helpful for styling decisions - * - * @param color (HEX formatted color string) - * @returns boolean indicating whether color is "light" or "dark" - */ - public static isLightColor(color: string): boolean { - if (this.isInvalidColorFormat(color)) { - return false; // default color is dark - } - - // ensure format is in 6 digit HEX - if (color.length == 3) { - color = color - .split("") - .map(s => s + s) - .join(""); - } - - // convert to RGB form - let colorRGB: number = +("0x" + color); - - let r: number = colorRGB >> 16; - let g: number = (colorRGB >> 8) & 255; - let b: number = colorRGB & 255; - - // estimate HSV value - let hsv: number = Math.sqrt(0.299 * (r * r) + 0.587 * (g * g) + 0.114 * (b * b)); - return hsv > 200; - } - - /** - * Helper function to validate if a project color is in HEX format - * - * @param color - * @returns boolean indicating whether color is in valid HEX format - */ - public static isInvalidColorFormat(color: string) { - return color == null || (color.length != 6 && color.length != 3) || !/^([0-9A-Fa-f]{3}){1,2}$/.test(color); - } -} diff --git a/frontend/src/app/dashboard/service/user/public-project/public-project.service.ts b/frontend/src/app/dashboard/service/user/public-project/public-project.service.ts deleted file mode 100644 index a6d35f610d7..00000000000 --- a/frontend/src/app/dashboard/service/user/public-project/public-project.service.ts +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { HttpClient } from "@angular/common/http"; -import { Injectable } from "@angular/core"; -import { Observable } from "rxjs"; -import { AppSettings } from "../../../../common/app-setting"; -import { PublicProject } from "../../../type/dashboard-project.interface"; - -export const USER_BASE_URL = `${AppSettings.getApiEndpoint()}/public/project`; - -@Injectable({ - providedIn: "root", -}) -export class PublicProjectService { - constructor(private http: HttpClient) {} - - public getType(pid: number): Observable { - return this.http.get(`${USER_BASE_URL}/type/${pid}`, { responseType: "text" }); - } - - public makePublic(pid: number): Observable { - return this.http.put(`${USER_BASE_URL}/public/${pid}`, null); - } - - public makePrivate(pid: number): Observable { - return this.http.put(`${USER_BASE_URL}/private/${pid}`, null); - } - - public getPublicProjects(): Observable { - return this.http.get(`${USER_BASE_URL}/list`); - } - - public addPublicProjects(CheckedId: number[]): Observable { - return this.http.put(`${USER_BASE_URL}/add`, CheckedId); - } -} diff --git a/frontend/src/app/dashboard/service/user/search.service.spec.ts b/frontend/src/app/dashboard/service/user/search.service.spec.ts index c80df0441bd..f59f925712f 100644 --- a/frontend/src/app/dashboard/service/user/search.service.spec.ts +++ b/frontend/src/app/dashboard/service/user/search.service.spec.ts @@ -30,7 +30,6 @@ import { SearchFilterParameters } from "../../type/search-filter-parameters"; import { SortMethod } from "../../type/sort-method"; import { SearchResult, SearchResultItem } from "../../type/search-result"; import { DashboardWorkflow } from "../../type/dashboard-workflow.interface"; -import { DashboardProject } from "../../type/dashboard-project.interface"; import { DashboardDataset } from "../../type/dashboard-dataset.interface"; const API = "api"; @@ -44,7 +43,6 @@ function makeEmptyFilter(): SearchFilterParameters { owners: [], ids: [], operators: [], - projectIds: [], }; } @@ -68,26 +66,12 @@ function makeWorkflowItem(wid: number, ownerId: number): SearchResultItem { settings: { dataTransferBatchSize: 400, executionMode: "PIPELINED" as any }, }, }, - projectIDs: [], accessLevel: "WRITE", ownerId, }; return { resourceType: "workflow", workflow }; } -function makeProjectItem(pid: number, ownerId: number): SearchResultItem { - const project: DashboardProject = { - pid, - name: `proj-${pid}`, - description: "", - ownerId, - creationTime: 0, - color: null, - accessLevel: "WRITE", - }; - return { resourceType: "project", project }; -} - function makeDatasetItem(did: number, ownerUid: number): SearchResultItem { const dataset: DashboardDataset = { isOwner: true, @@ -173,6 +157,25 @@ describe("SearchService", () => { expect(req.request.url).toContain("includePublic=true"); req.flush({ results: [], more: false }); }); + + it("drops rows whose resource type this client does not model, keeping the modelled ones", async () => { + // The unified-search response can still carry types the client has no payload for -- a + // project row while the backend half of the removal is unmerged, or a type the server + // gains first. Downstream `convertToName`/`DashboardEntry` throw on those, and the search + // bar subscribes with no error handler, so one such row would kill the autocomplete for + // the session. It has to be dropped here rather than reach a consumer. + const wf = makeWorkflowItem(11, 7); + const unmodelled = { resourceType: "project", project: { pid: 3, name: "p" } } as unknown as SearchResultItem; + const pending = firstValueFrom( + service.search(["k"], makeEmptyFilter(), 0, 10, null, SortMethod.NameAsc, true, false) + ); + http.expectOne(r => r.url.startsWith(`${API}/dashboard/search`)).flush({ results: [unmodelled, wf], more: true }); + + const got = await pending; + expect(got.results).toEqual([wf]); + // `more` and the rest of the envelope must survive the filter untouched. + expect(got.more).toBe(true); + }); }); // ─── getUserInfo ────────────────────────────────────────────────────────── @@ -276,22 +279,6 @@ describe("SearchService", () => { expect(persistSpy.getSizes).not.toHaveBeenCalled(); }); - it("uses Project entity routing for project items", async () => { - const proj = makeProjectItem(20, 8); - vi.spyOn(service, "getUserInfo").mockReturnValue(of({ 8: { userName: "bob" } })); - hubSpy.getCounts.mockReturnValue( - of([{ entityId: 20, entityType: EntityType.Project, counts: { [ActionType.Clone]: 2 } }]) - ); - - const [entry] = await firstValueFrom(service.extendSearchResultsWithHubActivityInfo([proj], true)); - - const [types, ids] = hubSpy.getCounts.mock.calls[0]; - expect(types).toEqual([EntityType.Project]); - expect(ids).toEqual([20]); - expect(entry.cloneCount).toBe(2); - expect(entry.ownerName).toBe("bob"); - }); - it("uses Dataset entity routing and pulls ownerUid for dataset items", async () => { const ds = makeDatasetItem(30, 9); const userInfoSpy = vi.spyOn(service, "getUserInfo").mockReturnValue(of({ 9: { userName: "carol" } })); @@ -306,10 +293,10 @@ describe("SearchService", () => { }); it("does not request sizes when there are no workflow items", async () => { - const proj = makeProjectItem(20, 8); + const ds = makeDatasetItem(20, 8); vi.spyOn(service, "getUserInfo").mockReturnValue(of({} as any)); - await firstValueFrom(service.extendSearchResultsWithHubActivityInfo([proj], true)); + await firstValueFrom(service.extendSearchResultsWithHubActivityInfo([ds], true)); expect(persistSpy.getSizes).not.toHaveBeenCalled(); }); diff --git a/frontend/src/app/dashboard/service/user/search.service.ts b/frontend/src/app/dashboard/service/user/search.service.ts index a48ff8991d6..f8f58ca1970 100644 --- a/frontend/src/app/dashboard/service/user/search.service.ts +++ b/frontend/src/app/dashboard/service/user/search.service.ts @@ -59,7 +59,7 @@ export class SearchService { * @param params - Additional search filter parameters. * @param start - The starting index for paginated results. * @param count - The number of results to retrieve. - * @param type - The type of resource to search for ("workflow", "project", "dataset", "file", or null (all resource type)). + * @param type - The type of resource to search for ("workflow", "dataset", "file", or null (all resource type)). * @param orderBy - Specifies the sorting method. * @param isLogin - Indicates if the user is logged in. * - `isLogin = true`: Use the authenticated search endpoint, retrieving both user-accessible and public resources based on `includePublic`. @@ -73,7 +73,7 @@ export class SearchService { params: SearchFilterParameters, start: number, count: number, - type: "workflow" | "project" | "file" | "dataset" | null, + type: "workflow" | "file" | "dataset" | null, orderBy: SortMethod, isLogin: boolean, includePublic: boolean = false @@ -84,9 +84,31 @@ export class SearchService { const finalIncludePublic = isLogin ? includePublic : true; - return this.http.get( - `${url}?${toQueryStrings(keywords, params, start, count, type, orderBy)}&includePublic=${finalIncludePublic}` - ); + return this.http + .get( + `${url}?${toQueryStrings(keywords, params, start, count, type, orderBy)}&includePublic=${finalIncludePublic}` + ) + .pipe( + map(result => ({ + ...result, + // The unified-search response can carry resource types this client does not model: + // rows from a feature being removed server-side later than here, or a type the backend + // gains first. Both `convertToName` and `DashboardEntry` throw on an unrecognised + // payload, and the autocomplete subscribes without an error handler, so a single such + // row would otherwise kill the subscription for the rest of the session. Dropping them + // at the funnel every consumer calls keeps a stale row merely invisible. + // + // Known trade-off: the server counted these rows against offset/limit, and + // `SearchResultsComponent.loadMore` starts the next page at `entries.length` and appends + // without dedup. So on the "All" tab a window holding k dropped rows re-fetches k + // already-shown rows, and a window that is entirely dropped rows leaves `entries.length` + // unmoved -- "Load more" re-requests the same window while `more` stays true. Typed tabs + // and the search bar are unaffected. Not corrected here: that belongs in the + // `LoadMoreFunction` contract shared by all five callers of `SearchResultsComponent.reset`, + // and removing the backend half (#7461) ends the only condition that produces such rows. + results: result.results.filter(item => item.workflow != null || item.file != null || item.dataset != null), + })) + ); } public getUserInfo(userIds: number[]): Observable<{ [key: number]: UserInfo }> { @@ -102,7 +124,7 @@ export class SearchService { * This method: * - Dispatches a paginated search request (authenticated or public) via `this.search(...)`. * - Filters out null or mismatched datasets when `type === 'dataset'` and sets `hasMismatch`. - * - Fetches owner information (name, Google avatar) in batch for workflows, projects, and datasets. + * - Fetches owner information (name, Google avatar) in batch for workflows and datasets. * - Aggregates view/clone/like counts via the batch counts API. * - Constructs `DashboardEntry` instances and attaches owner info and counts. * @@ -110,7 +132,7 @@ export class SearchService { * @param params Additional search filter parameters. * @param start The starting index for paginated results. * @param count The number of results to retrieve. - * @param type The type of resource to search for ("workflow", "project", "dataset", "file", or null (all resource type)). + * @param type The type of resource to search for ("workflow", "dataset", "file", or null (all resource type)). * @param orderBy Specifies the sorting method. * @param isLogin Indicates if the user is logged in. * @param includePublic Specifies whether to include public resources in the search results. @@ -125,7 +147,7 @@ export class SearchService { params: SearchFilterParameters, start: number, count: number, - type: "workflow" | "project" | "dataset" | "file" | null, + type: "workflow" | "dataset" | "file" | null, orderBy: SortMethod, isLogin: boolean, includePublic: boolean @@ -170,8 +192,7 @@ export class SearchService { const userIds = new Set(); items.forEach(i => { - if (i.project) userIds.add(i.project.ownerId); - else if (i.workflow) userIds.add(i.workflow.ownerId); + if (i.workflow) userIds.add(i.workflow.ownerId); else if (i.dataset?.dataset?.ownerUid != null) userIds.add(i.dataset.dataset.ownerUid); }); const userInfo$ = userIds.size ? this.getUserInfo(Array.from(userIds)) : of({} as Record); @@ -182,9 +203,6 @@ export class SearchService { if (i.workflow?.workflow?.wid != null) { entityTypes.push(EntityType.Workflow); entityIds.push(i.workflow.workflow.wid); - } else if (i.project) { - entityTypes.push(EntityType.Project); - entityIds.push(i.project.pid); } else if (i.dataset?.dataset?.did != null) { entityTypes.push(EntityType.Dataset); entityIds.push(i.dataset.dataset.did); @@ -220,18 +238,10 @@ export class SearchService { access.forEach(r => (accessMap[`${r.entityType}:${r.entityId}`] = r.userIds)); return items.map(i => { - const entry = i.workflow - ? new DashboardEntry(i.workflow) - : i.project - ? new DashboardEntry(i.project) - : new DashboardEntry(i.dataset!); + const entry = i.workflow ? new DashboardEntry(i.workflow) : new DashboardEntry(i.dataset!); const key = `${entry.type}:${entry.id}`; - const ownerId = i.workflow - ? i.workflow.ownerId - : i.project - ? i.project.ownerId - : i.dataset!.dataset!.ownerUid!; + const ownerId = i.workflow ? i.workflow.ownerId : i.dataset!.dataset!.ownerUid!; const ui = (userMap as any)[ownerId]; if (ui) { entry.setOwnerName(ui.userName); diff --git a/frontend/src/app/dashboard/service/user/stub-search.service.ts b/frontend/src/app/dashboard/service/user/stub-search.service.ts index 6ab1628626f..441f095bc6a 100644 --- a/frontend/src/app/dashboard/service/user/stub-search.service.ts +++ b/frontend/src/app/dashboard/service/user/stub-search.service.ts @@ -43,7 +43,7 @@ export class StubSearchService { params: SearchFilterParameters, start: number, count: number, - type: "workflow" | "project" | "file" | "dataset" | null, + type: "workflow" | "file" | "dataset" | null, orderBy: SortMethod, isLogin: boolean = true, includePublic: boolean = false @@ -54,7 +54,6 @@ export class StubSearchService { results: searchTestEntries(keywords, params, this.testEntries, type).map(i => ({ resourceType: i.type, workflow: i.type === "workflow" ? i.workflow : undefined, - project: i.type === "project" ? i.project : undefined, })), more: false, }); @@ -80,7 +79,7 @@ export class StubSearchService { params: SearchFilterParameters, start: number, count: number, - type: "workflow" | "project" | "dataset" | "file" | null, + type: "workflow" | "dataset" | "file" | null, orderBy: SortMethod, isLogin: boolean, includePublic: boolean @@ -95,7 +94,6 @@ export class StubSearchService { i => this.testEntries.find(e => { if (i.workflow && e.type === "workflow" && e.workflow === i.workflow) return true; - if (i.project && e.type === "project" && e.project === i.project) return true; if (i.dataset && e.type === "dataset" && e.dataset === i.dataset) return true; return false; })! diff --git a/frontend/src/app/dashboard/type/dashboard-entry.ts b/frontend/src/app/dashboard/type/dashboard-entry.ts index b2949b080df..e5e529c13d7 100644 --- a/frontend/src/app/dashboard/type/dashboard-entry.ts +++ b/frontend/src/app/dashboard/type/dashboard-entry.ts @@ -19,13 +19,11 @@ import { DashboardFile } from "./dashboard-file.interface"; import { DashboardWorkflow } from "./dashboard-workflow.interface"; -import { DashboardProject } from "./dashboard-project.interface"; import { DashboardDataset } from "./dashboard-dataset.interface"; import { DashboardWorkflowComputingUnit } from "../../common/type/workflow-computing-unit"; import { isDashboardDataset, isDashboardFile, - isDashboardProject, isDashboardWorkflow, isDashboardWorkflowComputingUnit, } from "./type-predicates"; @@ -57,14 +55,7 @@ export class DashboardEntry { accessibleUserIds: number[]; coverImageUrl?: string; - constructor( - public value: - | DashboardWorkflow - | DashboardProject - | DashboardFile - | DashboardDataset - | DashboardWorkflowComputingUnit - ) { + constructor(public value: DashboardWorkflow | DashboardFile | DashboardDataset | DashboardWorkflowComputingUnit) { if (isDashboardWorkflow(value)) { this.type = EntityType.Workflow; this.id = value.workflow.wid; @@ -83,24 +74,6 @@ export class DashboardEntry { this.likeCount = 0; this.isLiked = false; this.accessibleUserIds = []; - } else if (isDashboardProject(value)) { - this.type = EntityType.Project; - this.id = value.pid; - this.name = value.name; - this.description = ""; - this.creationTime = value.creationTime; - this.lastModifiedTime = value.creationTime; - this.accessLevel = value.accessLevel; - this.ownerName = ""; - this.ownerEmail = ""; - this.ownerGoogleAvatar = ""; - this.ownerId = value.ownerId; - this.size = 0; - this.viewCount = 0; - this.cloneCount = 0; - this.likeCount = 0; - this.isLiked = false; - this.accessibleUserIds = []; } else if (isDashboardFile(value)) { this.type = EntityType.File; this.id = value.file.fid; @@ -183,13 +156,6 @@ export class DashboardEntry { this.size = size; } - get project(): DashboardProject { - if (!isDashboardProject(this.value)) { - throw new Error("Value is not of type DashboardProject."); - } - return this.value; - } - get workflow(): DashboardWorkflow { if (!isDashboardWorkflow(this.value)) { throw new Error("Value is not of type DashboardWorkflow."); diff --git a/frontend/src/app/dashboard/type/dashboard-project.interface.ts b/frontend/src/app/dashboard/type/dashboard-project.interface.ts deleted file mode 100644 index 4e84bb16c0b..00000000000 --- a/frontend/src/app/dashboard/type/dashboard-project.interface.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -export interface DashboardProject { - pid: number; - name: string; - description: string; - ownerId: number; - creationTime: number; - color: string | null; - accessLevel: string; -} - -export interface PublicProject { - pid: number; - name: string; - owner: string; - creationTime: number; -} diff --git a/frontend/src/app/dashboard/type/dashboard-workflow.interface.ts b/frontend/src/app/dashboard/type/dashboard-workflow.interface.ts index 1a2a340a0d6..4bf43ff6346 100644 --- a/frontend/src/app/dashboard/type/dashboard-workflow.interface.ts +++ b/frontend/src/app/dashboard/type/dashboard-workflow.interface.ts @@ -23,7 +23,6 @@ export interface DashboardWorkflow { isOwner: boolean; ownerName: string | undefined; workflow: Workflow; - projectIDs: number[]; accessLevel: string; ownerId: number; } diff --git a/frontend/src/app/dashboard/type/search-filter-parameters.ts b/frontend/src/app/dashboard/type/search-filter-parameters.ts index 8cf39fc5a8c..a573d63d092 100644 --- a/frontend/src/app/dashboard/type/search-filter-parameters.ts +++ b/frontend/src/app/dashboard/type/search-filter-parameters.ts @@ -28,7 +28,6 @@ export interface SearchFilterParameters { owners: string[]; ids: string[]; operators: string[]; - projectIds: number[]; } export const toQueryStrings = ( @@ -36,7 +35,7 @@ export const toQueryStrings = ( params: SearchFilterParameters, start?: number, count?: number, - type?: "workflow" | "project" | "file" | "dataset" | null, + type?: "workflow" | "file" | "dataset" | null, orderBy?: SortMethod ): string => { function* getQueryParameters(): Iterable<[name: string, value: string]> { @@ -62,9 +61,6 @@ export const toQueryStrings = ( for (const operator of params.operators) { yield ["operator", operator]; } - for (const id of params.projectIds) { - yield ["projectId", id.toString()]; - } } const concatenateQueryStrings = (queryStrings: ReturnType): string => [ @@ -85,7 +81,7 @@ export const searchTestEntries = ( keywords: string[], params: SearchFilterParameters, testEntries: DashboardEntry[], - type: "workflow" | "project" | "file" | "dataset" | null + type: "workflow" | "file" | "dataset" | null ): DashboardEntry[] => { const endOfDay = (date: Date) => { date.setHours(23); @@ -130,13 +126,6 @@ export const searchTestEntries = ( ) ); } - if (params.projectIds.length > 0) { - testEntries = testEntries.filter( - e => - e.type === "workflow" && - e.workflow.projectIDs.some(id => params.projectIds.some(projectIdToFilterBy => projectIdToFilterBy == id)) - ); - } if (type) { testEntries = testEntries.filter(e => e.type === type); } diff --git a/frontend/src/app/dashboard/type/search-result.ts b/frontend/src/app/dashboard/type/search-result.ts index 8fc14361b17..07c6077369e 100644 --- a/frontend/src/app/dashboard/type/search-result.ts +++ b/frontend/src/app/dashboard/type/search-result.ts @@ -19,14 +19,12 @@ import { DashboardFile } from "./dashboard-file.interface"; import { DashboardWorkflow } from "./dashboard-workflow.interface"; -import { DashboardProject } from "./dashboard-project.interface"; import { DashboardDataset } from "./dashboard-dataset.interface"; import { DashboardEntry } from "./dashboard-entry"; export interface SearchResultItem { - resourceType: "workflow" | "project" | "file" | "dataset" | "computing-unit"; + resourceType: "workflow" | "file" | "dataset" | "computing-unit"; workflow?: DashboardWorkflow; - project?: DashboardProject; file?: DashboardFile; dataset?: DashboardDataset; } diff --git a/frontend/src/app/dashboard/type/type-predicates.ts b/frontend/src/app/dashboard/type/type-predicates.ts index 8c128b2c113..4ff5e2ad945 100644 --- a/frontend/src/app/dashboard/type/type-predicates.ts +++ b/frontend/src/app/dashboard/type/type-predicates.ts @@ -18,7 +18,6 @@ */ import { DashboardWorkflow } from "./dashboard-workflow.interface"; -import { DashboardProject } from "./dashboard-project.interface"; import { DashboardFile } from "./dashboard-file.interface"; import { DashboardDataset } from "./dashboard-dataset.interface"; import { DashboardWorkflowComputingUnit } from "../../common/type/workflow-computing-unit"; @@ -28,10 +27,6 @@ export function isDashboardWorkflow(value: any): value is DashboardWorkflow { return !!value && isNonNullObject(value.workflow); } -export function isDashboardProject(value: any): value is DashboardProject { - return !!value && typeof value.name === "string" && !value.workflow; -} - export function isDashboardFile(value: any): value is DashboardFile { return !!value && typeof value.ownerEmail === "string" && isNonNullObject(value.file); } diff --git a/frontend/src/app/hub/component/hub-search-result/hub-search-result.component.ts b/frontend/src/app/hub/component/hub-search-result/hub-search-result.component.ts index 1f69bdcff71..11df7ac7657 100644 --- a/frontend/src/app/hub/component/hub-search-result/hub-search-result.component.ts +++ b/frontend/src/app/hub/component/hub-search-result/hub-search-result.component.ts @@ -33,7 +33,6 @@ import { UntilDestroy, untilDestroyed } from "@ngneat/until-destroy"; import { SortMethod } from "../../../dashboard/type/sort-method"; import { UserService } from "../../../common/service/user/user.service"; import { SearchService } from "../../../dashboard/service/user/search.service"; -import { isDefined } from "../../../common/util/predicate"; import { firstValueFrom } from "rxjs"; import { map } from "rxjs/operators"; import { SortButtonComponent } from "../../../dashboard/component/user/sort-button/sort-button.component"; @@ -88,7 +87,6 @@ export class HubSearchResultComponent implements OnInit, AfterViewInit { } private masterFilterList: ReadonlyArray | null = null; - @Input() public pid?: number = undefined; @Input() public accessLevel?: string = undefined; public sortMethod = SortMethod.EditTimeDesc; lastSortMethod: SortMethod | null = null; @@ -144,10 +142,6 @@ export class HubSearchResultComponent implements OnInit, AfterViewInit { this.masterFilterList = this.filters.masterFilterList; this.searchKeywords = this.filters.getSearchKeywords(); let filterParams = this.filters.getSearchFilterParameters(); - if (isDefined(this.pid)) { - // force the project id in the search query to be the current pid. - filterParams.projectIds = [this.pid]; - } this.searchResultsComponent.reset((start, count) => { return firstValueFrom( diff --git a/frontend/src/app/hub/component/hub.component.spec.ts b/frontend/src/app/hub/component/hub.component.spec.ts index 5a883606394..61d85f60ac2 100644 --- a/frontend/src/app/hub/component/hub.component.spec.ts +++ b/frontend/src/app/hub/component/hub.component.spec.ts @@ -40,7 +40,6 @@ function makeSidebarTabs(overrides: Partial = {}): SidebarTabs { workflow_enabled: false, dataset_enabled: false, your_work_enabled: false, - projects_enabled: false, workflows_enabled: false, compute_enabled: false, datasets_enabled: false, diff --git a/frontend/src/app/hub/service/hub.service.ts b/frontend/src/app/hub/service/hub.service.ts index 4562ae9c8c8..46bd8763a0b 100644 --- a/frontend/src/app/hub/service/hub.service.ts +++ b/frontend/src/app/hub/service/hub.service.ts @@ -29,7 +29,6 @@ export const WORKFLOW_BASE_URL = `${AppSettings.getApiEndpoint()}/workflow`; export enum EntityType { Workflow = "workflow", Dataset = "dataset", - Project = "project", File = "file", ComputingUnit = "computing-unit", } diff --git a/frontend/src/app/workspace/component/menu/menu.component.ts b/frontend/src/app/workspace/component/menu/menu.component.ts index 69f08e4fefb..761601f8a74 100644 --- a/frontend/src/app/workspace/component/menu/menu.component.ts +++ b/frontend/src/app/workspace/component/menu/menu.component.ts @@ -33,18 +33,16 @@ import { WorkflowActionService } from "../../service/workflow-graph/model/workfl import { ExecutionState } from "../../types/execute-workflow.interface"; import { WorkflowWebsocketService } from "../../service/workflow-websocket/workflow-websocket.service"; import { WorkflowResultExportService } from "../../service/workflow-result-export/workflow-result-export.service"; -import { catchError, debounceTime, filter, mergeMap, tap } from "rxjs/operators"; +import { catchError, debounceTime, tap } from "rxjs/operators"; import { UntilDestroy, untilDestroyed } from "@ngneat/until-destroy"; import { WorkflowUtilService } from "../../service/workflow-graph/util/workflow-util.service"; import { WorkflowVersionService } from "../../../dashboard/service/user/workflow-version/workflow-version.service"; -import { UserProjectService } from "../../../dashboard/service/user/project/user-project.service"; import { NzUploadFile, NzUploadComponent } from "ng-zorro-antd/upload"; import { saveAs } from "file-saver"; import { NotificationService } from "src/app/common/service/notification/notification.service"; import { OperatorMenuService } from "../../service/operator-menu/operator-menu.service"; import { CoeditorPresenceService } from "../../service/workflow-graph/model/coeditor-presence.service"; import { firstValueFrom, of, Subscription, timer } from "rxjs"; -import { isDefined } from "../../../common/util/predicate"; import { NzModalService } from "ng-zorro-antd/modal"; import { ResultExportationComponent } from "../result-exportation/result-exportation.component"; import { ReportGenerationService } from "../../service/report-generation/report-generation.service"; @@ -141,7 +139,6 @@ export class MenuComponent implements OnInit, OnDestroy { protected readonly USER_WORKFLOW = USER_WORKFLOW; @Input() public writeAccess: boolean = false; - @Input() public pid?: number = undefined; @Input() public autoSaveState: string = ""; @Input() public currentWorkflowName: string = ""; // reset workflowName @Input() public currentExecutionName: string = ""; // reset executionName @@ -180,7 +177,6 @@ export class MenuComponent implements OnInit, OnDestroy { private datePipe: DatePipe, public workflowResultExportService: WorkflowResultExportService, public workflowUtilService: WorkflowUtilService, - private userProjectService: UserProjectService, private notificationService: NotificationService, public operatorMenu: OperatorMenuService, public coeditorPresenceService: CoeditorPresenceService, @@ -697,15 +693,12 @@ export class MenuComponent implements OnInit, OnDestroy { public persistWorkflow(): void { this.isSaving = true; - let localPid = this.pid; this.workflowPersistService .persistWorkflow(this.workflowActionService.getWorkflow()) .pipe( tap((updatedWorkflow: Workflow) => { this.workflowActionService.setWorkflowMetadata(updatedWorkflow); }), - filter(workflow => isDefined(localPid) && isDefined(workflow.wid)), - mergeMap(workflow => this.userProjectService.addWorkflowToProject(localPid!, workflow.wid!)), untilDestroyed(this) ) .subscribe({ diff --git a/frontend/src/app/workspace/component/workspace.component.html b/frontend/src/app/workspace/component/workspace.component.html index c54446fb318..56bf2672218 100644 --- a/frontend/src/app/workspace/component/workspace.component.html +++ b/frontend/src/app/workspace/component/workspace.component.html @@ -27,10 +27,7 @@ - - + { } describe("ngOnInit", () => { - it("parses numeric pid from route query params", async () => { - await createFixture(configureRoute({}, { pid: "13" })); - component.ngOnInit(); - expect(component.pid).toBe(13); - }); - - it("treats non-numeric pid as undefined", async () => { - await createFixture(configureRoute({}, { pid: "not-a-number" })); - component.ngOnInit(); - expect(component.pid).toBeUndefined(); - }); - it("enables highlighting on the workflow action service", async () => { await createFixture(); component.ngOnInit(); diff --git a/frontend/src/app/workspace/component/workspace.component.ts b/frontend/src/app/workspace/component/workspace.component.ts index 0677691c0c0..3170bb000d1 100644 --- a/frontend/src/app/workspace/component/workspace.component.ts +++ b/frontend/src/app/workspace/component/workspace.component.ts @@ -91,7 +91,6 @@ export const SAVE_DEBOUNCE_TIME_IN_MS = 5000; ], }) export class WorkspaceComponent implements AfterViewInit, OnInit, OnDestroy { - public pid?: number = undefined; public writeAccess: boolean = false; public isLoading: boolean = false; @ViewChild("codeEditor", { read: ViewContainerRef }) codeEditorViewRef!: ViewContainerRef; @@ -138,19 +137,6 @@ export class WorkspaceComponent implements AfterViewInit, OnInit, OnDestroy { ) {} ngOnInit() { - /** - * On initialization of the workspace, there are two possibilities regarding which component has - * routed to this component: - * - * 1. Routed to this component from within UserProjectSection component - * - track the pid identifying that project - * - upon persisting of a workflow, must also ensure it is also added to the project - * - * 2. Routed to this component from SavedWorkflowSection component - * - there is no related project, parseInt will return NaN. - * - NaN || undefined will result in undefined. - */ - this.pid = parseInt(this.route.snapshot.queryParams.pid) || undefined; this.workflowActionService.setHighlightingEnabled(true); // Clear session state when the user switches computing units in-canvas, so // the previous unit's status/console/results don't linger. diff --git a/sql/changelog.xml b/sql/changelog.xml index 8c181882a22..462a8a73108 100644 --- a/sql/changelog.xml +++ b/sql/changelog.xml @@ -34,6 +34,11 @@ + + + + +