0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-18 02:21:47 -05:00

Fixed content importer UI logic and email

- `result` parameter was wrongly passed to email
- email subject condition was reversed
- udpated email copy (still WIP)
- removed console.log from admin file selector
This commit is contained in:
Peter Zimon 2022-11-17 09:00:28 +01:00 committed by Sam Lord
parent 4fb05ab165
commit 4068d8c65c
3 changed files with 11 additions and 21 deletions

View file

@ -66,7 +66,6 @@ export default class ContentFileSelect extends Component {
}
_validateFileType(file) {
console.log(file);
let [, extension] = (/(?:\.([^.]+))?$/).exec(file.name);
if (extension.toLowerCase() !== 'json' && extension.toLowerCase() !== 'zip') {

View file

@ -124,32 +124,23 @@ module.exports = ({result, siteUrl, postsUrl, emailRecipient}) => `
</tr>
<tr>
<td style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; vertical-align: top;">
<p class="title" style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 21px; color: #3A464C; font-weight: normal; line-height: 25px; margin-bottom: 30px; margin-top: 50px; font-weight: 600; color: #15212A;">${result.errors ? 'Your content import was unsuccessful' : 'Your content import has finished'}</p>
<p class="title" style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 21px; color: #3A464C; font-weight: normal; line-height: 25px; margin-bottom: 30px; margin-top: 50px; font-weight: 600; color: #15212A;">${result.data.problems ? 'Import unsuccessful' : 'Your content import has finished'}</p>
</td>
</tr>
${result.errors ? `
${result.data.problems.length ? `
<tr>
<td style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 14px; vertical-align: top; padding-bottom: 16px;">
<p style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; color: #3A464C; font-weight: normal; margin: 0; line-height: 25px; margin-bottom: 0px;">Failed to import content with the following error${result.errors.length > 1 ? 's' : ''}:</p>
</td>
<td style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 14px; vertical-align: top; padding-bottom: 16px;">Your content could not be imported.</td>
</tr>
` : `
<tr>
<td style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 14px; vertical-align: top; padding-bottom: 16px;">
<ul style="padding-left: 2em;">
${_.map(result.errors, error => `
<li style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; color: #3A464C; font-weight: normal; margin: 0; line-height: 25px; margin-bottom: 4px;">${error.message}</li>
`).join('\n')}
</ul>
</td>
<td style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 14px; vertical-align: top; padding-bottom: 16px;">Your content was successfully imported.</td>
</tr>
` : ''}
${result.data && result.data.posts && result.data.posts.length > 0 ? `
`}
<tr>
<td style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 14px; vertical-align: top; padding-bottom: 12px; padding-top: 16px;">
<a href="${postsUrl.href}" target="_blank" style="display: inline-block; color: #ffffff; background-color: #15212A; border: solid 1px #15212A; border-radius: 5px; box-sizing: border-box; cursor: pointer; text-decoration: none; font-size: 16px; font-weight: normal; margin: 0; padding: 9px 22px 10px; border-color: #15212A;">View imported posts</a>
<a href="${postsUrl.href}" target="_blank" style="display: inline-block; color: #ffffff; background-color: #15212A; border: solid 1px #15212A; border-radius: 5px; box-sizing: border-box; cursor: pointer; text-decoration: none; font-size: 16px; font-weight: normal; margin: 0; padding: 9px 22px 10px; border-color: #15212A;">View posts</a>
</td>
</tr>
` : ''}
</table>
</td>
</tr>

View file

@ -445,15 +445,15 @@ class ImportManager {
if (!env?.startsWith('testing')) {
// Step 6: Send email
const email = this.generateCompletionEmail(importResult?.data, {
const email = this.generateCompletionEmail(importResult, {
emailRecipient: importOptions.user.email,
importTag: importOptions.importTag
});
await ghostMailer.send({
to: importOptions.user.email,
subject: importResult.errors
? 'Your content import has finished'
: 'Your content import was unsuccessful',
subject: importResult.data.problems.length
? 'Your content import was unsuccessful'
: 'Your content import has finished',
html: email
});
}