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

ENH Refactor: Improve code quality, remove unused code, general tidy up. #216

Merged

Conversation

GuySartorelli
Copy link
Member

@GuySartorelli GuySartorelli commented Feb 12, 2024

Requires silverstripe/silverstripe-admin#1678 to be merged for i18n stuff

Note that I have made changes in discrete commits so it's easier to review each type of change by just looking at each commit individually. Commits can be squashed if you want, though.

Issue

@GuySartorelli GuySartorelli marked this pull request as ready for review February 12, 2024 23:22
Comment on lines 4 to +11
SilverStripe\Admin\LeftAndMain:
extensions:
- SilverStripe\LinkField\Extensions\LeftAndMainExtension
extra_requirements_javascript:
'silverstripe/linkfield:client/dist/js/bundle.js':
defer: true
extra_requirements_i18n:
- 'silverstripe/linkfield:client/lang'
extra_requirements_css:
- 'silverstripe/linkfield:client/dist/styles/bundle.css'
Copy link
Member Author

Choose a reason for hiding this comment

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

Copied from the LeftAndMainExtension - no sense having a whole extension for this. I've also raised a card to do this for other modules.

Copy link
Member Author

Choose a reason for hiding this comment

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

This wasn't being used and probably doesn't even work with the updated code.

Copy link
Member Author

Choose a reason for hiding this comment

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

This replaces the traits, and also includes some code that was duplicated across the two linkfield implementations.

/**
* Set the priority of this link type in the CMS menu
*/
private static int $menu_priority = 30;
Copy link
Member Author

Choose a reason for hiding this comment

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

I updated the PHPDoc for this config property in Link - rather than trying to keep these in sync, I've opted to just remove the duplicates. API docs are smart enough to carry the description through, and for custom link types you'll probably be looking at Link rather than one of the subclasses anyway.

Comment on lines -9 to -12
use SilverStripe\Forms\CompositeValidator;
use SilverStripe\Forms\DropdownField;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\RequiredFields;
Copy link
Member Author

Choose a reason for hiding this comment

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

Here and anywhere else I've removed use statements, it's cause they weren't being used.

Comment on lines -58 to -62
* In-memory only property used to change link type
* This case is relevant for CMS edit form which doesn't use React driven UI
* This is a workaround as changing the ClassName directly is not fully supported in the GridField admin
*/
private ?string $linkType = null;
Copy link
Member Author

@GuySartorelli GuySartorelli Feb 13, 2024

Choose a reason for hiding this comment

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

This was used to let you pick a link type if creating a link in a gridfield. This isn't something we want to support, and if people really want to do it they should use GridFieldAddNewMultiClass from symbiote/silverstripe-gridfieldextensions

Most (if not all) of the other code removed in this class is related to this feature.

Copy link
Member

@emteknetnz emteknetnz left a comment

Choose a reason for hiding this comment

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

Tested locally, all seems to be working as expected

@emteknetnz emteknetnz merged commit 2bf91ca into silverstripe:4 Feb 13, 2024
10 checks passed
@emteknetnz emteknetnz deleted the pulls/4/standardise-module branch February 13, 2024 04:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants