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

Custom alert style #167

Merged
merged 13 commits into from
Aug 2, 2017

Conversation

phalkunz
Copy link
Contributor

@phalkunz phalkunz commented Jul 23, 2017


getSavedIcon() {
// In case this is specified directly
return this.props.savedIcon || this.props.data.savedIcon || null;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are all these fields in two places? They should either be on this.props or this.props.data.

Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like there's a bug that you're working around rather than fixing.

if (savedClasses && this.props.changed) {
savedClasses.split(' ').forEach((cl) => {
buttonClasses[`btn-${cl}`] = true;
});
Copy link
Contributor

Choose a reason for hiding this comment

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

can the classes have the btn- prefix when declared/added rather than magically added here?
Or perhaps it's more appropriate to call this savedButtonClass...

@@ -72,6 +86,17 @@ class FormAction extends SilverStripeComponent {
}

/**
* @return {boolean}
*/
isConstructive() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think isPrimary() or isPrimaryType() is a better name, it took me a while to work out what "constructive" meant and I doubt I'll remember a month later :)

const changed = !!(
state.unsavedForms &&
state.unsavedForms.find(form => ownProps.identifier === form.name)
);
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we use the isDirty() API provided by redux-forms?
isDirty(form.name, getFormState)(state);

// Action text when there's no changes detected in the form
savedTitle: React.PropTypes.string,
savedIcon: React.PropTypes.string,
savedClasses: React.PropTypes.string,
Copy link
Contributor

Choose a reason for hiding this comment

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

missing definition in the data prop

type: React.PropTypes.string,
loading: React.PropTypes.bool,
icon: React.PropTypes.string,
disabled: React.PropTypes.bool,
changed: React.PropTypes.bool,
Copy link
Contributor

Choose a reason for hiding this comment

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

this should be named formChanged I think, not to be confused with this actual component changing somehow

@phalkunz phalkunz force-pushed the pulls/1.0/create-success-msg branch from 940092b to dfc698b Compare July 27, 2017 23:45
@unclecheese unclecheese force-pushed the pulls/1.0/create-success-msg branch 2 times, most recently from 1db560b to 12f600e Compare August 2, 2017 00:01
});
return {
...field,
title: isPristine ? field.data.pristineTitle : field.data.dirtyTitle,
Copy link
Contributor

Choose a reason for hiding this comment

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

What if pristineTitle and dirtyTitle aren't set? FormField.php doesn't set these by default either.

Copy link
Contributor

Choose a reason for hiding this comment

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

You could get rid of dirtyTitle and just have title (for dirty / normal) and optional pristineTitle

Choose a reason for hiding this comment

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

Have updated this to have fallback value

Copy link
Contributor

@flamerohr flamerohr left a comment

Choose a reason for hiding this comment

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

Two minor changes I'll push up soon

@@ -8,6 +8,7 @@ import { setConfig } from 'state/config/ConfigActions';
import registerComponents from 'boot/registerComponents';
import registerReducers from 'boot/registerReducers';
import applyDevtools from 'boot/applyDevtools';
import transforms from './transforms';
Copy link
Contributor

Choose a reason for hiding this comment

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

import from boot/transforms would be following existing conventions, could this be named applyTransforms

return {
...field,
title: (isPristine ? field.data.pristineTitle : field.data.dirtyTitle) || field.title,
icon: (isPristine ? field.data.pristineIcon : field.data.dirtyIcon) || field.icon,
Copy link
Contributor

Choose a reason for hiding this comment

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

could we move the isPristine ? x : y parts to customTitle/Icon constants?

@flamerohr flamerohr merged commit 63d9588 into silverstripe:1 Aug 2, 2017
@flamerohr flamerohr deleted the pulls/1.0/create-success-msg branch August 2, 2017 22:06
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.

4 participants