Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OP#49859] add create work package form #500

Merged
merged 6 commits into from
Dec 6, 2023

Conversation

SwikritiT
Copy link
Collaborator

@SwikritiT SwikritiT commented Sep 28, 2023

Related work package [OP#49859]: https://community.openproject.org/projects/nextcloud-integration/work_packages/49859
This PR implements the creation of the work package through nextcloud

@SwikritiT SwikritiT force-pushed the feat/add-create-work-package-form branch from 80a8a89 to 3ad1332 Compare October 2, 2023 09:16
@SwikritiT SwikritiT force-pushed the feat/add-create-work-package-form branch 2 times, most recently from b93fe67 to 9faf221 Compare October 9, 2023 11:26
@SwikritiT SwikritiT force-pushed the feat/add-create-work-package-form branch from 9faf221 to 0a93e48 Compare October 9, 2023 11:33
@SwikritiT SwikritiT marked this pull request as ready for review October 12, 2023 06:13
@SwikritiT
Copy link
Collaborator Author

Note that the CI is failing currently because of: https://community.openproject.org/projects/nextcloud-integration/work_packages/50501

@SwikritiT SwikritiT self-assigned this Oct 12, 2023
src/views/ProjectsTab.vue Outdated Show resolved Hide resolved
Copy link
Collaborator

@individual-it individual-it left a comment

Choose a reason for hiding this comment

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

first quick review

appinfo/routes.php Outdated Show resolved Hide resolved
src/components/tab/SearchInput.vue Outdated Show resolved Hide resolved
src/components/tab/SearchInput.vue Outdated Show resolved Hide resolved
src/views/CreateWorkPackageModal.vue Outdated Show resolved Hide resolved
src/views/CreateWorkPackageModal.vue Outdated Show resolved Hide resolved
@SagarGi
Copy link
Collaborator

SagarGi commented Oct 13, 2023

I have gone through UI following figma.

modal-create-workpackage

Some changes can be made to it to make it look nicer.

  1. For Project* selection by default a place holder can be added as in figma.
  2. The input height of the Subject* could be adjusted as same height as select element to make it look nice and also place holder could also be added.

@SagarGi
Copy link
Collaborator

SagarGi commented Oct 13, 2023

createWP.mp4

Also Try this in your machine.
I tried to add type of REquired FC and the validation gives error but after some inputs in the form the create button is enabled and the error is gone and then i create the WP it does not do anything.

@SwikritiT
Copy link
Collaborator Author

createWP.mp4
Also Try this in your machine. I tried to add type of REquired FC and the validation gives error but after some inputs in the form the create button is enabled and the error is gone and then i create the WP it does not do anything.

Thanks. should be fixed now. Can you please recheck?

@SwikritiT SwikritiT force-pushed the feat/add-create-work-package-form branch from 10508c4 to 1359656 Compare October 17, 2023 05:04
lib/Controller/OpenProjectAPIController.php Outdated Show resolved Hide resolved
lib/Controller/OpenProjectAPIController.php Outdated Show resolved Hide resolved
lib/Controller/OpenProjectAPIController.php Outdated Show resolved Hide resolved
lib/Controller/OpenProjectAPIController.php Outdated Show resolved Hide resolved
lib/Controller/OpenProjectAPIController.php Outdated Show resolved Hide resolved
tests/jest/components/tab/SearchInput.spec.js Outdated Show resolved Hide resolved
tests/jest/components/tab/SearchInput.spec.js Outdated Show resolved Hide resolved
tests/jest/components/tab/SearchInput.spec.js Outdated Show resolved Hide resolved
tests/lib/Service/OpenProjectAPIServiceTest.php Outdated Show resolved Hide resolved
tests/lib/Service/OpenProjectAPIServiceTest.php Outdated Show resolved Hide resolved
@SwikritiT SwikritiT force-pushed the feat/add-create-work-package-form branch from 7aada3a to 00889eb Compare October 18, 2023 05:41
@SwikritiT SwikritiT force-pushed the feat/add-create-work-package-form branch from 7db3105 to 6a4c08a Compare October 18, 2023 06:07
@SwikritiT
Copy link
Collaborator Author

I've also updated the PR with alphabetical sorting @SagarGi @individual-it please recheck

Copy link
Collaborator

@SagarGi SagarGi left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@SwikritiT SwikritiT force-pushed the feat/add-create-work-package-form branch from 89079d2 to 1433dbb Compare October 31, 2023 09:29
@SwikritiT
Copy link
Collaborator Author

@SagarGi @individual-it I've also updated this PR by fixing the auto-focus/auto-opening of the project selection dropdown menu when the work package creation/linking form is opened.

@wielinde Whenever you have time you can test this PR.

Comment on lines +290 to +296
// when the modal opens the dropdown for selecting project gains focus automatically
// this is a workaround to prevent that by bluring the focus and the enabling the dropDown that was
// disabled initially in data
if (this.$refs?.createWorkPackageProjectInput) {
document.getElementById(`${this.$refs?.createWorkPackageProjectInput?.inputId}`).blur()
this.noDropAvailableProjectDropDown = false
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@SagarGi @individual-it this is sort of the workaround for disabling the autofocus when the modal comes into view. I know this is a "hack" but I also couldn't manage to do it in a very conventional way. I'm open to suggestion if anyone has a better way to do this.

@SwikritiT SwikritiT force-pushed the feat/add-create-work-package-form branch 2 times, most recently from aa15e0f to 7dd3da4 Compare November 3, 2023 09:02
@SwikritiT SwikritiT force-pushed the feat/add-create-work-package-form branch from 839c914 to f909591 Compare November 3, 2023 09:20
@wielinde
Copy link
Collaborator

wielinde commented Nov 8, 2023

Hey @SagarGi, while I was trying to debug why on my machine this PR does not work, I found that the current approach to fetch projects does not work well. The extra requests for fetching the storages per project were making troubles. When thinking about what you want to achieve it became apparent, that you should use the correct filters on the projects query in the first place and not fetch the storages at all.

  • You can simply use the storageUrl filter on the projects endpoint

Further, you want to make sure that the current user has the correct permissions on the selected projects.

  • the user should have the permission to create work packages in the project AND
  • the user should have the permission to create file links

We can filter on the available permission of a user in project with userAction filter.

Unfortunately, we currently cannot filter for a condition that requires ALL permissions to be present (Equals All "&="). We only have an operator that hits when any of the permissions is present (Equals "="). We will provide that extra filter soon (@Kharonus is working on it). For the time being you can work with the "Equals" operator. It will show more projects than actually good, but we can change that quickly once we provide the "EqualsAll" operator.

The new code could look somewhat like this:

	public function getAvailableOpenProjectProjects(string $userId): array {
		$resultsById = [];
            $result = $this->request(
                $userId,
                'projects?filters=' .
                urlencode(
                    '[{"storageUrl":{"operator":"=","values":["' .
                    $this->getBaseUrl() .
                    '"]}},{"userAction":{"operator":"=","values":["file_links/manage", "work_packages/create"]}}]'
                )
            );
            if (isset($result['error'])) {
                throw new OpenprojectErrorException($result['error'], $result['statusCode']);
            }
            if (
                !isset($result['_embedded']) ||
                !isset($result['_embedded']['elements'])
            ) {
                $this->logger->error(
                    "getAvailableOpenProjectProjects " . $result,
                    ['app' => $this->appName]
                );
                throw new OpenprojectResponseException('Malformed response');
            }
            foreach ($result['_embedded']['elements'] as $project) {
                $resultsById[$project['id']] = $project;
            }
            return $resultsById;
        }

And the function getProjectStorages can probably completely deleted as we do not need it anymore.

@SwikritiT SwikritiT force-pushed the feat/add-create-work-package-form branch from f909591 to 132df57 Compare November 20, 2023 06:16
@SwikritiT
Copy link
Collaborator Author

@wielinde I've updated the PR as per your comment can you please re-check and ensure that the recent changes are working as expected for you?

@SwikritiT SwikritiT force-pushed the feat/add-create-work-package-form branch 2 times, most recently from d32526a to 738fd12 Compare November 24, 2023 05:48
@wielinde
Copy link
Collaborator

Hey @SwikritiT, I played around with the work package creation form and it looked all pretty solid. I could not break it. Well done.

One tiny detail: The submit button looks pretty "disabled"/"inactive" in dark mode. I looked at other places where and I think the caption text color "should" be white. Could it be that there is a wrong class applied? That style is also visible when the form is fully filled out.

image

Apart from that, from a QA perspective that PR is good be merged into "master".

@SwikritiT SwikritiT force-pushed the feat/add-create-work-package-form branch 2 times, most recently from 200aa45 to b00dc9b Compare December 6, 2023 06:05
add option for creating workpackage in the search input

make the create workpackage sticky

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

test with iframe

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

handel creating and linking workpackage

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

handel linking multiple files to newely created work packages and fix some lint errors

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

uncomment the commented code

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

fix lint and other stuff

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

fix storage not linked error message display

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

add unit tests

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

add unit tests

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

fix tests

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

Add form for creating workpackage

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

add form validation endpoint

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

fetch assignee

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

fix UI and fix linting errors

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

fix style lint errors

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

fix filtering of the options

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

add create and link workpackage

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

make changes

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

handel valiation errors

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

display project hierarchy

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

fix project listing and make layout responsive

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

handel custom types

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

fix phpstan

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

fix phpstan

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

fix faiing phpunit tests

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

add phpunit tests

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

remove CSP listener

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

fix phpstan complains

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

add phpunit tests

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

add more tests

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

add vue unit tests

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

add ui unit tests

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

add more unit test

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

fix failing tests

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

remove some unneeded attributes

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

fix unit tests

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

add more cases

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

address reviews

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

address more reviews

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

fix type not changing

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

filter workpackages according to their storages

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

address more reviews

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

address reviews

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

remove leftovers

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

add placeholders

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

make some ui adjustments

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

sort project alphabetically

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

remove duplicate check

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

update url to direct to the workpackage creation form directly

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

add workaround for project dropdown gaining auto focus

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

fix unit tests and update snapshots

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>
Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>
Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>
Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>
Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>
@SwikritiT SwikritiT force-pushed the feat/add-create-work-package-form branch 2 times, most recently from f5a6ee5 to 5696c71 Compare December 6, 2023 07:10
Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>
@SwikritiT SwikritiT force-pushed the feat/add-create-work-package-form branch from 5696c71 to 260ddf9 Compare December 6, 2023 07:12
Copy link

github-actions bot commented Dec 6, 2023

JS Code Coverage

Coverage after merging feat/add-create-work-package-form into master will be
87.38%
Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
src
   adminSettings.js0%0%0%0%1, 1, 10–19, 2, 20–25, 3–9
   bootstrap.js0%0%0%0%1, 1–7
   dashboard.js0%0%0%0%1, 1, 10–19, 2, 20–25, 3–9
   fileActions.js0%0%0%0%1, 1, 10–17, 2–9
   personalSettings.js0%0%0%0%1, 1, 10–19, 2, 20–25, 3–9
   projectTab.js0%0%0%0%1, 1, 10–19, 2, 20–29, 3, 30–39, 4, 40–49, 5, 50–59, 6, 60–66, 7–9
   reference.js0%0%0%0%1, 1, 10–19, 2, 20–29, 3, 30–39, 4, 40–49, 5, 50–59, 6, 60, 7–9
   utils.js66.67%33.33%50%69.09%10–14, 17–26, 6–9
src/components
   AdminSettings.vue99.29%95.60%85.19%99.91%1, 1, 1, 1, 1
   OAuthConnectButton.vue99.19%87.50%100%100%1
   PersonalSettings.vue98.87%93.33%85.71%100%1
src/components/admin
   FieldValue.vue92.08%33.33%100%97.78%1, 1, 1, 1, 1, 1, 23, 23
   FormHeading.vue97.66%75%100%99.36%1, 1, 34, 34
   ProjectFolderError.vue96.83%80%100%98.21%1, 1
   TextInput.vue99.25%95%88.89%100%1
src/components/icons
   ClippyIcon.vue93.18%50%50%97.50%1, 1
   OpenProjectIcon.vue93.75%100%0%96.77%1
src/components/settings
   CheckBox.vue92.45%80%66.67%97.62%1, 1
   SettingsTitle.vue94.74%50%100%97.14%1, 1
src/components/tab
   EmptyContent.vue97.14%78.95%100%99.35%1, 1, 1, 33, 33
   SearchInput.vue99.22%94.74%77.78%100%1
   WorkPackage.vue98.42%40%100%99.35%1, 1, 1, 43, 43
src/filesPlugin
   filesPlugin.js0%0%0%0%1, 1, 10, 100–104, 11–19, 2, 20–29, 3, 30–39, 4, 40–49, 5, 50–59, 6, 60–69, 7, 70–79, 8, 80–89, 9, 90–99
   filesPluginLessThan28.js0%0%0%0%1, 1, 10–19, 2, 20–29, 3, 30–39, 4, 40–49, 5, 50–59, 6, 60–69, 7, 70–78, 8–9
src/utils
   workpackageHelper.js93.39%91.11%88.89%94.15%153–154, 18–20, 49, 49–51, 94–99
src/views
   CreateWorkPackageModal.vue98.22%92.59%40%99.84%1, 1, 1
   Dashboard.vue98.97%71.43%100%99.65%1, 1, 1
   LinkMultipleFilesModal.vue99.67%94.12%100%100%1
   ProjectsTab.vue99.74%93.75%100%100%23
   WorkPackagePickerElement.vue0%0%0%0%1, 1, 10–19, 2, 20–29, 3, 30–39, 4, 40–49, 5, 50–59, 6, 60–69, 7, 70–79, 8, 80–89, 9, 90–96
   WorkPackageReferenceWidget.vue0%0%0%0%1, 1, 10, 100–109, 11, 110–119, 12, 120–129, 13, 130–134, 14–19, 2, 20–29, 3, 30–39, 4, 40–49, 5, 50–59, 6, 60–69, 7, 70–79, 8, 80–89, 9, 90–99

Copy link

github-actions bot commented Dec 6, 2023

PHP Code Coverage

Coverage after merging feat/add-create-work-package-form into master will be
59.17%
Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
server/apps/integration_openproject/lib
   Capabilities.php0%100%0%0%19, 26–29
server/apps/integration_openproject/lib/AppInfo
   Application.php11.43%100%25%9.68%101–104, 108–111, 113, 117–122, 133, 137, 70–72, 75, 79, 81, 84, 88, 90, 94, 99
server/apps/integration_openproject/lib/BackgroundJob
   RemoveExpiredDirectUploadTokens.php0%100%0%0%42, 44–46, 55–56
server/apps/integration_openproject/lib/Controller
   ConfigController.php62.69%100%50%63.39%134, 151–152, 154, 156–158, 160–161, 166–167, 169, 217, 278, 367–368, 371–372, 378–380, 506–509, 511–512, 515, 523, 534, 548–550, 565–569, 571–572, 574–577, 579–581, 583–585, 587–589, 607–612, 614–615, 617–619, 622, 624–627, 629–631, 633–635, 637–639, 653, 662–665, 667–670, 680–685
   DirectDownloadController.php0%100%0%0%36–38, 53–55, 57, 60–61
   DirectUploadController.php71.43%100%100%70.43%131–132, 177, 190, 194–197, 199, 209, 216, 232–234, 236–237, 240–242, 248, 250, 255–256, 263–264, 267–268, 271–272, 288–289, 309, 314, 320
   FilesController.php77%100%85.71%76.34%223–224, 277, 283, 285–287, 289, 291, 302–304, 307–308, 310–311, 315–318, 321, 327
   OpenProjectAPIController.php87.31%100%84.21%87.55%139, 180, 204, 230–233, 236, 238, 240–243, 245–246, 251, 263, 272, 290, 299, 367, 369, 419, 421, 441, 443, 490, 492, 712, 714, 96
server/apps/integration_openproject/lib/Dashboard
   OpenProjectWidget.php0%100%0%0%101–102, 104–108, 116, 123–124, 126, 128–129, 131–132, 134, 137–138, 140–141, 143, 69–73, 80, 87, 94
server/apps/integration_openproject/lib/Exception
   OpenprojectErrorException.php100%100%100%100%
   OpenprojectFileNotUploadedException.php100%100%100%100%
   OpenprojectGroupfolderSetupConflictException.php100%100%100%100%
   OpenprojectResponseException.php100%100%100%100%
   OpenprojectUnauthorizedUserException.php0%100%0%0%16
server/apps/integration_openproject/lib/Listener
   BeforeGroupDeletedListener.php0%100%0%0%48, 56–57, 60–63
   BeforeNodeInsideOpenProjectGroupfilderChangedListener.php0%100%0%0%41–43, 47–52, 55–56, 58–63, 65, 67, 71
   BeforeUserDeletedListener.php0%100%0%0%48, 55–56, 58–61
   LoadAdditionalScriptsListener.php0%100%0%0%17–18, 21–25
   LoadSidebarScript.php0%100%0%0%100, 102, 104, 106–108, 110, 112, 114–115, 117–118, 120, 122, 75–81, 83–84, 86–87, 89–90, 96–97, 99
   OpenProjectReferenceListener.php0%100%0%0%53–54, 58–59, 62–63, 65, 67
   UserChangedListener.php0%100%0%0%52, 59–60, 63–68
server/apps/integration_openproject/lib/Migration
   Version2001Date20221213083550.php0%100%0%0%47, 57, 60, 63, 67, 70, 73, 77–79, 81
   Version2310Date20230116153411.php0%100%0%0%46, 49–52, 54–56, 60, 64, 68, 72, 76, 81–82, 84
   Version2400Date20230504144300.php0%100%0%0%47, 57, 60
server/apps/integration_openproject/lib/Reference
   WorkPackageReferenceProvider.php17.02%100%10%18.92%102, 109–112, 115–117, 120, 127–130, 132, 134–136, 138, 140, 142, 146, 155, 163–164, 172, 52, 59, 66, 73–74
server/apps/integration_openproject/lib/Search
   OpenProjectSearchProvider.php0%100%0%0%103–104, 107–114, 116–118, 121–122, 124–125, 129–134, 140–141, 143, 66–69, 76, 83, 91, 93, 96
   OpenProjectSearchResultEntry.php100%100%100%100%
server/apps/integration_openproject/lib/Service
   DatabaseService.php43.90%100%60%41.67%125–128, 131, 80–87, 89–93, 95–97
   DirectDownloadService.php88%100%100%86.96%65–66, 68
   DirectUploadService.php54.55%100%66.67%52.63%112, 118, 79–82, 84, 89, 91
   OauthService.php0%100%0%0%108–115, 45–47, 56–66, 68, 70–72, 75–78, 89, 91–94, 96–97
   OpenProjectAPIService.php74.42%100%73.33%74.53%1002, 1020, 1022, 1028, 1033, 1037, 1048–1049, 1180–1187, 1189, 1197–1201, 1209–1216, 1233–1240, 1249–1254, 165–169, 240,

Copy link
Collaborator

@SagarGi SagarGi left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@SagarGi SagarGi merged commit 60a1763 into master Dec 6, 2023
21 checks passed
@delete-merged-branch delete-merged-branch bot deleted the feat/add-create-work-package-form branch December 6, 2023 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants