Formatting.

This commit is contained in:
mike12345567 2021-05-11 15:24:17 +01:00
parent 8e1f18e456
commit c70d4444a9
9 changed files with 56 additions and 33 deletions

View File

@ -1,5 +1,12 @@
<script>
import { Body, Menu, MenuItem, Detail, MenuSection, DetailSummary } from "@budibase/bbui"
import {
Body,
Menu,
MenuItem,
Detail,
MenuSection,
DetailSummary,
} from "@budibase/bbui"
export let bindings
export let onBindingClick = () => {}
@ -8,8 +15,8 @@
<Menu>
{#each bindings as binding}
<MenuItem on:click={() => onBindingClick(binding)}>
<Detail size="M">{binding.name}</Detail>
<Body size="XS" noPadding>{binding.description}</Body>
<Detail size="M">{binding.name}</Detail>
<Body size="XS" noPadding>{binding.description}</Body>
</MenuItem>
{/each}
</Menu>

View File

@ -1,8 +1,6 @@
<script>
import { url } from "@roxi/routify"
import {
Link,
} from "@budibase/bbui"
import { Link } from "@budibase/bbui"
import { roles } from "stores/backend"
export let value

View File

@ -83,25 +83,26 @@
value={selectedTemplate.contents}
/>
<div class="bindings-editor">
<Detail size="L">Bindings</Detail>
<Tabs selected={selectedBindingTab}>
<Tab title="Template">
<TemplateBindings
title="Template Bindings"
bindings={templateBindings}
onBindingClick={setTemplateBinding}
/>
</Tab>
<Tab title="Common">
<TemplateBindings
title="Common Bindings"
bindings={$email.definitions.bindings.common}
onBindingClick={setTemplateBinding}
/>
</Tab>
</Tabs>
<Detail size="L">Bindings</Detail>
<Tabs selected={selectedBindingTab}>
<Tab title="Template">
<TemplateBindings
title="Template Bindings"
bindings={templateBindings}
onBindingClick={setTemplateBinding}
/>
</Tab>
<Tab title="Common">
<TemplateBindings
title="Common Bindings"
bindings={$email.definitions.bindings.common}
onBindingClick={setTemplateBinding}
/>
</Tab>
</Tabs>
</div>
</Tab>
</div></Tab
>
<Tab title="Preview">
<div class="preview" transition:fade>
{@html selectedTemplate.contents}
@ -136,5 +137,4 @@
margin-bottom: var(--spacing-xl);
cursor: pointer;
}
</style>

View File

@ -34,7 +34,7 @@
const templateSchema = {
purpose: {
displayName: "Email",
editable: false
editable: false,
},
}

View File

@ -53,9 +53,11 @@ exports.reset = async ctx => {
)
}
try {
const user = await getGlobalUserByEmail(email)
await sendEmail(email, EmailTemplatePurpose.PASSWORD_RECOVERY, { user, subject: "{{ company }} platform password reset" })
await sendEmail(email, EmailTemplatePurpose.PASSWORD_RECOVERY, {
user,
subject: "{{ company }} platform password reset",
})
} catch (err) {
// don't throw any kind of error to the user, this might give away something
}

View File

@ -5,13 +5,27 @@ const authPkg = require("@budibase/auth")
const GLOBAL_DB = authPkg.StaticDatabases.GLOBAL.name
exports.sendEmail = async ctx => {
const { groupId, email, userId, purpose, contents, from, subject } = ctx.request.body
const {
groupId,
email,
userId,
purpose,
contents,
from,
subject,
} = ctx.request.body
let user
if (userId) {
const db = new CouchDB(GLOBAL_DB)
user = await db.get(userId)
}
const response = await sendEmail(email, purpose, { groupId, user, contents, from, subject })
const response = await sendEmail(email, purpose, {
groupId,
user,
contents,
from,
subject,
})
ctx.body = {
...response,
message: `Email sent to ${email}.`,

View File

@ -136,7 +136,9 @@ exports.invite = async ctx => {
if (existing) {
ctx.throw(400, "Email address already in use.")
}
await sendEmail(email, EmailTemplatePurpose.INVITATION, { subject: "{{ company }} platform invitation" })
await sendEmail(email, EmailTemplatePurpose.INVITATION, {
subject: "{{ company }} platform invitation",
})
ctx.body = {
message: "Invitation has been sent.",
}

View File

@ -141,7 +141,7 @@ exports.sendEmail = async (
{ groupId, user, from, contents, subject } = {}
) => {
const db = new CouchDB(GLOBAL_DB)
let config = await getSmtpConfiguration(db, groupId) || {}
let config = (await getSmtpConfiguration(db, groupId)) || {}
if (Object.keys(config).length === 0 && !TEST_MODE) {
throw "Unable to find SMTP configuration."
}

View File

@ -15,7 +15,7 @@ const BASE_COMPANY = "Budibase"
exports.getSettingsTemplateContext = async (purpose, code = null) => {
const db = new CouchDB(StaticDatabases.GLOBAL.name)
// TODO: use more granular settings in the future if required
let settings = await getScopedConfig(db, { type: Configs.SETTINGS }) || {}
let settings = (await getScopedConfig(db, { type: Configs.SETTINGS })) || {}
if (!settings || !settings.platformUrl) {
settings.platformUrl = LOCAL_URL
}