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

Fix root site org asset library showing no items in file picker #603

Merged

Conversation

daniellinden22
Copy link
Contributor

@daniellinden22 daniellinden22 commented Feb 18, 2024

Q A
Bug fix? [ X ]
New feature? [ ]
New sample? [ ]
Related issues? #595

Issue

  • When the file picker is used to pick files from an organizational asset library on the SharePoint root site, no files are shown.

What's in this Pull Request?

  1. Fix library name missing from the listFullUrl query parameter, which caused the REST API request to retrieve items from an organizational assets library to fail, on the SharePoint root site.
  2. Also fix an error in the _parseOrgAssetsLibraryItem function, which causes the absoluteUrl property to lack one / after the root SharePoint URL (e.g. "https://TENANT.sharepoint.comOrganizational Media Library" or "https://TENANT.sharepoint.comsites/OrgAssetsSite/Branding images"). Since this is faulty for org asset libraries on ALL sites, I don't think this property is used, otherwise it would have caused problems already.
    • See screenshots below for the behaviour.

Explanation of the error in file picker of organizational asset library:

  1. The relative url of the root site is /, which causes a / to still be present in the library name, after removal of the site relative url.
  2. This is turn causes the library name to be an empty string after splitting the library name on /.
  3. When building the API request URL for retrieving the organizational assets library items, the library name is therefore missing from the listFullUrl query parameter (e.g. "https://TENANT.sharepoint.com//" instead of "https://TENANT.sharepoint.com/Organizational Media Library").
  • In addition to this, the listFullUrl query parameter can't contain two slashes in front of the library name (e.g. "https://TENANT.sharepoint.com//Organizational Media Library") This also causes the request to fail).
  • This error would also happen if the site server relative url (_orgAssetsLibraryServerRelativeSiteUrl) starts with a slash.

Screenshots / GIFs

File picker error
Left side has a org. assets library on a site under /sites/, while the right one has one on the root SharePoint site. The gifs are roughly 1,5 minutes long.
pnp-595-comparison-rec
Showcasing the current behavior, stepping through the code and showing property values.

pnp-595-comparison-fix-rec
Showcasing the fixed behavior, stepping through the code and showing property values.

_parseOrgAssetsLibraryItem
pnp-595-parseOrgAssetsLibraryItem-root
Showing faulty absoluteUrl property on the org asset library, when retrieving from the root SharePoint site.

pnp-595-parseOrgAssetsLibraryItem-site
Showing faulty absoluteUrl property on the org asset library, when retrieving from a site under /sites/.

pnp-595-parseOrgAssetsLibraryItem-fixed
Showing fixed property.

- When the file picker is used to pick files from an organizational asset library on the SharePoint root site, no files are shown.
- Also fix an error in the _parseOrgAssetsLibraryItem function, which causes the absoluteUrl property to lack one / after the root SharePoint URL (e.g. "https://TENANT.sharepoint.comOrganizational Media Library" or "https://TENANT.sharepoint.comsites/OrgAssetsSite/Branding images"). Since this is faulty for org asset libraries on ALL sites, I don't think this property is used, otherwise it would have caused problems already.

Explanation of error in file picker of organizational asset library:
1. The relative url of the root site is /, which causes a / to still be present in the library name, after removal of the site relative url.
2. This is turn causes the library name to be an empty string after splitting the library name on /.
3. When building the API request URL for retrieving the organizational assets library items, the library name is therefore missing from the listFullUrl query parameter.
- In addition to this, the listFullUrl query parameter can't contain two slashes in front of the library name (also causes the request to fail).
- This error would also happen if the site server relative url (_orgAssetsLibraryServerRelativeSiteUrl) starts with a slash.
@joaojmendes joaojmendes self-assigned this Apr 17, 2024
@joaojmendes joaojmendes added the status:fixed-next-drop Issue will be fixed in upcoming release. label Apr 17, 2024
@joaojmendes joaojmendes added this to the 3.17.0 milestone Apr 17, 2024
@joaojmendes joaojmendes merged commit db773cc into pnp:dev Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:fixed-next-drop Issue will be fixed in upcoming release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants