Skip to content

FolderPicker - Improvment to automatically detect URL type #1658

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

Open
michaelmaillot opened this issue Sep 26, 2023 · 3 comments
Open

FolderPicker - Improvment to automatically detect URL type #1658

michaelmaillot opened this issue Sep 26, 2023 · 3 comments
Labels
help wanted type:enhancement New feature or enhancement of existing capability

Comments

@michaelmaillot
Copy link
Collaborator

Category

[x] Enhancement

[ ] Bug

[ ] Question

Version

Please specify what version of the library you are using: [3.15.0]

Expected / Desired Behavior / Question

Raised by #1379, the idea is to enhance the rootFolder.ServerRelativeUrl to automatically detect if it's absolute or not

Observed Behavior

Current version of the control only works with server relative URL. Some additional work has to be done when working with another site collection than the context's one.

Steps to Reproduce

  • Add the FolderPicker control in a SPFx project
  • Set the siteAbsoluteUrl prop to another site collection
  • Try to set the site collection's library with server relative URL
@ghost
Copy link

ghost commented Sep 26, 2023

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

@michaelmaillot
Copy link
Collaborator Author

michaelmaillot commented Sep 26, 2023

@stevebeauge, if you would like to give a hand on this one, let us know 🙂

Edit: of course, if I've mistakenly wrote the improvment idea, please let me know.

@stevebeauge
Copy link
Contributor

I think the improvement can be broader than just the folder picker. Let me reformulate my vision

Basically, SharePoint has three kind of URL:

  • Absolute URL: https://contoso.sharepoint.com/sites/somesite/shared documents/mydoc.pdf
  • Server relative URL: /sites/somesite/shared documents/mydoc.pdf
  • Web relative URL: shared documents/mydoc.pdf

Most of the SharePoint API require one specific form of URL (server relative is the most used I'd say).

This leads the developer to need an understanding of which form of url is required, and convert from another form (ex: type the url of a site collection in a textbox and query data inside it).

My proposal is to integrate a utility module that can convert any url to the desired form. Whenever a component or a service requires a specific form of url which is dependent on external input, such utility may ensure the correctness of the application.

For example, regarding the FolderPicker, we could replace siteAbsoluteUrl by simply siteUrl. The developer does not need to worry about the form of the url. He may pass https://contoso.sharepoint.com/sites/somesite or /sites/somesite. Both would work.

This is only an example. Once the utility is present in the code, progressive inclusion of the helper could be added to existing controls.

Such utility is already in place in our spfx code base. I should be able to port it (the code is actually quite simple). These functions are available:

export declare const toServerRelativeUrl: (url: string) => string;
export declare const toAbsoluteUrl: (url: string) => string;
export declare const toWebRelativeUrl: (webUrl: string, objectUrl: string) => string;

If you think this idea has its place, I can try to apply on the folder picker as a try

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted type:enhancement New feature or enhancement of existing capability
Projects
None yet
Development

No branches or pull requests

2 participants