Skip to content

New Sharing#1087

Merged
jotoeri merged 8 commits intomasterfrom
enh/sharing
May 31, 2022
Merged

New Sharing#1087
jotoeri merged 8 commits intomasterfrom
enh/sharing

Conversation

@jotoeri
Copy link
Copy Markdown
Member

@jotoeri jotoeri commented Dec 9, 2021

So - here it is! 🎉 Ready for Review.
I'm really sorry, it became that much code now in a single PR. Thus i moved fixing the API-versioning to #1126.

Looking forward for the first tests! ☺️

grafik
grafik
AppNavigation is now:
grafik

Fixes #425 😉

@jotoeri jotoeri added design Related to the design enhancement New feature or request feature: 👥 sharing settings labels Dec 9, 2021
@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 9, 2021

Codecov Report

Merging #1087 (6a6a036) into master (daf8282) will increase coverage by 2.90%.
The diff coverage is 47.64%.

❗ Current head 6a6a036 differs from pull request most recent head b3a4e1b. Consider uploading reports for the commit b3a4e1b to get more accurate results

@@             Coverage Diff              @@
##             master    #1087      +/-   ##
============================================
+ Coverage     29.14%   32.04%   +2.90%     
- Complexity      369      435      +66     
============================================
  Files            36       40       +4     
  Lines          1431     1676     +245     
============================================
+ Hits            417      537     +120     
- Misses         1014     1139     +125     

@jotoeri

This comment was marked as outdated.

@jotoeri jotoeri linked an issue Dec 11, 2021 that may be closed by this pull request
@jotoeri jotoeri force-pushed the enh/sharing branch 4 times, most recently from 35c6c69 to 4634cb2 Compare December 17, 2021 21:26
@skjnldsv skjnldsv added the 2. developing Work in progress label Dec 20, 2021
@RenataGegaj

This comment was marked as resolved.

@jotoeri

This comment was marked as resolved.

@jotoeri jotoeri force-pushed the enh/sharing branch 10 times, most recently from fdb5553 to 736c089 Compare February 8, 2022 21:10
@jotoeri jotoeri force-pushed the enh/sharing branch 6 times, most recently from 9957233 to 4e9673b Compare February 20, 2022 11:38
@jotoeri jotoeri force-pushed the enh/sharing branch 6 times, most recently from 5af5e6c to a21a51a Compare April 30, 2022 19:03
@jotoeri jotoeri mentioned this pull request Apr 30, 2022
@jotoeri
Copy link
Copy Markdown
Member Author

jotoeri commented May 14, 2022

Review help

  • The OLD sharing was stored like:
form: {
   ...
   access: {
      type: 'selected',
      users: ['userId1', 'userId2'],
      groups: ['groupId1']
   }
}
  • The NEW sharing changed to:
form: {
   ...
   access: {
      permitAllUsers: True,
      showToAllUsers: True,
      [ legacyLink: True ]
   },
   shares: [
      {
         id: 3,
         formId: 5,
         shareType: IShare::TYPE_USER,
         shareWith: 'userId1'
      },
      {
         id: 4,
         formId: 5,
         shareType: IShare::TYPE_LINK,
         shareWith: 'iAmSomeHash'
      },
   ]
}

Regarding the links:

  • While the old (also publich) sharing link was the direct form link, localhost/index.php/apps/forms/someHash, this link will now only work as internal link for users already having access. This is similar to the files-sharing internal link.
  • The new public sharing link is now like localhost/index.php/apps/forms/s/someNewHash, which now also can be multiple public links, linking to the same form.
  • For temporary compatiblity, the migration of old forms introduces the legacyLink-property, which still allows the internal link to be used as old public link. But this also produces a warning for the form-owner, to replace the link. This functionality is a one-way ticket, so once deleted, it can not be restored, but a new public link has to be used.

Regarding direct access in the app:

  • If a form is directly shared to single users or groups, then the form always shows up on their sidebar.
  • While the property permitAllUsers allows all users to access the form (via spread internal link), there is now an additional switch, to show the form to all users on the sidebar. This enables now also to share, but not show to all users, which was a multiple FR on the issue-tracker.

Internal Data:

  • There is a permissions-property added, which tells the frontend, what the current user is allowed to do on a form. This is currently used, to check if a user is allowed to e.g. edit a form, but also prepares for an easier result-sharing f.ex..
  • Maybe clear, but to explain: Partial forms are just stripped form-objects, that contain only the data, that is necessary to show the form on the sidebar. Only when selecting a form for edit/submit, the rest of the non-partial data is loaded. The loading of partial forms got a small restructuring here...
  • To submit as non-logged in users to the new public links, the share hash must be passed to the api. This is the way of access-control, if there is a public link used. The user needs to know the share-hash, but can not just submit to a form without a public hash.
  • The api-versioning is a bit mixed up here, as the new routes are for apiv2, just the old routes are not renamed in this pr. There is the separate pr API v2 #1126 for fixing the api versioning then...

@jotoeri
Copy link
Copy Markdown
Member Author

jotoeri commented May 14, 2022

A try for review coordination: Feel free to edit this, add comments, etc.!

  • appinfo/info.xml
  • appinfo/routes.php
  • css/icons.scss
  • lib/Constants.php
  • lib/Controller/ApiController.php
  • lib/Controller/PageController.php
  • lib/Controller/ShareApiController.php
  • lib/Db/FormMapper.php
  • lib/Db/Share.php
  • lib/Db/ShareMapper.php
  • lib/Migration/Version030000Date20211206213004.php
  • lib/Service/FormsService.php
  • package-lock.json
  • package.json
  • src/Forms.vue
  • src/FormsSubmit.vue
  • src/components/AppNavigationForm.vue
  • src/components/ShareDiv.vue
  • src/components/SidebarTabs/SettingsSidebarTab.vue
  • src/components/SidebarTabs/SharingSearchDiv.vue
  • src/components/SidebarTabs/SharingShareDiv.vue
  • src/components/SidebarTabs/SharingSidebarTab.vue
  • src/components/UserDiv.vue
  • src/mixins/PermissionTypes.js
  • src/mixins/ShareLinkMixin.js
  • src/mixins/ShareTypes.js
  • src/mixins/ViewsMixin.js
  • src/views/Create.vue
  • src/views/Results.vue
  • src/views/Sidebar.vue
  • src/views/Submit.vue
  • tests/Unit/Controller/ShareApiControllerTest.php
  • tests/Unit/Service/FormsServiceTest.php
  • Testing the frontend and finding dumb bugs

Copy link
Copy Markdown
Contributor

@come-nc come-nc left a comment

Choose a reason for hiding this comment

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

PHP code looks good!
A few minor comments, and I think improvement needed on the Migration, it should use a $qb var for the query builder and assign the other 3 from there, it looks quite messy right now compared to other Migrations from other apps.

Properties are not strong typed, but I thought this may be on purpose if you plan to support older Nextcloud/PHP versions. (24 requires PHP>=7.4 so we can start using strong typed properties there. But you can also require PHP>=7.4 even if you support older Nextcloud versions I think, given 7.3 is EOL. Not 100% sure of the rules there.)

A strong step in the right direction for form sharing, congrats.

Comment thread lib/Controller/ShareApiController.php
Comment thread lib/Controller/ShareApiController.php Outdated
Comment thread lib/Controller/ShareApiController.php Outdated
Comment thread lib/Controller/ShareApiController.php Outdated
Comment thread lib/Migration/Version030000Date20211206213004.php
Comment thread lib/Migration/Version030000Date20211206213004.php Outdated
Comment thread lib/Migration/Version030000Date20211206213004.php Outdated
Comment thread lib/Migration/Version030000Date20211206213004.php Outdated
Comment thread lib/Service/FormsService.php
@jotoeri
Copy link
Copy Markdown
Member Author

jotoeri commented May 16, 2022

Thank you in any case already for your work, @come-nc ! 💪 🚀
A few things i fixed already, the rest i'll do the next days... 😉

Comment thread lib/Controller/ShareApiController.php
Comment thread lib/Migration/Version030000Date20211206213004.php Outdated
Comment thread lib/Migration/Version030000Date20211206213004.php Outdated
Comment thread lib/Migration/Version030000Date20211206213004.php Outdated
Comment thread lib/Migration/Version030000Date20211206213004.php Outdated
Comment thread lib/Migration/Version030000Date20211206213004.php Outdated
Comment thread lib/Migration/Version030000Date20211206213004.php Outdated
Comment thread lib/Db/ShareMapper.php
Comment on lines +35 to +36

class ShareMapper extends QBMapper {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
class ShareMapper extends QBMapper {
/**
* @template-extends QBMapper<Share>
*/
class ShareMapper extends QBMapper {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Any specific functionality on that? (Or what do i have to search for to understand it? 😉) Tbh. we don't have that on any of our mappers... 🤔

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.

It gives more information to psalm to improve its error detection, basically.
You can see the template in the docblocks of https://github.com/nextcloud/server/blob/master/lib/public/AppFramework/Db/QBMapper.php#L43

Copy link
Copy Markdown
Contributor

@artonge artonge left a comment

Choose a reason for hiding this comment

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

Nice PR overall !

I still got some logic interrogations, and some readability suggestions, feel free to ignore some if they concern copy-pasted code.

Comment thread src/Forms.vue Outdated
Comment thread src/Forms.vue
Comment thread src/Forms.vue Outdated
Comment thread src/Forms.vue
Comment thread package.json
Comment thread src/components/SidebarTabs/SharingSearchDiv.vue
Comment thread src/components/SidebarTabs/SharingSearchDiv.vue
Comment thread src/components/SidebarTabs/SharingSearchDiv.vue Outdated
Comment thread src/components/SidebarTabs/SharingShareDiv.vue Outdated
Comment thread src/components/SidebarTabs/SharingShareDiv.vue Outdated
@jotoeri
Copy link
Copy Markdown
Member Author

jotoeri commented May 22, 2022

Properties are not strong typed, but I thought this may be on purpose if you plan to support older Nextcloud/PHP versions. (24 requires PHP>=7.4 so we can start using strong typed properties there.

Yes, we officially still support NC22 and just recently removed php 7.2. ^^ Thus i'd leave it for now. We'll have a separate PR to change all of our classes, when the time has come. 😉

@jotoeri
Copy link
Copy Markdown
Member Author

jotoeri commented May 22, 2022

Ok - So thank you, @artonge @CarlSchwan @come-nc for your reviews here! 🚀 Quite a few new things and ideas. I had a look onto all of it, partially just set a comment, but also implemented quite a few things.

So - i think if there's no more issues from your side, this should be good to go, then! ☺️ 🎉

Copy link
Copy Markdown
Contributor

@come-nc come-nc left a comment

Choose a reason for hiding this comment

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

Good apart from nitpicking.

I did not test.

Comment thread lib/Controller/ShareApiController.php
Comment thread lib/Migration/Version030000Date20211206213004.php Outdated
@jotoeri
Copy link
Copy Markdown
Member Author

jotoeri commented May 31, 2022

@artonge Do you wanna check your requested changes? Or should i just dismiss the review as i looked into your comments?

Comment thread src/components/SidebarTabs/SettingsSidebarTab.vue Outdated
jotoeri added 8 commits May 31, 2022 21:40
Signed-off-by: Jonas Rittershofer <jotoeri@users.noreply.github.com>
Signed-off-by: Jonas Rittershofer <jotoeri@users.noreply.github.com>
Signed-off-by: Jonas Rittershofer <jotoeri@users.noreply.github.com>
Also fixes #806

Signed-off-by: Jonas Rittershofer <jotoeri@users.noreply.github.com>
Signed-off-by: Jonas Rittershofer <jotoeri@users.noreply.github.com>
Signed-off-by: Jonas Rittershofer <jotoeri@users.noreply.github.com>
Signed-off-by: Jonas Rittershofer <jotoeri@users.noreply.github.com>
Signed-off-by: Jonas Rittershofer <jotoeri@users.noreply.github.com>
@come-nc
Copy link
Copy Markdown
Contributor

come-nc commented Jun 2, 2022

🚀 🥳

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews design Related to the design enhancement New feature or request feature: 👥 sharing settings high High priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feature request] Share a form by more than one method. Show sharings as in Server

9 participants