diff --git a/client/lib/importer/constants.js b/client/lib/importer/constants.js index 0756e668587546..9e0906d556a165 100644 --- a/client/lib/importer/constants.js +++ b/client/lib/importer/constants.js @@ -13,12 +13,10 @@ export const appStates = Object.freeze( { UPLOADING: 'importer-uploading' } ); -export const importerTypes = Object.freeze( { - WORDPRESS: 'importer-type-wordpress', - GHOST: 'importer-type-ghost', - MEDIUM: 'importer-type-medium', - SQUARESPACE: 'importer-type-squarespace' -} ); +export const WORDPRESS = 'importer-type-wordpress'; +export const GHOST = 'importer-type-ghost'; +export const MEDIUM = 'importer-type-medium'; +export const SQUARESPACE = 'importer-type-squarespace'; export const actionTypes = Object.freeze( { API_REQUEST: 'importer-api-request', diff --git a/client/my-sites/site-settings/section-import.jsx b/client/my-sites/site-settings/section-import.jsx index 944412ccf53d1c..4c498fe1f01238 100644 --- a/client/my-sites/site-settings/section-import.jsx +++ b/client/my-sites/site-settings/section-import.jsx @@ -16,7 +16,10 @@ import MediumImporter from 'my-sites/importer/importer-medium'; import SquarespaceImporter from 'my-sites/importer/importer-squarespace'; import WordPressImporter from 'my-sites/importer/importer-wordpress'; import { fetchState } from 'lib/importer/actions'; -import { appStates, importerTypes } from 'lib/importer/constants'; +import { + appStates, + WORDPRESS, GHOST, MEDIUM, SQUARESPACE +} from 'lib/importer/constants'; export default React.createClass( { displayName: 'SiteSettingsImport', @@ -36,30 +39,10 @@ export default React.createClass( { ImporterStore.off( 'change', this.updateState ); }, - getDescription: function() { - return this.translate( - 'Import another site\'s content into ' + - '{{strong}}%(title)s{{/strong}}. Once you start an ' + - 'import, come back here to check on the progress. ' + - 'Check out our {{a}}import guide{{/a}} ' + - 'if you need more help.', { - args: { title: this.getSiteTitle() }, - components: { - a: , - strong: - } - } - ); - }, - getInitialState: function() { return getImporterState(); }, - getSiteTitle: function() { - return this.props.site.title.length ? this.props.site.title : this.props.site.slug; - }, - /** * Finds the import status objects for a * particular type of importer @@ -67,57 +50,28 @@ export default React.createClass( { * @param {enum} type ImportConstants.IMPORT_TYPE_* * @returns {Array} ImportStatus objects */ - getStatusFor: function( type ) { + getImports: function( type ) { const { api: { isHydrated }, importers } = this.state; const { site } = this.props; - var disabledTypes, status; + const { slug, title } = site; + const siteTitle = title.length ? title : slug; - disabledTypes = [ - importerTypes.GHOST, - importerTypes.MEDIUM, - importerTypes.SQUARESPACE - ]; + const disabledTypes = [ GHOST, MEDIUM, SQUARESPACE ]; if ( ! isHydrated || includes( disabledTypes, type ) ) { - return [ { importerState: appStates.DISABLED, type } ]; + return [ { importerState: appStates.DISABLED, type, siteTitle } ]; } - status = Object.keys( importers ) + const status = Object.keys( importers ) .map( id => importers[ id ] ) .filter( importer => site.ID === importer.site.ID ) .filter( importer => type === importer.type ); if ( 0 === status.length ) { - return [ { importerState: appStates.INACTIVE, type } ]; + return [ { importerState: appStates.INACTIVE, type, siteTitle } ]; } - return status.map( item => Object.assign( {}, item, { site } ) ); - }, - - renderImporters: function() { - var siteTitle = this.getSiteTitle(); - - return Object.keys( importerTypes ).map( type => ( - this.getStatusFor( importerTypes[ type ] ).map( ( status, index ) => { - const key = `import-list-${type}-${index}`; - - status.siteTitle = siteTitle; - - switch ( importerTypes[ type ] ) { - case importerTypes.GHOST: - return ; - - case importerTypes.MEDIUM: - return ; - - case importerTypes.SQUARESPACE: - return ; - - case importerTypes.WORDPRESS: - return ; - } - } ) - ) ); + return status.map( item => Object.assign( {}, item, { site, siteTitle } ) ); }, updateFromAPI: function() { @@ -129,14 +83,31 @@ export default React.createClass( { }, render: function() { - if ( this.props.site.jetpack ) { + const { site } = this.props; + const { jetpack: isJetpack, options: { admin_url: adminUrl }, slug, title: siteTitle } = site; + const title = siteTitle.length ? siteTitle : slug; + const description = this.translate( + 'Import another site\'s content into ' + + '{{strong}}%(title)s{{/strong}}. Once you start an ' + + 'import, come back here to check on the progress. ' + + 'Check out our {{a}}import guide{{/a}} ' + + 'if you need more help.', { + args: { title }, + components: { + a: , + strong: + } + } + ); + + if ( isJetpack ) { return ( ); @@ -148,10 +119,22 @@ export default React.createClass( { { this.translate( 'Import Another Site' ) } - { this.getDescription() } + { description } - { this.renderImporters() } + + { this.getImports( WORDPRESS ).map( ( importerStatus, key ) => + ) } + + { this.getImports( GHOST ).map( ( importerStatus, key ) => + ) } + + { this.getImports( MEDIUM ).map( ( importerStatus, key ) => + ) } + + { this.getImports( SQUARESPACE ).map( ( importerStatus, key ) => + ) } + ); } diff --git a/server/devdocs/Makefile b/server/devdocs/Makefile deleted file mode 100644 index 144f51e580df65..00000000000000 --- a/server/devdocs/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -NODE_BIN := $(shell npm bin) -MOCHA ?= $(NODE_BIN)/mocha -BASE_DIR := $(NODE_BIN)/../.. -NODE_PATH := test:$(BASE_DIR)/client -COMPILERS ?= js:babel/register -REPORTER ?= spec -UI ?= bdd - -test: - @NODE_ENV=test NODE_PATH=$(NODE_PATH) $(MOCHA) --compilers $(COMPILERS) --reporter $(REPORTER) --ui $(UI) - -.PHONY: test
{ this.getDescription() }
{ description }