cleaned up new slack bot creation

This commit is contained in:
hagen-danswer 2024-11-22 11:53:51 -08:00
parent 9819aa977a
commit c6dadb24dc
7 changed files with 61 additions and 10 deletions

View File

@ -0,0 +1,41 @@
"""remove default bot
Revision ID: 6d562f86c78b
Revises: 177de57c21c9
Create Date: 2024-11-22 11:51:29.331336
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "6d562f86c78b"
down_revision = "177de57c21c9"
branch_labels = None
depends_on = None
def upgrade() -> None:
op.execute(
sa.text(
"""
DELETE FROM slack_bot
WHERE name = 'Default Bot'
AND bot_token = ''
AND app_token = ''
"""
)
)
def downgrade() -> None:
op.execute(
sa.text(
"""
INSERT INTO slack_bot (name, enabled, bot_token, app_token)
SELECT 'Default Bot', true, '', ''
WHERE NOT EXISTS (SELECT 1 FROM slack_bot)
RETURNING id;
"""
)
)

View File

@ -75,7 +75,7 @@ export const ExistingSlackBotForm = ({
return (
<div>
{popup}
<div className="flex items-center justify-between">
<div className="flex items-center justify-between h-14">
<div className="flex items-center gap-2">
<div className="my-auto">
<SourceIcon iconSize={36} sourceType={"slack"} />
@ -108,6 +108,7 @@ export const ExistingSlackBotForm = ({
onClick={() => setShowDeleteModal(true)}
icon={FiTrash}
tooltip="Click to delete"
className="border h-[42px]"
>
Delete
</Button>
@ -129,8 +130,8 @@ export const ExistingSlackBotForm = ({
)}
</div>
</div>
<div className="mt-4">
<div className="inline-block border rounded-lg border-gray-200 px-2 py-2">
<div className="mt-2">
<div className="inline-block border rounded-lg border-gray-200 p-2">
<Checkbox
label="Enabled"
checked={formValues.enabled}

View File

@ -95,7 +95,12 @@ export const SlackTokensForm = ({
<div className="flex justify-end w-full mt-4">
<Button
type="submit"
disabled={isSubmitting}
disabled={
isSubmitting ||
!values.bot_token ||
!values.app_token ||
!values.name
}
variant="submit"
size="default"
>

View File

@ -369,7 +369,7 @@ export const SlackChannelConfigCreationForm = ({
<Button
type="submit"
variant="submit"
disabled={isSubmitting}
disabled={isSubmitting || !values.channel_name}
className="mx-auto w-64"
>
{isUpdate ? "Update!" : "Create!"}

View File

@ -95,7 +95,7 @@ function SlackBotEditPage({
text-sm
w-80
"
href={`/admin/bots/new?slack_bot_id=${unwrappedParams["bot-id"]}`}
href={`/admin/bots/${unwrappedParams["bot-id"]}/channels/new`}
>
<div className="mx-auto flex">
<FiPlusSquare className="my-auto mr-2" />

View File

@ -23,12 +23,12 @@ export function Checkbox({
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
}) {
return (
<label className="flex text-sm">
<label className="flex text-sm cursor-pointer">
<input
checked={checked}
onChange={onChange}
type="checkbox"
className="mx-3 px-5 w-3.5 h-3.5 my-auto"
className="mr-2 w-3.5 h-3.5 my-auto"
/>
<div>
<Label>{label}</Label>

View File

@ -81,13 +81,17 @@ export function EditableStringFieldDisplay({
value={editableValue}
onChange={handleValueChange}
onKeyDown={handleKeyDown}
className={cn(textClassName, isEditing ? "block" : "hidden")}
className={cn(
textClassName,
"user-text",
isEditing ? "block" : "hidden"
)}
style={{ fontSize: `${scale}rem` }}
/>
{!isEditing && (
<span
onClick={() => isEditable && setIsEditing(true)}
className={cn(textClassName, "cursor-pointer")}
className={cn(textClassName, "cursor-pointer user-text")}
style={{ fontSize: `${scale}rem` }}
>
{value}