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

Feature: Read-only property for External Libraries #8992

Closed
wants to merge 8 commits into from

Conversation

rokiden
Copy link

@rokiden rokiden commented Apr 21, 2024

Closes #5449. Original thread .

This PR adds "Read Only" property for External library.

In database it stored as column "libraries.isReadOnly". This property set at library creation time and can't be modified. Asset.isReadOnly inherits library's value at creation time. At frontend it was added as toggle to "Select library owner" dialog. Mobile app doesn't require changes.

Asset modification and deletion require to check only isReadOnly property, isExternal becomes only informational.

Tested:

  • delete to trash
  • empty trash
  • modification
  • rescan of library

TODO:

  • automated tests
  • indication of ReadOnly property in web/mobile
  • ? cmdline tool to migrate library to RW mode and back

Screenshot_20240403_144638_Firefox.png

@benmccann benmccann added the external-library Issues related to external libraries label Apr 21, 2024
@ThreeAurora
Copy link

Thanks, that's what I need most about this feature, otherwise I wouldn't even know how to do my job!

@rokiden rokiden requested a review from benmccann April 26, 2024 05:38
@benmccann
Copy link
Contributor

Thanks! I discussed this PR with the other maintainers and we're happy with it overall, but adding that additional server-side check would be a blocker. Then I think the only other change needed would be some updates to the tests

TODO:
indication of ReadOnly property in web/mobile

I believe we already have some indications such as delete being disabled for readonly assets

? cmdline tool to migrate library to RW mode and back

Probably better to make the readonly property modifiable in the UI rather than a cmdline tool, but that's probably better as a separate PR. I think this is fine for now

@ThreeAurora
Copy link

Thanks for keeping an eye on this feature, we're excited to see it coming soon!

@jrasm91
Copy link
Contributor

jrasm91 commented Apr 27, 2024

#8943 seems more complete

@benmccann
Copy link
Contributor

benmccann commented Apr 27, 2024

@jrasm91 in what way does it seem more complete?

@jrasm91
Copy link
Contributor

jrasm91 commented Apr 27, 2024

Both look to be doing essentially the same thing. The other PR was created first, has some tests, and allows the property to be updated after the library is created.

@rokiden
Copy link
Author

rokiden commented Apr 28, 2024

@benmccann
I've added server-side checks to update and updateAll.
Also added library's isReadOnly indication using alternative icon for read-write libs:
Screenshot from 2024-04-28 16-57-36

@@ -252,11 +252,19 @@ export class AssetService {
async update(auth: AuthDto, id: string, dto: UpdateAssetDto): Promise<AssetResponseDto> {
await this.access.requirePermission(auth, Permission.ASSET_UPDATE, id);

let asset = await this.assetRepository.getById(id);
Copy link
Contributor

Choose a reason for hiding this comment

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

this is going to cause a second query right after having done a query on the line above. Perhaps it should just be part of that initial permission check. see AssetAcess.checkOwnerAccess in access.repository.ts

Copy link
Contributor

Choose a reason for hiding this comment

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

That would be fine with me. Asset update access implies the asset is not read only.

@@ -37,6 +39,7 @@
<p class="p-5 text-sm">NOTE: This cannot be changed later!</p>
Copy link
Contributor

Choose a reason for hiding this comment

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

Assuming #9188 is merged, then you will be able to change the readonly status, so we might need to clarify what "This" is referring to in this message

@jrasm91
Copy link
Contributor

jrasm91 commented May 3, 2024

Hey, thanks for working on this and sorry for the confusion/back and forth around this topic. Internally we have had a lot of discussions about the direction we want to take external libraries. Long story short, we decided to go ahead with the implementation laid out in #9235.

@jrasm91 jrasm91 closed this May 3, 2024
@rokiden
Copy link
Author

rokiden commented May 3, 2024

This is good news, for me it’s much better that the team took it upon themselves. Thanks! I was glad to help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external-library Issues related to external libraries
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants