Skip to content
This repository was archived by the owner on Nov 23, 2026. It is now read-only.

refactor: remove share status in favour of syncEnabled - #10421

Merged
JammingBen merged 2 commits into
masterfrom
remove-share-status
Jan 31, 2024
Merged

JammingBen merged 2 commits into
masterfrom
remove-share-status

Conversation

@JammingBen

@JammingBen JammingBen commented Jan 30, 2024 •

Copy link
Copy Markdown
Contributor

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
@update-docs

update-docs Bot commented Jan 30, 2024

Copy link
Copy Markdown

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
30 of 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

@dschmidt dschmidt left a comment

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.

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

@dschmidt dschmidt Jan 31, 2024 •

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.

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

@JammingBen JammingBen Jan 31, 2024 •

Copy link
Copy Markdown
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 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
Copy Markdown
Member

Choose a reason for hiding this comment

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

sweeeeeeeeeeeeeeeeeeeeeeeeeeeeet

await triggerShareAction({
resource,
status: resource.status,
status: resource.syncEnabled ? 0 : 2,

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.

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

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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).

@sonarqubecloud

Copy link
Copy Markdown

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
@delete-merged-branch
delete-merged-branch Bot deleted the remove-share-status branch January 31, 2024 14:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants