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

Asset link type sources in project config don't match volume UIDs #144

Closed
sidm1983 opened this issue Feb 24, 2021 · 11 comments
Closed

Asset link type sources in project config don't match volume UIDs #144

sidm1983 opened this issue Feb 24, 2021 · 11 comments

Comments

@sidm1983
Copy link

sidm1983 commented Feb 24, 2021

I have a Craft CMS site running in headless mode and I am using the Typed Link Field plugin (version 2.0.0-beta.12).

When I customise the asset link type in the link field to only allow picking of assets from certain asset sources, I get the following in my project config:

- asset
-
  __assoc__:
    -
      - enabled
      - true
    -
      - allowCustomQuery
      - false
    -
      - allowCrossSiteLink
      - false
    -
      - sources
      -
        - 'folder:ffb39844-f556-4c29-b4a8-7b181bf72ec1'

This looks fine on the surface, however, I have now realised that the UID being referenced by folder:ffb39844-f556-4c29-b4a8-7b181bf72ec1 does not match the UID of the volume I have selected. It seems to be using a different UID and not the UID or handle of the selected volume from the YAML in the volumes project config folder. In other words, the UID being referenced here cannot be found anywhere else in any of the project config YAML files. The YAML filename of the asset volume referenced above is actually documents--75d8bc6f-c819-4a59-b465-84f8496d9f39.yaml, so I am expecting the above reference to be folder:75d8bc6f-c819-4a59-b465-84f8496d9f39 instead of what it is above.

As a result of this, every time I do a clean install of Craft CMS (e.g. when a new developer joins the team or freshly setting up a different environment like QA, UAT or PROD), that database doesn't end up having this UID and so none of my previously selected asset sources get preselected after a fresh Craft CMS install. The UID used above seems to be a dynamic UID that changes every time Craft is freshly installed.

In contrast, the "Entry" link type correctly uses the UID of the section it is referencing as seen in the filename of the section's project config YAML. For example, my entry source for the same link field above is section:47f8d07e-c48a-4ec2-8420-36ea82eb50ba and the YAML filename of this section is article--47f8d07e-c48a-4ec2-8420-36ea82eb50ba.yaml which match up correctly.

Please fix this issue as this is causing all my environments to not have the asset sources preselected because they don't have the same UID being referenced by the asset sources in the project config for the asset link type.

Also, just in case it matters, my asset volumes are all remote volumes that store the underlying files in Azure Blob Storage using the Azure Blob Remote Volume plugin in the plugin store (https://plugins.craftcms.com/azure-blob-remote-volume).

Any thoughts or help in fixing this soon would be greatly appreciated.

Thank you 🙏🏽

Craft CMS version: 3.6.4.1
Type Linked Field version: 2.0.0-beta.12
Azure Blob Remote Volume version: 1.1.1
PHP version: 7.3
Database driver & version: PGSQL 11

@sidm1983
Copy link
Author

Hi @sebastian-lenz, just checking to see if you have any thoughts about this issue. Please let me know when you get a chance. Thank you. 🙏🏽

@sebastian-lenz
Copy link
Owner

Hey @sidm1983, no need to put pressure on me. This plugin is free and open source and if you need a change quickly you are free to fork and adjust the code to your liking.

As your snippet from the project configuration shows, we currently store the folder identifier (folder:ffb39...) when selecting particular assets sources. We do this for quite a long time as that format is expected by the ui element for selecting elements exposed by the CMS.

Unfortunately the folder ids change between different Craft instances as they are not part of the project configuration. There is a volume identifier though that stays the same. So it would make sense we switch the source storage on our side from the folder to the volume ids.

@sidm1983
Copy link
Author

sidm1983 commented Feb 28, 2021

@sebastian-lenz, I was definitely not trying to put pressure on you. Sorry if it came across that way and made you feel pressured. 🙏🏽

I am definitely super appreciative for the plugin as it helps simplify content entry for links in my entry types. Thanks for creating this plugin. 🙌🏽

I do normally help out and contribute where I can, however, I am very new to Craft CMS & PHP in general, so I didn't want to make a mess of things.

Thank you for doing the switch to volume IDs so quickly. It is definitely appreciated.

I can see that your commit references beta 13. I will update to that and do some testing on my end first thing tomorrow morning. Will report back (or try to contribute/fix) if I find any issues.

Once again, sorry and thank you. 🙏🏽

@sidm1983
Copy link
Author

sidm1983 commented Mar 1, 2021

@sebastian-lenz, just reporting back. I tried to install v2.0.0-beta.13, however, composer couldn't find the beta 13 version. I got the following error:

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires sebastianlenz/linkfield ^2.0.0-beta.13, found sebastianlenz/linkfield[dev-master, 1.0.1, ..., v1.0.x-dev, 2.0.0-beta.1, ..., 2.0.0-beta.12] but it does not match the constraint.

Please let me know when beta 13 is available or if there is another way for me to get your updates.

Thank you.

@sebastian-lenz
Copy link
Owner

Hi @sidm1983, i did not tag a version beta.13 yet so it is not available. If you want to access the changes early, you can upgrade to dev-master which will install the latest available version:

"require": {
  "sebastianlenz/linkfield": "dev-master",
}

You can also directly point to the commit that contains the new feature, which ensures you won't update to other upcoming pre-release versions:

"require": {
  "sebastianlenz/linkfield": "dev-master#ced723f",
}

If you do so, you should remember to remove that line and return to the version 2 tag once version 13 is out so you get updates after that.

@sidm1983
Copy link
Author

sidm1983 commented Mar 1, 2021

@sebastian-lenz thank you. I will try it today and let you know how I go. 🙌🏽👍🏽

@sidm1983
Copy link
Author

sidm1983 commented Mar 4, 2021

@sebastian-lenz, I have been testing your recent updates and I have found an issue.

When I explicitly select one or more asset sources while configuring the link field, the asset picker on the asset link field type doesn't show any assets. The asset picker modal loads when I click the "+ Choose" button, but then none of the assets in the allowed volumes show up. Please see the following screenshots.

Here is a screenshot of my "Asset" type configuration in the link field:
image
As you can see, I have selected "Documents" as the only allowed asset source for the asset link type.

Here you can see that I actually have a document in my "Documents" volume:
image

And lastly, here is the asset picker modal that comes up when I click the "+ Choose" button for an asset link type:
image

I believe this used to work before when it was still using folder UIDs, but has stopped working since the switch to volume UIDs.

If I select "All" as the allowed asset sources for the asset link type, then the asset picker modal works and displays all volumes/assets.

Not sure if this is just something I have misconfigured or if you are also able to replicate this on your end.
Please let me know when you get a chance.

PS: All of the volumes you see in my screenshots are remote volumes that are set up and configured using the Azure Blob Remote Volume plugin in the plugin store (https://plugins.craftcms.com/azure-blob-remote-volume). This shouldn't make a difference as I believe it was working with these remote volumes prior to the switch to volume UIDs and also selecting the "All" option works, but just thought I'd bring this to your attention in case there is an edge case here.

Thank you! 🙏🏽

@sebastian-lenz
Copy link
Owner

Ah, I'm sorry, I missed something while cleaning up my code mess. We must transform the volume ids before sending them to element select, I've added that part back to the plugin. The volumes now correctly show up for me.

@sidm1983
Copy link
Author

sidm1983 commented Mar 4, 2021

No worries at all @sebastian-lenz. I will pull your latest updates and test them soon. Will let you know how I go. Thank you.

@sidm1983
Copy link
Author

sidm1983 commented Mar 5, 2021

@sebastian-lenz I just tested this and it is working again now. Asset modal now shows the correct volume and assets and also the volume UID switch is working and pre-selecting the correct volumes on my QA environment. Closing this issue now. Thank you. 🙏🏽

@sidm1983 sidm1983 closed this as completed Mar 5, 2021
@sebastian-lenz
Copy link
Owner

That's great to here. Thank you for your feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants