Skip to content

Refactor User Project Section Workflows - #1461

Merged
shengquan-ni merged 40 commits into
apache:masterfrom
ethanwong16:ethan-user-project-workflow-refactor
May 13, 2022
Merged

shengquan-ni merged 40 commits into
apache:masterfrom
ethanwong16:ethan-user-project-workflow-refactor

Conversation

@ethanwong16

@ethanwong16 ethanwong16 commented Feb 25, 2022 •

Copy link
Copy Markdown
Contributor

Introduction

This PR refactors the code in the UserProjectSection involving a particular project's workflows. The goal is to improve the maintainability of the user project feature and keep the design of workflow sections consistent.

Solution

Previously the UserProjectSection component created new HTML and Typescript logic for managing the list of workflows belonging to a particular project. The issue with this was that it introduced duplicate code and updates to the SavedWorkflowSection would not propagate to the UserProjectSection. As a solution, I modified the SavedWorkflowSection component to enable features relevant to user projects and reused this component within the UserProjectSection.

Changes Made

Frontend

  • user-project-section.component.ts : make pid field public to pass it to SavedWorkflowSection
  • user-project-section.component.html : reuse the SavedWorkflowSection component and pass pid
  • saved-workflow-section.component.ts : use optional pid input field to determine whether to load workflows belonging to a specific project or load all workflows + add logic for create / duplicate / refresh workflows to account for user projects
  • saved-workflow-section.component.html : if rendering within a UserProjectSection, also add additional buttons for add / remove workflow(s) from project
  • saved-workflow-section.component.scss : even out margin between sort / create/ add / remove buttons + allow component to collapse when workflows are removed from project
  • workspace.component.ts : it now extracts a passed in pid field from the route snapshot in ngOnInit, this is used for adding newly created workflows to projects
  • workspace.component.html : pass the pid field to the Navigation component which persists workflows
  • navigation.component.ts : when persisting workflows, also add workflow to a project if given a valid pid field
  • ngbd-modal-add-project-workflow.component.html, ngbd-modal-add-project-workflow.component.scss, ngbd-modal-remove-project-workflow.component.html, ngbd-modal-remove-project-workflow.component.scss : fix CSS to allow for scrolling and keep text overflow within table

Backend

  • ProjectResource.scala : modify endpoint adding workflow to a project to first check if mapping already exists before adding

Demo

In the demo below, we can see the UserProjectSection component workflows now are consistent with the SavedWorkflowSection component and still maintains the ability to add / remove workflows from projects.

refactor-user-project-workflow.mov

Future TODOs

  • Address deprecated usage of .subscribe() with more than one parameter

  • Refresh user projects upon log out / log in

  • Enable creating files / workflows from SavedWorkflow and UserFile section components

  • Update CSS to add scrolling and control max modal width for popup to add/remove files from projects

  • Refactor UserFileService to remove local cache

  • Use newly refactored UserFileService to modify / reuse UserFileSection component within UserProjectSection

  • Add color indicators for each user project

  • Add exported sink operator CSV to current project

ethanwong16 and others added 25 commits November 4, 2021 17:40
- Update texera_db schema to include projects
- Regenerate JOOQ files
- Create ProjectResource Scala model
- Add ability to get, create, delete, update projects
- Add ability to get / delete workflows and files of a project
- Add new API endpoint '/project' in TexeraWebApplication.scala
- Backend Changes
	1) check for creating projects with duplicated names
	2) creating a project returns new Project object
- Changed Frontend Features
	1) User Projects Page (lists a user's projects)
		- error message when renaming / creating project with duplicate names
		- utilize front end cache to minimize need to refresh list of projects after creating / deleting a project
	2) Single Project Page (a project and all of its files / workflows)
		- files are no longer stored in cache, modeled off of UserFileService and refreshing after an update
		- finish implementation for deleting file from this page
		- finish implementation of adding workflows created on this page to the project as well
- in texera_db, renamed 'project' table into 'user_project' table
- regenerated JOOQ tables and data access objects for 'user_project'
- updated ProjectResource.scala API endpoint paths as requested
- updated frontend user-project.service.ts to call updated endpoints
- added @permitAll to ProjectResource.scala to allow all users to access
- updated logic for ProjectResource.scala listProjectWorkflows and listProjectFiles to use DB join
- updated logic for ProjectResource.scala createProject to use try / catch and minimize number of queries
- updated logic for ProjectResource.scala updateProjectName to use try / catch to validate name
- now performs name validation for whitespace or empty renaming
- also checks for renaming to an already existing project name
- rename ownerId to use 'ID' instead of 'Id'
- created utility function to validate project names
- utilized NotificationService to display error messages
- UserProjectSection --> UserProjectList : this component lists a user's projects
- ProjectPage --> UserProjectSection     : this component is for a single user project
- updated some routing / variables to use user project instead of project
- Pass input to SavedWorkflowSectionComponent to track project ID, if any
- Update SavedWorkflowSectionComponent service calls to also change project/workflow mappings, if needed
- Pass project ID to Workspace and Navigation component to enable saving workflow to project
- Update Navigation component persistWorkflow() to also save workflow into user project
- Update ProjectResource.scala endpoint to check for duplicates before adding workflow to project
- integrate modals for add / remove workflow(s) from project
- update margins between workflow action buttons (sort, create, add workflow to project, remove workflow from project)
@ethanwong16 ethanwong16 added the refactor Refactor the code label Mar 31, 2022

@shengquan-ni shengquan-ni left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some minor comments.

@shengquan-ni shengquan-ni left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Xiao-zhen-Liu

Copy link
Copy Markdown
Contributor

Discussion 2022.05.12: @shengquan-ni will merge this PR.

@shengquan-ni
shengquan-ni merged commit a1daa49 into apache:master May 13, 2022
Yicong-Huang added a commit that referenced this pull request Jul 27, 2023
This PR fixes an issue where manually persisting a workflow would throw
an `[object object]` issue. The root of the problem lies in the
invocation of `project/{pid}/workflow/{wid}/add` (introduced in #1461)
during the persistence process. The issue arises when the project id is
missing, leading to the request parameter being set as `NaN`. As a
consequence, an error occurs, and it is not being handled appropriately.
Now this faulty logic has been fixed.

---------

Co-authored-by: Shengquan Ni <[email protected]>
yangzhang75 pushed a commit to yangzhang75/texera that referenced this pull request Jun 22, 2026
* Add project management API endpoint + data schema

- Update texera_db schema to include projects
- Regenerate JOOQ files
- Create ProjectResource Scala model
- Add ability to get, create, delete, update projects
- Add ability to get / delete workflows and files of a project
- Add new API endpoint '/project' in TexeraWebApplication.scala

* reformat files

* Update JobResultService.scala

* added basic features of project management : view projects, view / edit / add  projects & files of a project

* Finished basic project management features
- Backend Changes
	1) check for creating projects with duplicated names
	2) creating a project returns new Project object
- Changed Frontend Features
	1) User Projects Page (lists a user's projects)
		- error message when renaming / creating project with duplicate names
		- utilize front end cache to minimize need to refresh list of projects after creating / deleting a project
	2) Single Project Page (a project and all of its files / workflows)
		- files are no longer stored in cache, modeled off of UserFileService and refreshing after an update
		- finish implementation for deleting file from this page
		- finish implementation of adding workflows created on this page to the project as well

* Modified front end file formatting and removed unused test files

* added missing semicolons for fixing frotend format

* updated schema spacing for project tables

* Added requested fixes to backend API and data layer
- in texera_db, renamed 'project' table into 'user_project' table
- regenerated JOOQ tables and data access objects for 'user_project'
- updated ProjectResource.scala API endpoint paths as requested
- updated frontend user-project.service.ts to call updated endpoints
- added @permitAll to ProjectResource.scala to allow all users to access
- updated logic for ProjectResource.scala listProjectWorkflows and listProjectFiles to use DB join
- updated logic for ProjectResource.scala createProject to use try / catch and minimize number of queries
- updated logic for ProjectResource.scala updateProjectName to use try / catch to validate name

* scalafmtcheck for ProjectResource.scala

* Updated renaming project logic for backend API
- now performs name validation for whitespace or empty renaming
- also checks for renaming to an already existing project name

* Added requested changes to frontend
- rename ownerId to use 'ID' instead of 'Id'
- created utility function to validate project names
- utilized NotificationService to display error messages

* reformat string to use double quotes

* Renamed frontend components
- UserProjectSection --> UserProjectList : this component lists a user's projects
- ProjectPage --> UserProjectSection     : this component is for a single user project
- updated some routing / variables to use user project instead of project

* Refactor UserProjectSection to reuse SavedWorkflowSection component
- Pass input to SavedWorkflowSectionComponent to track project ID, if any
- Update SavedWorkflowSectionComponent service calls to also change project/workflow mappings, if needed
- Pass project ID to Workspace and Navigation component to enable saving workflow to project
- Update Navigation component persistWorkflow() to also save workflow into user project
- Update ProjectResource.scala endpoint to check for duplicates before adding workflow to project

* Finalize reusing SavedWorkflowSection component + ran yarn reformatting
- integrate modals for add / remove workflow(s) from project
- update margins between workflow action buttons (sort, create, add workflow to project, remove workflow from project)

* Fix add / remove workflow CSS + make SavedWorkflowSection component CSS shrinkable

* Fixed frontend format with yarn format:fix

* Revert removal of notificationService comments

* Reformat whitespace

* Added comments to explain variables in add / delete worklows to project modals

* Format frontend workflow / project modal files

Co-authored-by: Shengquan Ni <[email protected]>
Co-authored-by: Shengquan Ni <[email protected]>
yangzhang75 pushed a commit to yangzhang75/texera that referenced this pull request Jun 22, 2026
This PR fixes an issue where manually persisting a workflow would throw
an `[object object]` issue. The root of the problem lies in the
invocation of `project/{pid}/workflow/{wid}/add` (introduced in apache#1461)
during the persistence process. The issue arises when the project id is
missing, leading to the request parameter being set as `NaN`. As a
consequence, an error occurs, and it is not being handled appropriately.
Now this faulty logic has been fixed.

---------

Co-authored-by: Shengquan Ni <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Refactor the code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants