Skip to content

Commit 3c0da76

Browse files
committed
improvement: modals
1 parent a4ac715 commit 3c0da76

File tree

63 files changed

+568
-122
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+568
-122
lines changed

apps/sim/app/api/workspaces/[id]/route.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ import { getUserEntityPermissions } from '@/lib/workspaces/permissions/utils'
1414

1515
const patchWorkspaceSchema = z.object({
1616
name: z.string().trim().min(1).optional(),
17+
color: z
18+
.string()
19+
.regex(/^#[0-9a-fA-F]{6}$/)
20+
.optional(),
1721
billedAccountUserId: z.string().optional(),
1822
allowPersonalApiKeys: z.boolean().optional(),
1923
})
@@ -113,10 +117,11 @@ export async function PATCH(request: NextRequest, { params }: { params: Promise<
113117

114118
try {
115119
const body = patchWorkspaceSchema.parse(await request.json())
116-
const { name, billedAccountUserId, allowPersonalApiKeys } = body
120+
const { name, color, billedAccountUserId, allowPersonalApiKeys } = body
117121

118122
if (
119123
name === undefined &&
124+
color === undefined &&
120125
billedAccountUserId === undefined &&
121126
allowPersonalApiKeys === undefined
122127
) {
@@ -139,6 +144,10 @@ export async function PATCH(request: NextRequest, { params }: { params: Promise<
139144
updateData.name = name
140145
}
141146

147+
if (color !== undefined) {
148+
updateData.color = color
149+
}
150+
142151
if (allowPersonalApiKeys !== undefined) {
143152
updateData.allowPersonalApiKeys = Boolean(allowPersonalApiKeys)
144153
}

apps/sim/app/api/workspaces/route.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,16 @@ import { getSession } from '@/lib/auth'
99
import { PlatformEvents } from '@/lib/core/telemetry'
1010
import { buildDefaultWorkflowArtifacts } from '@/lib/workflows/defaults'
1111
import { saveWorkflowToNormalizedTables } from '@/lib/workflows/persistence/utils'
12+
import { getRandomWorkspaceColor } from '@/lib/workspaces/colors'
1213

1314
const logger = createLogger('Workspaces')
1415

1516
const createWorkspaceSchema = z.object({
1617
name: z.string().trim().min(1, 'Name is required'),
18+
color: z
19+
.string()
20+
.regex(/^#[0-9a-fA-F]{6}$/)
21+
.optional(),
1722
skipDefaultWorkflow: z.boolean().optional().default(false),
1823
})
1924

@@ -65,9 +70,9 @@ export async function POST(req: Request) {
6570
}
6671

6772
try {
68-
const { name, skipDefaultWorkflow } = createWorkspaceSchema.parse(await req.json())
73+
const { name, color, skipDefaultWorkflow } = createWorkspaceSchema.parse(await req.json())
6974

70-
const newWorkspace = await createWorkspace(session.user.id, name, skipDefaultWorkflow)
75+
const newWorkspace = await createWorkspace(session.user.id, name, skipDefaultWorkflow, color)
7176

7277
recordAudit({
7378
workspaceId: newWorkspace.id,
@@ -96,16 +101,23 @@ async function createDefaultWorkspace(userId: string, userName?: string | null)
96101
return createWorkspace(userId, workspaceName)
97102
}
98103

99-
async function createWorkspace(userId: string, name: string, skipDefaultWorkflow = false) {
104+
async function createWorkspace(
105+
userId: string,
106+
name: string,
107+
skipDefaultWorkflow = false,
108+
explicitColor?: string
109+
) {
100110
const workspaceId = crypto.randomUUID()
101111
const workflowId = crypto.randomUUID()
102112
const now = new Date()
113+
const color = explicitColor || getRandomWorkspaceColor()
103114

104115
try {
105116
await db.transaction(async (tx) => {
106117
await tx.insert(workspace).values({
107118
id: workspaceId,
108119
name,
120+
color,
109121
ownerId: userId,
110122
billedAccountUserId: userId,
111123
allowPersonalApiKeys: true,
@@ -174,6 +186,7 @@ async function createWorkspace(userId: string, name: string, skipDefaultWorkflow
174186
return {
175187
id: workspaceId,
176188
name,
189+
color,
177190
ownerId: userId,
178191
billedAccountUserId: userId,
179192
allowPersonalApiKeys: true,

apps/sim/app/workspace/[workspaceId]/files/files.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ export function Files() {
596596
<ModalContent size='sm'>
597597
<ModalHeader>Unsaved Changes</ModalHeader>
598598
<ModalBody>
599-
<p className='text-[13px] text-[var(--text-secondary)]'>
599+
<p className='text-[var(--text-secondary)]'>
600600
You have unsaved changes. Are you sure you want to discard them?
601601
</p>
602602
</ModalBody>
@@ -731,7 +731,7 @@ function DeleteConfirmModal({
731731
<ModalContent size='sm'>
732732
<ModalHeader>Delete File</ModalHeader>
733733
<ModalBody>
734-
<p className='text-[13px] text-[var(--text-secondary)]'>
734+
<p className='text-[var(--text-secondary)]'>
735735
Are you sure you want to delete{' '}
736736
<span className='font-medium text-[var(--text-primary)]'>{fileName}</span>?{' '}
737737
<span className='text-[var(--text-error)]'>This action cannot be undone.</span>

apps/sim/app/workspace/[workspaceId]/knowledge/[id]/[documentId]/components/delete-chunk-modal/delete-chunk-modal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export function DeleteChunkModal({
3434
<ModalContent size='sm'>
3535
<ModalHeader>Delete Chunk</ModalHeader>
3636
<ModalBody>
37-
<p className='text-[12px] text-[var(--text-secondary)]'>
37+
<p className='text-[var(--text-secondary)]'>
3838
Are you sure you want to delete this chunk?{' '}
3939
<span className='text-[var(--text-error)]'>This action cannot be undone.</span>
4040
</p>

apps/sim/app/workspace/[workspaceId]/knowledge/[id]/[documentId]/document.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ function UnsavedChangesModal({
7272
<ModalContent size='sm'>
7373
<ModalHeader>Unsaved Changes</ModalHeader>
7474
<ModalBody>
75-
<p className='text-[12px] text-[var(--text-secondary)]'>
75+
<p className='text-[var(--text-secondary)]'>
7676
You have unsaved changes. Are you sure you want to discard them?
7777
</p>
7878
</ModalBody>
@@ -1168,7 +1168,7 @@ export function Document({
11681168
<ModalContent size='sm'>
11691169
<ModalHeader>Delete Document</ModalHeader>
11701170
<ModalBody>
1171-
<p className='text-[12px] text-[var(--text-secondary)]'>
1171+
<p className='text-[var(--text-secondary)]'>
11721172
Are you sure you want to delete{' '}
11731173
<span className='font-medium text-[var(--text-primary)]'>
11741174
{effectiveDocumentName}

apps/sim/app/workspace/[workspaceId]/knowledge/[id]/base.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,7 @@ export function KnowledgeBase({
11211121
<ModalContent size='sm'>
11221122
<ModalHeader>Delete Knowledge Base</ModalHeader>
11231123
<ModalBody>
1124-
<p className='text-[12px] text-[var(--text-secondary)]'>
1124+
<p className='text-[var(--text-secondary)]'>
11251125
Are you sure you want to delete{' '}
11261126
<span className='font-medium text-[var(--text-primary)]'>{knowledgeBaseName}</span>?
11271127
This will permanently delete the knowledge base and all {pagination.total} document
@@ -1151,7 +1151,7 @@ export function KnowledgeBase({
11511151
{(() => {
11521152
const docToDelete = documents.find((doc) => doc.id === documentToDelete)
11531153
return (
1154-
<p className='text-[12px] text-[var(--text-secondary)]'>
1154+
<p className='text-[var(--text-secondary)]'>
11551155
Are you sure you want to delete{' '}
11561156
<span className='font-medium text-[var(--text-primary)]'>
11571157
{docToDelete?.filename ?? 'this document'}
@@ -1190,7 +1190,7 @@ export function KnowledgeBase({
11901190
<ModalContent size='sm'>
11911191
<ModalHeader>Delete Documents</ModalHeader>
11921192
<ModalBody>
1193-
<p className='text-[12px] text-[var(--text-secondary)]'>
1193+
<p className='text-[var(--text-secondary)]'>
11941194
Are you sure you want to delete {selectedDocuments.size} document
11951195
{selectedDocuments.size === 1 ? '' : 's'}?{' '}
11961196
<span className='text-[var(--text-error)]'>This action cannot be undone.</span>

apps/sim/app/workspace/[workspaceId]/knowledge/[id]/components/base-tags-modal/base-tags-modal.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ export function BaseTagsModal({ open, onOpenChange, knowledgeBaseId }: BaseTagsM
419419
<ModalHeader>Delete Tag</ModalHeader>
420420
<ModalBody>
421421
<div className='space-y-[8px]'>
422-
<p className='text-[12px] text-[var(--text-secondary)]'>
422+
<p className='text-[var(--text-secondary)]'>
423423
Are you sure you want to delete the "{selectedTag?.displayName}" tag? This will
424424
remove this tag from {selectedTagUsage?.documentCount || 0} document
425425
{selectedTagUsage?.documentCount !== 1 ? 's' : ''}.{' '}
@@ -462,15 +462,15 @@ export function BaseTagsModal({ open, onOpenChange, knowledgeBaseId }: BaseTagsM
462462
<ModalHeader>Documents using "{selectedTag?.displayName}"</ModalHeader>
463463
<ModalBody>
464464
<div className='space-y-[8px]'>
465-
<p className='text-[12px] text-[var(--text-secondary)]'>
465+
<p className='text-[var(--text-secondary)]'>
466466
{selectedTagUsage?.documentCount || 0} document
467467
{selectedTagUsage?.documentCount !== 1 ? 's are' : ' is'} currently using this tag
468468
definition.
469469
</p>
470470

471471
{selectedTagUsage?.documentCount === 0 ? (
472472
<div className='rounded-[6px] border p-[16px] text-center'>
473-
<p className='text-[12px] text-[var(--text-secondary)]'>
473+
<p className='text-[var(--text-secondary)]'>
474474
This tag definition is not being used by any documents. You can safely delete it
475475
to free up the tag slot.
476476
</p>

apps/sim/app/workspace/[workspaceId]/knowledge/components/delete-knowledge-base-modal/delete-knowledge-base-modal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export function DeleteKnowledgeBaseModal({
4141
<ModalContent size='sm'>
4242
<ModalHeader>Delete Knowledge Base</ModalHeader>
4343
<ModalBody>
44-
<p className='text-[12px] text-[var(--text-secondary)]'>
44+
<p className='text-[var(--text-secondary)]'>
4545
{knowledgeBaseName ? (
4646
<>
4747
Are you sure you want to delete{' '}

apps/sim/app/workspace/[workspaceId]/schedules/schedules.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ export function Schedules() {
226226
/>
227227

228228
<Modal open={isDeleteDialogOpen} onOpenChange={setIsDeleteDialogOpen}>
229-
<ModalContent className='w-[400px]'>
229+
<ModalContent size='sm'>
230230
<ModalHeader>Delete Schedule</ModalHeader>
231231
<ModalBody>
232232
<p className='text-[12px] text-[var(--text-secondary)]'>

apps/sim/app/workspace/[workspaceId]/settings/components/api-keys/api-keys.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ export function ApiKeys() {
378378
<ModalContent size='sm'>
379379
<ModalHeader>Delete Sim key</ModalHeader>
380380
<ModalBody>
381-
<p className='text-[13px] text-[var(--text-secondary)]'>
381+
<p className='text-[var(--text-secondary)]'>
382382
Deleting{' '}
383383
<span className='font-medium text-[var(--text-primary)]'>{deleteKey?.name}</span> will
384384
immediately revoke access for any integrations using it.{' '}

0 commit comments

Comments
 (0)