-
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
FIX Create campaign success message #37
FIX Create campaign success message #37
Conversation
0840b53
to
ec321c7
Compare
@@ -352,6 +436,7 @@ function mapStateToProps(state, ownProps) { | |||
record: record || {}, | |||
campaign: state.campaign, | |||
treeClass, | |||
newItemCreated: state.campaign.newItemCreated, |
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.
proptypes definition for this
if (this.props.record.State === 'open') { | ||
if (!items || items.length === 0) { | ||
actionProps = Object.assign(actionProps, { | ||
title: i18n._t('CampaignAdmin.PUBLISHCAMPAIGN'), |
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.
add translation default fallback
className="flexbox-area-grow | ||
fill-height | ||
preview | ||
campaign-admin__campaign-preview |
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.
shouldn't have new lines in double quoted strings...
move these to a variable or classnames object
@@ -6,6 +6,7 @@ const initialState = deepFreeze({ | |||
changeSetItemId: null, | |||
isPublishing: false, | |||
view: null, | |||
newItemCreated: false, |
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.
the name for this is quite confusing, since this is a boolean type, it should describe the question like isNewItem
or hasNewItem
.
newItemCreated
implies it's an object that was just created.
* @param {boolean} | ||
* @return {Object} | ||
*/ | ||
export function setNewCampaignCreated(newItemCreated) { |
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.
naming is inconsistent with what it's doing, maybe setIsNewItem
or markHasCreatedItem
having both New
and Created
is double up on meaning.
@@ -119,7 +120,8 @@ class CampaignAdmin extends SilverStripeComponent { | |||
// open the new campaign in edit mode after save completes | |||
const sectionUrl = this.props.sectionConfig.url; | |||
const id = response.record.id; | |||
this.props.router.push(`${sectionUrl}/set/${id}/edit`); | |||
this.props.campaignActions.setNewCampaignCreated(true); |
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.
Since the id
is available, it would be more extensible to include the record or even just the id in the record, rather than just a boolean.
In this case, you could ignore the is
or has
prefix I mentioned below. But try to keep the naming consistent still setNewItem
is perfectly fine.
7af190b
to
280d637
Compare
280d637
to
65e66c2
Compare
); | ||
const newItemInfo = newItem ? | ||
(<p className="alert alert-success alert--no-border" role="alert"> | ||
Nice one! You have successfully created a campaign. |
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.
i18n this please.
<div className={previewClasses}> | ||
<h2 className="campaign-admin__empty-heading">Getting started</h2> | ||
<p className="campaign-admin__empty-info"> | ||
Select <strong>Add to Campaign</strong> from pages, files, and other content types |
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.
i18n this please
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.
be careful with adding html to translation strings, it's heavily discouraged because you need to use dangerouslySetInnerHTML
in react... (or castStringToElement()
)
Can we use quotes instead?
I've raised this about the "Nice one!" being bold above as well, and it was agreed that we could remove the bold for that.
/** | ||
* Set new campaign | ||
* | ||
* @param {?number} |
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.
invalid JSDoc @param {Number|null}
@@ -29,6 +28,16 @@ class CampaignAdminList extends SilverStripeComponent { | |||
this.handleItemSelected = this.handleItemSelected.bind(this); | |||
this.setBreadcrumbs = this.setBreadcrumbs.bind(this); | |||
this.handleCloseItem = this.handleCloseItem.bind(this); | |||
|
|||
if (!this.isRecordLoaded()) { |
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.
since this is in the constructor, would be a good idea to pass through props to isRecordLoaded
it can default to this.props
if not provided
src/CampaignAdmin.php
Outdated
@@ -550,7 +590,7 @@ public function getCampaignCreateForm() | |||
'campaignCreateForm', | |||
$fields, | |||
FieldList::create( | |||
FormAction::create('save', _t(__CLASS__.'.SAVE', 'Save')) | |||
FormAction::create('save', _t(__CLASS__.'.SAVE', 'Create')) |
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.
this isn't good practice, please create a new translation key entry... the fallback doesn't even take effect.
<div className={previewClasses}> | ||
<h2 className="campaign-admin__empty-heading">Getting started</h2> | ||
<p className="campaign-admin__empty-info"> | ||
Select <strong>Add to Campaign</strong> from pages, files, and other content types |
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.
be careful with adding html to translation strings, it's heavily discouraged because you need to use dangerouslySetInnerHTML
in react... (or castStringToElement()
)
Can we use quotes instead?
I've raised this about the "Nice one!" being bold above as well, and it was agreed that we could remove the bold for that.
src/CampaignAdmin.php
Outdated
'noItemText' => 'Add from ' . $class->i18n_plural_name() . ' area', | ||
'items' => [] | ||
]; | ||
} |
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.
I'm not comfortable with the idea of cross-module references like this...
Can these be added by an extension hook, rather than hardcoded in to campaign admin?
It could even be an array of classes in a config.
Either extension hook or config will be fine, both could be a best of both worlds.
src/CampaignAdmin.php
Outdated
'baseClass' => DataObject::getSchema()->baseDataClass('SilverStripe\Assets\File'), | ||
'singular' => $class->i18n_singular_name(), | ||
'plural' => $class->i18n_plural_name(), | ||
'noItemText' => 'Add from ' . $class->i18n_plural_name() . ' area', |
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.
Oops and this could be i18n translated
{ | ||
listGroupItems.length > 0 | ||
? listGroupItems | ||
: <p className="list-group-item">{group.noItemsText}</p> |
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.
@phalkunz please note, we're following airbnb formatting standards (to an extent) so ternary conditions should break like this:
condition
? item
: null
ref: https://github.com/airbnb/javascript/#comparison--nested-ternaries the better section
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.
👍
src/CampaignAdmin.php
Outdated
@@ -155,6 +159,34 @@ public function readCampaigns() | |||
return $response; | |||
} | |||
|
|||
protected function getPlaceholderGroups() |
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.
PHPDoc please.
src/CampaignAdmin.php
Outdated
{ | ||
$groups = []; | ||
|
||
$classes = Config::inst()->get(self::class, 'placeholder_group_classes'); |
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.
This is a duplication of ChangeSet::important_classes config.
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.
What do you mean by this? Should we be using ChangeSet.important_classes
instead?
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.
Never mind, I see your comment below.
@@ -315,6 +374,19 @@ class CampaignAdminList extends SilverStripeComponent { | |||
return groups; | |||
} | |||
|
|||
getPlaceholderGroups() { |
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.
I'm not sure why we need this api; doesn't groupItemsForSet() build the groups automatically?
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.
ok, @phalkunz has explained why this is necessary. The only change I'd request is the switch to using the existing config for important_classes instead.
src/CampaignAdmin.php
Outdated
'data' => [ | ||
'pristineTitle' => _t(__CLASS__.'SAVED', 'Saved'), | ||
'pristineIcon' => 'tick', | ||
'dirtyTitle' => _t(__CLASS__.'SAVECHANGES', 'Save changes'), |
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.
@unclecheese Looks like this render the title set above (line 521) redundant.
src/CampaignAdmin.php
Outdated
|
||
foreach ($classes as $class) { | ||
/** @var DataObject $item */ | ||
$item = Injector::inst()->get($class); |
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.
get() won't return null if the class doesn't exist, it'll throw an exception. Can you use class_exists() instead please?
Issue: #16
Requires silverstripe/silverstripe-admin#178 to be merged first
Merge these after this