improve app tab selection

This commit is contained in:
Ruben Fiszel
2024-01-22 23:27:00 +01:00
parent d95ca968fa
commit 3787c886e5
7 changed files with 23 additions and 23 deletions

View File

@@ -56,7 +56,8 @@ pub async fn test_email(
require_super_admin(&db, &authed.email).await?;
let smtp = test_email.smtp;
let to = test_email.to;
let client = SmtpClientBuilder::new(smtp.host, smtp.port).implicit_tls(smtp.tls_implicit);
let client = SmtpClientBuilder::new(smtp.host, smtp.port)
.implicit_tls(smtp.tls_implicit.unwrap_or(false));
let client = if let (Some(username), Some(password)) = (smtp.username, smtp.password) {
if !username.is_empty() {
client.credentials((username, password))

View File

@@ -1666,7 +1666,8 @@ pub fn send_email_if_possible(subject: &str, content: &str, to: &str) {
pub async fn send_email_if_possible_intern(subject: &str, content: &str, to: &str) -> Result<()> {
if let Some(smtp) = SERVER_CONFIG.read().await.smtp.clone() {
let client = SmtpClientBuilder::new(smtp.host, smtp.port).implicit_tls(smtp.tls_implicit);
let client = SmtpClientBuilder::new(smtp.host, smtp.port)
.implicit_tls(smtp.tls_implicit.unwrap_or(false));
let client = if let (Some(username), Some(password)) = (smtp.username, smtp.password) {
if !username.is_empty() {
client.credentials((username, password))

View File

@@ -9,7 +9,7 @@ pub struct Smtp {
pub password: Option<String>,
pub port: u16,
pub from: String,
pub tls_implicit: bool,
pub tls_implicit: Option<bool>,
}
#[derive(Serialize, Deserialize, PartialEq)]
@@ -40,7 +40,7 @@ pub async fn load_server_config(db: &DB) -> error::Result<ServerConfig> {
host,
username,
password,
tls_implicit: config.smtp_tls_implicit.unwrap_or(false),
tls_implicit: config.smtp_tls_implicit,
port: config.smtp_port.unwrap_or(587),
from: config
.smtp_from
@@ -61,8 +61,7 @@ pub async fn load_server_config(db: &DB) -> error::Result<ServerConfig> {
password,
tls_implicit: std::env::var("SMTP_TLS_IMPLICIT")
.ok()
.and_then(|p| p.parse().ok())
.unwrap_or(false),
.and_then(|p| p.parse().ok()),
port: std::env::var("SMTP_PORT")
.ok()
.and_then(|p| p.parse().ok())

View File

@@ -1,7 +1,5 @@
<script lang="ts">
import { GroupService, UserService, type InstanceGroup } from '$lib/gen'
import { workspaceStore } from '$lib/stores'
import AutoComplete from 'simple-svelte-autocomplete'
import { GroupService, type InstanceGroup } from '$lib/gen'
import { createEventDispatcher } from 'svelte'
import autosize from 'svelte-autosize'
import { Button } from './common'
@@ -11,23 +9,18 @@
export let name: string
let email = ''
let instance_group: InstanceGroup | undefined
let members: { member_email: string }[] | undefined = undefined
let usernames: string[] | undefined = []
let username: string = ''
const dispatch = createEventDispatcher()
async function loadUsernames(): Promise<void> {
usernames = await UserService.listUsernames({ workspace: $workspaceStore! })
}
$: {
load()
}
async function load() {
return Promise.all([loadInstanceGroup(), loadUsernames()])
return Promise.all([loadInstanceGroup()])
}
async function loadInstanceGroup(): Promise<void> {
@@ -67,7 +60,7 @@
</div>
<h2>Members ({members?.length ?? 0})</h2>
<div class="flex items-start">
<AutoComplete noInputStyles items={usernames} bind:selectedItem={username} />
<input type="text" placeholder="john@acme.com" bind:value={email} />
<Button
variant="contained"
color="blue"
@@ -76,7 +69,7 @@
on:click={async () => {
await GroupService.addUserToInstanceGroup({
name,
requestBody: { email: username }
requestBody: { email: email }
})
dispatch('update')
sendUserToast('User added')

View File

@@ -20,10 +20,11 @@
const outputs = initOutput($worldStore, id, {
conditions: [] as boolean[],
selectedConditionIndex: 0
selectedTabIndex: 0
})
function onFocus() {
console.log('onFocus', id, selectedConditionIndex)
$focusedGrid = {
parentComponentId: id,
subGridIndex: selectedConditionIndex
@@ -51,7 +52,7 @@
}
selectedConditionIndex = index
outputs.selectedConditionIndex.set(index)
outputs.selectedTabIndex.set(index)
}
$: resolvedConditions && handleResolvedConditions()
@@ -93,7 +94,7 @@
style={css?.container?.style}
subGridId={`${id}-${i}`}
containerHeight={componentContainerHeight}
on:focus={() => {
on:focus={(e) => {
if (!$connectingInput.opened) {
$selectedComponent = [id]
}

View File

@@ -223,9 +223,14 @@
parentComponentId: befSelected,
subGridIndex: 0
}
} else if (item?.data.type === 'steppercomponent') {
$focusedGrid = {
parentComponentId: befSelected,
subGridIndex:
($worldStore.outputsById?.[befSelected]?.currentStepIndex?.peak() as number) ?? 0
}
} else if (
item?.data.type === 'tabscomponent' ||
item?.data.type === 'steppercomponent' ||
item?.data.type === 'conditionalwrapper'
) {
$focusedGrid = {

View File

@@ -124,7 +124,7 @@ export function moveItem(active, items, cols) {
// console.log(JSON.stringify(item), JSON.stringify(active), JSON.stringify(cols), 3, cols)
// Create matrix from the items expect the active
let matrix = makeMatrixFromItemsIgnore(items, [item.id], getRowsCount(items, cols), cols)
let matrix = makeMatrixFromItemsIgnore(items, [active.id], getRowsCount(items, cols), cols)
// Getting the ids of items under active Array<String>
const closeBlocks = findCloseBlocks(matrix, item)
// Getting the objects of items under active Array<Object>