-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Notices: Redux everything! #1393
Changes from 31 commits
6a4462f
99d6d57
abe9eb8
2957c66
3c571fe
0320323
969fd8b
718fde2
e8ae82a
9edc979
dc75c32
3a6e337
303ae86
ab12dc4
a233628
6b8454c
9f2932c
1c90e2d
fac06c2
7c91bf3
b29b6ec
c91799a
d6e5798
8d1dbde
b81249c
faa3e18
f107d47
113f920
f07e648
e54af03
8f3d3b3
5b50b05
5da94cb
a2f7f79
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,51 @@ | ||
#!/usr/bin/env node | ||
|
||
var fs = require( 'fs' ); | ||
var validIconSizes = [ 12, 18, 24, 36, 48, 54, 72 ]; | ||
|
||
var filename = process.argv[ 2 ]; | ||
|
||
fs.readFile( filename, 'utf8', function ( err, data ) { | ||
var result = '', | ||
splittedCode, | ||
lineNumber = 1; | ||
if ( err ) { | ||
console.log(err); | ||
process.exit( 1 ); | ||
} | ||
data = data.toLowerCase(); | ||
splittedCode = data.split( '<gridicon' ); | ||
|
||
if ( splittedCode.length > 1 ) { | ||
// There are gridicon instances in this file. | ||
splittedCode.forEach( function( chunk ) { | ||
var gridiconAttrs, isNonStandard, size; | ||
if( chunk ) { | ||
// we discard all the code after the tag closing... we are only interested in the props of the gridicon. | ||
gridiconAttrs = chunk.split( '>' )[ 0 ]; | ||
isNonStandard = gridiconAttrs.indexOf( 'nonstandardsize' ) >= 0; | ||
if ( gridiconAttrs.indexOf( 'size={' ) >= 0 ) { | ||
size = gridiconAttrs.split( 'size={' )[ 1 ].split( '}' )[ 0 ]; | ||
if ( !isNaN( size ) ) { | ||
// We only can check if the size is standard if it is a number. If not (variables), we have no way of knowing if it's fine or not | ||
if( !isNonStandard && validIconSizes.indexOf( +size ) < 0 ) { | ||
result += '\033[31mNon-standard gridicon size ( ' + size + 'px ) detected in ' + filename + ' line ' + lineNumber + '\n'; | ||
} | ||
if( isNonStandard && validIconSizes.indexOf( +size ) >= 0 ) { | ||
result += '\033[33mStandard size gridicon ( ' + size + 'px ) marked as non-standard... are you sure that is ok? in ' + filename + ' line ' + lineNumber + '\n'; | ||
} | ||
} | ||
} | ||
lineNumber += chunk.split('\n').length - 1; | ||
} | ||
} ); | ||
} | ||
|
||
if ( result !== '' ) { | ||
console.error( result ); | ||
console.log( '\033[m=== Valid gridiconsizes are ' + validIconSizes.join( 'px, ' ) + 'px ===\n' ); | ||
process.exit( 1 ); | ||
} else { | ||
process.exit( 0 ); | ||
} | ||
} ); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ var React = require( 'react' ), | |
*/ | ||
var Masterbar = require( './masterbar' ), | ||
NoticesList = require( 'notices/notices-list' ), | ||
GlobalNotices = require( 'notices/global-notices' ), | ||
notices = require( 'notices' ); | ||
|
||
module.exports = React.createClass( { | ||
|
@@ -32,6 +33,7 @@ module.exports = React.createClass( { | |
<Masterbar /> | ||
<div id="content" className="wp-content"> | ||
<NoticesList id="notices" notices={ notices.list } /> | ||
<GlobalNotices id="notices" /> | ||
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. Can those two components be both rendered at the same time? If that happens, won’t the two HTML elements have the same 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. Good point! 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. |
||
<div id="primary" className="wp-primary wp-section" /> | ||
<div id="secondary" className="wp-secondary" /> | ||
</div> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ import React from 'react'; | |
* Internal dependencies | ||
*/ | ||
import observe from 'lib/mixins/data-observe'; | ||
import notices from 'notices'; | ||
import { success, error } from 'state/notices/actions'; | ||
import Main from 'components/main'; | ||
import ReauthRequired from 'me/reauth-required'; | ||
import twoStepAuthorization from 'lib/two-step-authorization'; | ||
|
@@ -16,8 +16,9 @@ import Navigation from './navigation'; | |
import BlogsSettings from './blogs-settings'; | ||
import store from 'lib/notification-settings-store'; | ||
import { fetchSettings, toggle, saveSettings } from 'lib/notification-settings-store/actions'; | ||
import { connect } from 'react-redux'; | ||
|
||
export default React.createClass( { | ||
const NotificationSettings = React.createClass( { | ||
displayName: 'NotificationSettings', | ||
|
||
mixins: [ observe( 'sites', 'devices' ) ], | ||
|
@@ -43,11 +44,11 @@ export default React.createClass( { | |
const state = store.getStateFor( 'blogs' ); | ||
|
||
if ( state.error ) { | ||
notices.error( this.translate( 'There was a problem saving your changes. Please, try again.' ) ); | ||
this.props.errorNotice( this.translate( 'There was a problem saving your changes. Please, try again.' ) ); | ||
} | ||
|
||
if ( state.status === 'success' ) { | ||
notices.success( this.translate( 'Settings saved successfully!' ) ); | ||
this.props.successNotice( this.translate( 'Settings saved successfully!' ) ); | ||
} | ||
|
||
this.setState( state ); | ||
|
@@ -74,3 +75,16 @@ export default React.createClass( { | |
} | ||
} ); | ||
|
||
export default connect( | ||
() => { | ||
return {} | ||
}, | ||
( dispatch ) => { return { | ||
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 the place I would like to have some helper, because implementing this action creators in every place that uses notices would be... verbose. |
||
successNotice: ( text, options ) => { | ||
dispatch( success( text, options ) ); | ||
}, | ||
errorNotice: ( text, options ) => { | ||
dispatch( error( text, options ) ); | ||
} | ||
} } | ||
)( NotificationSettings ); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,27 +18,30 @@ module.exports = React.createClass( { | |
path: React.PropTypes.string.isRequired | ||
}, | ||
|
||
getDefaultProps: function() { | ||
return { | ||
tabs: [ | ||
{ | ||
title: i18n.translate( 'Password', { textOnly: true } ), | ||
path: '/me/security', | ||
}, | ||
{ | ||
title: i18n.translate( 'Two-Step Authentication', { textOnly: true } ), | ||
path: '/me/security/two-step', | ||
}, | ||
{ | ||
title: i18n.translate( 'Connected Applications', { textOnly: true } ), | ||
path: '/me/security/connected-applications', | ||
}, | ||
config.isEnabled( 'me/security/checkup' ) ? { | ||
title: i18n.translate( 'Checkup', { textOnly: true } ), | ||
path: '/me/security/checkup', | ||
} : false | ||
] | ||
}; | ||
getNavtabs: function() { | ||
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. it seems you picked up some unrelated changes? |
||
var tabs = [ | ||
{ | ||
title: i18n.translate( 'Password', { textOnly: true } ), | ||
path: '/me/security', | ||
}, | ||
{ | ||
title: i18n.translate( 'Two-Step Authentication', { textOnly: true } ), | ||
path: '/me/security/two-step', | ||
}, | ||
{ | ||
title: i18n.translate( 'Connected Applications', { textOnly: true } ), | ||
path: '/me/security/connected-applications', | ||
} | ||
]; | ||
|
||
if ( config.isEnabled( 'me/security/checkup' ) ) { | ||
tabs.push( { | ||
title: i18n.translate( 'Checkup', { textOnly: true } ), | ||
path: '/me/security/checkup', | ||
} ); | ||
} | ||
|
||
return tabs; | ||
}, | ||
|
||
getFilteredPath: function() { | ||
|
@@ -48,7 +51,7 @@ module.exports = React.createClass( { | |
|
||
getSelectedText: function() { | ||
var text = '', | ||
found = find( this.props.tabs, function( tab ) { | ||
found = find( this.getNavtabs(), function( tab ) { | ||
return this.getFilteredPath() === tab.path; | ||
}, this ); | ||
|
||
|
@@ -67,7 +70,7 @@ module.exports = React.createClass( { | |
return ( | ||
<SectionNav selectedText={ this.getSelectedText() }> | ||
<NavTabs> | ||
{ this.props.tabs.map( function( tab ) { | ||
{ this.getNavtabs().map( function( tab ) { | ||
return ( | ||
<NavItem | ||
key={ tab.path } | ||
|
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 must have squashed it into non-existence in #338, but in some of my earlier attempts to introduce a top-level provider, I used it as an opportunity to reduce some of the repetition here:
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 will get around to that once we decide what to do with global store (do we want singleton?)
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.
Pushing right now :)
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.
Fixed!