-
Notifications
You must be signed in to change notification settings - Fork 16
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 CMS 6 compatibility #346
base: 3.0
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
Name: campaign-admin-extensions | ||
--- | ||
SilverStripe\Assets\Shortcodes\FileLink: | ||
extensions: | ||
- SilverStripe\CampaignAdmin\Extensions\HideInCampaignsExtension | ||
--- | ||
Name: campaign-admin-extensions-elemental | ||
Only: | ||
moduleexists: dnadesign/silverstripe-elemental | ||
--- | ||
DNADesign\Elemental\Models\ElementalArea: | ||
extensions: | ||
- SilverStripe\CampaignAdmin\Extensions\HideInCampaignsExtension | ||
--- | ||
Name: campaign-admin-extensions-asset-admin | ||
Only: | ||
moduleexists: silverstripe/asset-admin | ||
After: assetadmin | ||
--- | ||
SilverStripe\AssetAdmin\Forms\FileFormFactory: | ||
extensions: | ||
- SilverStripe\CampaignAdmin\Extensions\FileFormFactoryExtension | ||
SilverStripe\AssetAdmin\Controller\AssetAdmin: | ||
campaign_admin_managed_data_class: SilverStripe\Assets\File | ||
extensions: | ||
- SilverStripe\CampaignAdmin\Extensions\AddToCampaignExtension | ||
--- | ||
Name: campaign-admin-extensions-cms | ||
Only: | ||
moduleexists: silverstripe/cms | ||
--- | ||
SilverStripe\CMS\Model\SiteTree: | ||
extensions: | ||
- SilverStripe\CampaignAdmin\SiteTreeExtension | ||
SilverStripe\CMS\Controllers\CMSPageEditController: | ||
campaign_admin_managed_data_class: Page | ||
extensions: | ||
- SilverStripe\CampaignAdmin\Extensions\AddToCampaignExtension |
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
require('../boot/index'); | ||
import '../legacy/AddToCampaignForm'; | ||
import '../boot/index'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/* global window */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is JS that used to be in admin silverstripe/silverstripe-admin#1857 |
||
import i18n from 'i18n'; | ||
import jQuery from 'jquery'; | ||
import React from 'react'; | ||
import { createRoot } from 'react-dom/client'; | ||
import { loadComponent } from 'lib/Injector'; | ||
|
||
const FormBuilderModal = loadComponent('FormBuilderModal'); | ||
|
||
jQuery.entwine('ss', ($) => { | ||
/** | ||
* Kick off an "add to campaign" dialog from the CMS actions. | ||
*/ | ||
$( | ||
'.cms-content-actions .add-to-campaign-action,' + | ||
'#add-to-campaign__action' | ||
).entwine({ | ||
onclick() { | ||
let dialog = $('#add-to-campaign__dialog-wrapper'); | ||
|
||
if (!dialog.length) { | ||
dialog = $('<div id="add-to-campaign__dialog-wrapper" />'); | ||
$('body').append(dialog); | ||
} | ||
|
||
dialog.open(); | ||
|
||
return false; | ||
}, | ||
}); | ||
|
||
// This is required because the React version of e.preventDefault() doesn't work | ||
// this is to prevent PJAX request to occur when clicking a link the modal | ||
$('.add-to-campaign-modal .add-to-campaign-modal__nav-link').entwine({ | ||
onclick: (e) => { | ||
e.preventDefault(); | ||
const $link = $(e.target); | ||
window.location = $link.attr('href'); | ||
}, | ||
}); | ||
|
||
/** | ||
* Uses reactstrap in order to replicate the bootstrap styling and JavaScript behaviour. | ||
* The "add to campaign" dialog is used in a similar fashion in AssetAdmin. | ||
*/ | ||
$('#add-to-campaign__dialog-wrapper').entwine({ | ||
ReactRoot: null, | ||
|
||
onunmatch() { | ||
// solves errors given by ReactDOM "no matched root found" error. | ||
this._clearModal(); | ||
}, | ||
|
||
open() { | ||
this._renderModal(true); | ||
}, | ||
|
||
close() { | ||
this._renderModal(false); | ||
}, | ||
|
||
_renderModal(isOpen) { | ||
const handleHide = () => this.close(); | ||
const handleSubmit = (...args) => this._handleSubmitModal(...args); | ||
const id = $('form.cms-edit-form :input[name=ID]').val(); | ||
const sectionConfigKey = 'SilverStripe\\CMS\\Controllers\\CMSPageEditController'; | ||
const store = window.ss.store; | ||
const sectionConfig = store.getState().config.sections | ||
.find((section) => section.name === sectionConfigKey); | ||
const modalSchemaUrl = `${sectionConfig.form.addToCampaignForm.schemaUrl}/${id}`; | ||
const title = i18n._t('Admin.ADD_TO_CAMPAIGN', 'Add to campaign'); | ||
|
||
let root = this.getReactRoot(); | ||
if (!root) { | ||
root = createRoot(this[0]); | ||
} | ||
root.render( | ||
<FormBuilderModal | ||
title={title} | ||
isOpen={isOpen} | ||
onSubmit={handleSubmit} | ||
onClosed={handleHide} | ||
schemaUrl={modalSchemaUrl} | ||
bodyClassName="modal__dialog" | ||
className="add-to-campaign-modal" | ||
responseClassBad="modal__response modal__response--error" | ||
responseClassGood="modal__response modal__response--good" | ||
identifier="Admin.AddToCampaign" | ||
/> | ||
); | ||
this.setReactRoot(root); | ||
}, | ||
|
||
_clearModal() { | ||
const root = this.getReactRoot(); | ||
if (root) { | ||
root.unmount(); | ||
this.setReactRoot(null); | ||
} | ||
// this.empty(); | ||
}, | ||
|
||
_handleSubmitModal(data, action, submitFn) { | ||
return submitFn(); | ||
}, | ||
|
||
}); | ||
}); |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,8 +24,7 @@ | |
"php": "^8.3", | ||
"silverstripe/admin": "^3", | ||
"silverstripe/framework": "^6", | ||
"silverstripe/versioned": "^3", | ||
"silverstripe/vendor-plugin": "^2" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using the vendor-plugin defined in framework instead |
||
"silverstripe/versioned": "^3" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "^11.3", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,25 +33,20 @@ | |
"homepage": "https://github.com/silverstripe/silverstripe-campaign-admin", | ||
"dependencies": { | ||
"@popperjs/core": "^2.11.6", | ||
"bootstrap": "^4.6.2", | ||
"bootstrap": "^5.2.0", | ||
"classnames": "^2.3.2", | ||
"core-js": "^3.26.0", | ||
"deep-freeze-strict": "^1.1.1", | ||
"prop-types": "^15.8.1", | ||
"react": "^18.2.0", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed all of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume you mean "because I couldn't run |
||
"react-dom": "^18.2.0", | ||
"react-redux": "^8.0.5", | ||
"react-router-dom": "^6.4.3", | ||
"reactstrap": "^8.9.0", | ||
"redux": "^4.2.0", | ||
"redux-form": "^8.3.8", | ||
"redux-mock-store": "^1.5.4", | ||
"redux-thunk": "^2.4.2" | ||
"reactstrap": "^9.2.0", | ||
"redux": "^5.0.1", | ||
"redux-form": "^8.3.10", | ||
"redux-thunk": "^3.1.0" | ||
}, | ||
"devDependencies": { | ||
"@silverstripe/eslint-config": "^1.3.0", | ||
"@silverstripe/webpack-config": "^3.0.0-alpha1", | ||
"@testing-library/react": "^14.0.0", | ||
"@silverstripe/webpack-config": "^3.0.0-alpha3", | ||
"@testing-library/react": "^16.1.0", | ||
"babel-core": "^6.26.3", | ||
"babel-jest": "^29.3.0", | ||
"babel-loader": "^9.1.0", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These used to be done in Versioned silverstripe/silverstripe-versioned#482
The plural_name is used here with a call to ChangeSet::singleton()->i18n_pluralise()
We may as well also keep the singlular_name for consistency