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

refactor: remove share status in favour of syncEnabled #10421

Merged
merged 2 commits into from
Jan 31, 2024

Conversation

JammingBen
Copy link
Contributor

@JammingBen JammingBen commented Jan 30, 2024

Description

Remove share status in favour of the syncEnabled property since sharing NG won't have share statuses anymore. Also renames the actions and test steps accordingly.

The remaining places where we still use the status (e.g. triggerShareAction) are deprecated and will be removed with one of the next changes.

In addition to that I decided to introduce OutgoingShareResource and IncomingShareResource interfaces that extend ShareResoruce, since some properties are only available on incoming share resources. This makes type checking easier and even allows us to kill some of the pesky route checks (e.g. IncomingShareResource == "Shared with me" page).

Related Issue

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests
  • Documentation
  • Maintenance (e.g. dependency updates or tooling)

@JammingBen JammingBen self-assigned this Jan 30, 2024
Copy link

update-docs bot commented Jan 30, 2024

Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would create a changelog item based on your changes.

@JammingBen JammingBen mentioned this pull request Jan 30, 2024
40 tasks
@JammingBen JammingBen force-pushed the remove-share-status branch 3 times, most recently from 36ef6ec to d9a7d0b Compare January 30, 2024 12:32
@JammingBen JammingBen force-pushed the remove-share-status branch 4 times, most recently from 381d60f to 51cf938 Compare January 30, 2024 17:11
@delete-merged-branch delete-merged-branch bot deleted the branch master January 31, 2024 07:05
@JammingBen JammingBen changed the base branch from sharing-ng-shared-with-me to master January 31, 2024 07:16
@JammingBen JammingBen marked this pull request as ready for review January 31, 2024 07:53
Copy link
Member

@dschmidt dschmidt left a comment

Choose a reason for hiding this comment

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

Greeeeaaaaaat! 🎉

Personally I probably wouldn't have gotten rid of the ShareStatus enum/class just yet, because I feel the magic numbers will be harder to review in the upcoming iterations ... but I wouldn't revert the change now either

resource.status = parseInt(share.state)
resource.hidden = share.hidden === 'true' || share.hidden === true
;(resource as IncomingShareResource).syncEnabled = parseInt(share.state) === 0
;(resource as IncomingShareResource).hidden = share.hidden === 'true' || share.hidden === true
Copy link
Member

@dschmidt dschmidt Jan 31, 2024

Choose a reason for hiding this comment

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

As you already implemented type predicates, can't we somehow narrow the type down here properly reasonably instead of just casting it?

https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates

Copy link
Contributor Author

@JammingBen JammingBen Jan 31, 2024

Choose a reason for hiding this comment

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

This will be removed later today, so I decided to not invest any time 😄

Edit: see #10426

return false
}
if (isIncomingShareResource(resources[0]) && !resources[0].syncEnabled) {
return false
Copy link
Member

Choose a reason for hiding this comment

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

sweeeeeeeeeeeeeeeeeeeeeeeeeeeeet

resource,
status: resource.status,
status: resource.syncEnabled ? 0 : 2,
Copy link
Member

Choose a reason for hiding this comment

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

This is probably for the time being until we're moving towards the graph client completely?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will be removed as one of the next steps, so again I decided to not invest much time into making it more readable.

client,
hidden = undefined,
spaces = [],
fullShareOwnerPaths = false
Copy link
Member

Choose a reason for hiding this comment

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

Reminds me - have you tried this with fullShareOwnerPaths? 🙈 👀

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not yet, it will probably break eventually with the transition to sharing NG (or tbh I think the first PR already broke it 😅 ). But I'd like to get this transition going first, especially because code paths like these will change in a few days anyway.

I added it to the epic though: #10418

@JammingBen
Copy link
Contributor Author

Personally I probably wouldn't have gotten rid of the ShareStatus enum/class just yet, because I feel the magic numbers will be harder to review in the upcoming iterations ... but I wouldn't revert the change now either

Yeah, I was thinking about the same but decided for the clean cut here because the remaining magic numbers will be removed as one of the next steps anyway (which is basically the triggerShareAction method).

Copy link

Quality Gate Passed Quality Gate passed

The SonarCloud Quality Gate passed, but some issues were introduced.

8 New issues
0 Security Hotspots
56.3% Coverage on New Code
19.7% Duplication on New Code

See analysis details on SonarCloud

@JammingBen JammingBen merged commit 634c0f8 into master Jan 31, 2024
3 checks passed
@delete-merged-branch delete-merged-branch bot deleted the remove-share-status branch January 31, 2024 14: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
Development

Successfully merging this pull request may close these issues.

2 participants