Skip to content

Commit

Permalink
Merge pull request #483 from Automattic/update/sites-list-add-site-na…
Browse files Browse the repository at this point in the history
…mes-on-error-notices

Add site names on sites-list error notices
  • Loading branch information
johnHackworth committed Nov 25, 2015
2 parents 74f9dda + a1801bc commit 26dfa5e
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions client/lib/sites-list/notices.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,19 @@ module.exports = {
},

getMessage: function( logs, messageFunction ) {
var sampleLog, translateArg;
sampleLog = logs[ 0 ];
translateArg = {
count: logs.length,
args: {
siteName: sampleLog.site.title,
numberOfSites: logs.length
}
};
const sampleLog = logs[ 0 ],
sites = logs.map( function( log ) {
return log.site && log.site.title;
} ),
translateArg = {
count: logs.length,
args: {
siteName: sampleLog.site.title,
siteNames: sites.join( ', ' ),
numberOfSites: sites.length
}
};

return messageFunction( sampleLog.action, translateArg, sampleLog );
},

Expand Down Expand Up @@ -110,8 +114,8 @@ module.exports = {
return this.translate( 'Error fetching plugins on %(siteName)s.', translateArg );
}
return this.translate(
'Error fetching plugins on %(numberOfSites)d site.',
'Error fetching plugins on %(numberOfSites)d sites.',
'Error fetching plugins on %(numberOfSites)d site: %(siteNames)s.',
'Error fetching plugins on %(numberOfSites)d sites: %(siteNames)s.',
translateArg );

case 'DISCONNECT_SITE':
Expand All @@ -122,17 +126,17 @@ module.exports = {
return this.translate( 'You don\'t have permission to disconnect %(siteName)s.', translateArg );
}
return this.translate(
'You don\'t have permission to disconnect %(numberOfSites)d site.',
'You don\'t have permission to disconnect %(numberOfSites)d sites.',
'You don\'t have permission to disconnect %(numberOfSites)d site: %(siteNames)s.',
'You don\'t have permission to disconnect %(numberOfSites)d sites: %(siteNames)s.',
translateArg );

default:
if ( 1 === translateArg.args.numberOfSites ) {
return this.translate( 'Error disconnecting %(siteName)s.', translateArg );
}
return this.translate(
'Error disconnecting %(numberOfSites)d site.',
'Error disconnecting %(numberOfSites)d sites.',
'Error disconnecting %(numberOfSites)d site: %(siteNames)s.',
'Error disconnecting %(numberOfSites)d sites: %(siteNames)s.',
translateArg );
}

Expand Down

0 comments on commit 26dfa5e

Please sign in to comment.