-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1ff7935
commit 2424796
Showing
12 changed files
with
390 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
apps/dashboard-app/app/(dashboard)/automations/_components/Template.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
'use client' | ||
|
||
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from '@repo/ui/molecules/shadcn/Card' | ||
import { ArrowRightIcon, CopyIcon } from 'lucide-react' | ||
import DynamicIcon from '../../../../components/DynamicIcon' | ||
import { useRouter } from 'next/navigation' | ||
import { useSession } from 'next-auth/react' | ||
import { useToast } from '../../../../hooks/useToast' | ||
import { duplicateWorkflow, editFlow, makeFlowPublic } from '../../../actions/workflows/workflow' | ||
import { Label } from '@repo/ui/atoms/shadcn/Label' | ||
import { Switch } from '@repo/ui/molecules/shadcn/Switch' | ||
import { useState } from 'react' | ||
import { Input } from '@repo/ui/atoms/shadcn/Input' | ||
import { Textarea } from '@repo/ui/atoms/shadcn/Textarea' | ||
|
||
|
||
const Template = ({workflow}:any) => { | ||
const router = useRouter(); | ||
const session = useSession(); | ||
const userId = session.data?.user?.id; | ||
const [toggle,setToggle] = useState(workflow.shared || false) | ||
const [name, setName] = useState(workflow.name); | ||
const [description, setDescription] = useState(workflow.description); | ||
const [showNameEdit,setShowNameEdit] = useState(false); | ||
const [showDescriptionEdit,setShowDescriptionEdit] = useState(false); | ||
|
||
const onToggle = async () =>{ | ||
setToggle(!toggle) | ||
await makeFlowPublic(workflow.id,!toggle) | ||
} | ||
|
||
const handleEditName = async () =>{ | ||
if (showNameEdit) { | ||
setName(name) | ||
await editFlow(workflow.id,name,description); | ||
} | ||
setShowNameEdit(!showNameEdit); | ||
// router.refresh(); | ||
} | ||
|
||
const handleEditDescription = async () =>{ | ||
if (showDescriptionEdit){ | ||
setDescription(description) | ||
await editFlow(workflow.id,name,description); | ||
} | ||
setShowDescriptionEdit(!showDescriptionEdit); | ||
} | ||
|
||
return ( | ||
<Card className=''> | ||
<CardHeader className=''> | ||
<CardTitle className='flex items-center justify-between leading-3 '> | ||
<div className='flex items-center gap-2 w-full justify-between leading-normal'> | ||
{showNameEdit ? ( | ||
<Input | ||
className='w-[80%] break-words whitespace-normal bg-background dark:bg-background dark:text-foreground' | ||
placeholder={name} | ||
onChange={(e: any) => setName(e.target.value)} | ||
onBlur={handleEditName} // Exit edit mode when clicking outside the input | ||
autoFocus // Automatically focus the input when entering edit mode | ||
/> | ||
) : ( | ||
// Add onDoubleClick to enable editing on double click | ||
<div className='w-[80%] break-words whitespace-normal text-wrap text-button' onDoubleClick={handleEditName}> | ||
{name} | ||
</div> | ||
)} | ||
</div> | ||
<div className='flex items-center gap-2 text-right '> | ||
<Label htmlFor='airplane-mode'> | ||
{toggle? 'Private': 'Public'} | ||
</Label> | ||
<Switch id='airplane-mode' onClick={onToggle} defaultChecked={toggle} /> | ||
</div> | ||
|
||
</CardTitle> | ||
<CardDescription className='text-description text-xs leading-snug '> | ||
<div className='flex items-start justify-start gap-2 text-sm text-description w-full '> | ||
{showDescriptionEdit ? ( | ||
<Textarea | ||
placeholder={description} | ||
onChange={(e: any) => setDescription(e.target.value)} | ||
onBlur={handleEditDescription} // Exit edit mode when clicking outside the input | ||
autoFocus // Automatically focus the input when entering edit mode | ||
className='w-full mt-2' | ||
/> | ||
) : ( | ||
// Add onDoubleClick to enable editing on double click | ||
<div className='text-description' onDoubleClick={handleEditDescription}> | ||
{description || 'Add Description Here'} | ||
</div> | ||
)} | ||
</div> | ||
</CardDescription> | ||
|
||
</CardHeader> | ||
<CardContent className=''> | ||
<CardDescription> | ||
|
||
<div className='flex items-center justify-start gap-2 flex-wrap mt-2'> | ||
{workflow.trigger && <> | ||
<DynamicIcon icon={workflow.trigger.type.triggerType.icon}/> | ||
<ArrowRightIcon className='w-2 h-2'/> | ||
</> | ||
} | ||
{workflow.actions.map((action:any) => ( | ||
<><DynamicIcon key={action.id} icon={action.type.actionType.icon}/> | ||
</> | ||
))} | ||
</div> | ||
</CardDescription> | ||
</CardContent> | ||
</Card> | ||
) | ||
} | ||
|
||
export default Template |
32 changes: 32 additions & 0 deletions
32
apps/dashboard-app/app/(dashboard)/automations/_components/Templates.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
"use client" | ||
/* eslint-disable */ | ||
|
||
import React, { useEffect, useState } from 'react' | ||
import { getTemplatesAction } from '../../../actions/workflows/workflow' | ||
import PublicWorkflow from './PublicWorkflow' | ||
import { useSession } from 'next-auth/react' | ||
import Template from './Template' | ||
|
||
const Templates = () => { | ||
const [workflows,setWorkflows] = useState<any>([]) | ||
const session = useSession(); | ||
const userId = session.data?.user?.id; | ||
|
||
useEffect(()=>{ | ||
async function fetchWorkflows(){ | ||
const flows = await getTemplatesAction(userId || ''); | ||
setWorkflows(flows); | ||
} | ||
fetchWorkflows() | ||
},[userId]) | ||
|
||
return ( | ||
<div className='grid grid-cols-1 lg:grid-cols-2 2xl:grid-cols-3 w-full py-10 overflow-y-auto gap-4'> | ||
{workflows?.map((workflow:any) => ( | ||
<Template key={workflow.id} workflow={workflow}/> | ||
))} | ||
</div> | ||
) | ||
} | ||
|
||
export default Templates |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
.../automations/editor/[editorId]/_components/action-forms/code/PythonCodeBlockVariables.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { Input } from '@repo/ui/atoms/shadcn/Input'; | ||
import ConfirmDialog from '@repo/ui/molecules/custom/ConfirmDialog' | ||
import { set } from 'date-fns'; | ||
import { Trash2Icon } from 'lucide-react' | ||
import React, { useState } from 'react' | ||
|
||
const PythonCodeBlockVariables = ({variable,removeVariable,block,index,modifyVariable}:any) => { | ||
const [key, setKey] = useState(variable.key); | ||
const [value, setValue] = useState(variable.value); | ||
const [showKeyEdit, setShowKeyEdit] = useState(false); | ||
const [showValueEdit, setShowValueEdit] = useState(false); | ||
|
||
const modifyKey = async () =>{ | ||
if (showKeyEdit){ | ||
setKey(key) | ||
await modifyVariable(block.id,index,key,value) | ||
} | ||
setShowKeyEdit(!showKeyEdit) | ||
} | ||
|
||
const modifyValue = async () =>{ | ||
if (showValueEdit){ | ||
setValue(value) | ||
await modifyVariable(block.id,index,key,value) | ||
} | ||
setShowValueEdit(!showValueEdit) | ||
} | ||
|
||
return ( | ||
<div className='flex gap-2 items-center'> | ||
{showKeyEdit ? ( | ||
<Input | ||
className='w-[30%] break-words whitespace-normal bg-background dark:bg-background dark:text-foreground' | ||
placeholder={key} | ||
onChange={(e: any) => setKey(e.target.value)} | ||
onBlur={modifyKey} // Exit edit mode when clicking outside the input | ||
autoFocus // Automatically focus the input when entering edit mode | ||
/>):( | ||
<div onDoubleClick={modifyKey} className='w-[30%] border-[1px] rounded-md p-2 break-words whitespace-normal text-wrap text-paragraph'> | ||
{key} | ||
</div> | ||
)} | ||
{showValueEdit ? ( | ||
<Input | ||
className='w-[30%] break-words whitespace-normal bg-background dark:bg-background dark:text-foreground' | ||
placeholder={value} | ||
onChange={(e: any) => setValue(e.target.value)} | ||
onBlur={modifyValue} // Exit edit mode when clicking outside the input | ||
autoFocus // Automatically focus the input when entering edit mode | ||
/>):( | ||
<div onDoubleClick={modifyValue} className='w-[30%] border-[1px] rounded-md p-2 break-words whitespace-normal text-wrap text-paragraph'> | ||
{value} | ||
</div> | ||
)} | ||
|
||
<ConfirmDialog | ||
alertActionFunction={() => removeVariable(block.id, index)} | ||
alertTitle='Delete Property' | ||
alertDescription='Are you sure you want to delete this property?' | ||
buttonDiv={<Trash2Icon className='w-5 h-5 cursor-pointer col-span-1 text-foreground/50' />} | ||
alertActionText='Delete' | ||
/> | ||
</div> | ||
) | ||
} | ||
|
||
export default PythonCodeBlockVariables |
Oops, something went wrong.