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

When dnadesign/silverstripe-elemental is installed, the "Select a content type" field is not available. #198

Closed
JamesDPC opened this issue Feb 17, 2021 · 5 comments
Assignees
Labels

Comments

@JamesDPC
Copy link

JamesDPC commented Feb 17, 2021

Hi

Per the subject, when the dnadesign/silverstripe-elemental and the "Blocks" tab is available in the Archives admin, the "Other" tab is available but does not show the "Select a content type" field. Instead, the others tab shows a list of all versioned dataobjects excluding SiteTree records.

With the "blocksarchive" configuration enabled (default) in archive-admin.yml:

image

With the "blocksarchive" configuration removed in archive-admin.yml, we see the field:

image

#---
#Name: blocksarchive
#Only:
#  moduleexists: dnadesign/silverstripe-elemental
#---
#DNADesign\Elemental\Models\BaseElement:
#  extensions:
#    - SilverStripe\VersionedAdmin\Extensions\BlockArchiveExtension

The culprit seems to be that the model class when the "Other" tab is active Is DNADesign\Elemental\Models\BaseElement
(https://github.com/silverstripe/silverstripe-versioned-admin/blob/1/src/ArchiveAdmin.php#L68)
This blocks the "getOtherModelSelectorField" from returning the content type selection field.

A possible fix is to ensure the modelClass value is empty when the Other tab is active ? Another is to simply default to the "Select a Content Type" field and provide the Pages, Files, Blocks selection in that field, rather than via tabs. Maybe defaulting to the first that is available depending on the modules installed.

Our workaround for this at the moment is an extension for the ArchiveAdmin to ensure the field returned from getOtherModelSelectorField is pushed onto the form in updateEditForm. This allows our content editors to filter the "Other" records.

Versions:

SS: 4.6,4.7
Version: 1.6,1.7.2

Thanks!
James

PR

@Cheddam
Copy link
Member

Cheddam commented Feb 18, 2021

Hey @JamesDPC, thanks for raising this issue?

I'm having a bit of trouble reproducing the problem - can you confirm whether ?others=1 is appended to the URL when you open the Others tab? This GET parameter is what triggers the content type selection field, so if it's somehow missing, that'd help to explain the problem.

@JamesDPC
Copy link
Author

Hi, yep, it is:

image

I'll do some more digging...

@JamesDPC
Copy link
Author

When there is no 'ModelClass' param in the request URL, the modelClass is being set in ModelAdmin::init() using the array of available versioned models returned from ArchiveAdmin::getManagedModels().

https://github.com/silverstripe/silverstripe-admin/blob/1/code/ModelAdmin.php#L152

If I enable the file tab by turning 'keep_archived_assets' on in config, the File class is added at the start of the managed models when /admin/archive/?others=1 is requested and is set as the modelClass for the request.

I think the problem lies here:
https://github.com/silverstripe/silverstripe-versioned-admin/blob/1/src/ArchiveAdmin.php#L67-L73

Both BaseElement and File have a method getArchiveField via the extension in the versioned-admin module, so the Content Type field is never added to the form.

@Cheddam
Copy link
Member

Cheddam commented Feb 22, 2021

Thanks for the additional details, @JamesDPC. I can definitely reproduce the issue when keep_archived_assets is enabled, though I still don't seem to hit it when Elemental is installed but keep_archived_assets is disabled.

Either way, there's definitely an issue with the logic here.

@GuySartorelli
Copy link
Member

PR merged. This will be automatically tagged by GitHub actions.

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

No branches or pull requests

4 participants