Skip to content

Commit

Permalink
integrations categories and coming soon integrations (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasfrancisco authored Sep 19, 2024
1 parent 8e8567a commit 5bbc1e0
Show file tree
Hide file tree
Showing 101 changed files with 1,813 additions and 689 deletions.
2 changes: 1 addition & 1 deletion apps/dashboard/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pnpm dev
bun dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
Open [https://localhost:3000](https://localhost:3000) with your browser to see the result.

You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.

Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
4 changes: 2 additions & 2 deletions apps/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "module",
"scripts": {
"build": "next build",
"dev": "next dev",
"dev": "next dev --experimental-https",
"format": "prettier --check . --ignore-path ../../.gitignore --ignore-path ../../.prettierignore",
"lint": "eslint",
"start": "next start",
Expand All @@ -21,7 +21,7 @@
"@octokit/app": "^15.1.0",
"@octokit/auth-oauth-app": "^8.1.1",
"@octokit/core": "^6.1.2",
"@sentry/nextjs": "^8",
"@sentry/nextjs": "^8.30.0",
"@supabase/ssr": "^0.4.0",
"@supabase/supabase-js": "^2.45.0",
"@t3-oss/env-core": "^0.11.0",
Expand Down
19 changes: 0 additions & 19 deletions apps/dashboard/public/favicon/dev/site.webmanifest

This file was deleted.

19 changes: 0 additions & 19 deletions apps/dashboard/public/favicon/prod/site.webmanifest

This file was deleted.

3 changes: 3 additions & 0 deletions apps/dashboard/src/app/app/integrations/@tabs/default.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import DefaultPage from './inputs/page';

export default DefaultPage;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import DefaultPage from './page';

export default DefaultPage;
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use client';

import { IntegrationCard } from '@/components';
import { Button, Icons } from '@ds-project/components';
import { IntegrationLogo } from '@/components/integration-logo/integration-logo';
import Link from 'next/link';
import { config } from '@/config';

export function FigmaCard() {
return (
<IntegrationCard
logo={<IntegrationLogo icon={Icons.FigmaLogoIcon} />}
description="Install DS Pro widget in your Figma file to synchronize Figma Variables."
name="Figma"
>
<Button asChild>
<Link href={config.figmaWidgetUrl}>Install Widget</Link>
</Button>
</IntegrationCard>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { FigmaCard } from '../_components/figma-card';
export function Figma() {
return <FigmaCard />;
}
14 changes: 14 additions & 0 deletions apps/dashboard/src/app/app/integrations/@tabs/inputs/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { getMetadata } from '@/lib/metadata';
import { Figma } from './figma/_rsc/figma';
import { Penpot } from './penpot/_rsc/penpot';

export const metadata = getMetadata({ title: 'Inputs' });

export default function Page() {
return (
<section className="flex flex-wrap gap-2">
<Figma />
<Penpot />
</section>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use client';

import { IntegrationCard } from '@/components';
import { Button, PenpotLogo } from '@ds-project/components';
import { IntegrationLogo } from '@/components/integration-logo/integration-logo';

export function PenpotCard() {
return (
<IntegrationCard
disabled={true}
logo={<IntegrationLogo icon={PenpotLogo} />}
description="Syncronize your assets directly from Penpot files."
name="Penpot"
>
<Button disabled={true}>Coming soon</Button>
</IntegrationCard>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { PenpotCard } from '../_components/penpot-card';
export function Penpot() {
return <PenpotCard />;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import DefaultPage from './page';

export default DefaultPage;
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use client';

import { IntegrationCard } from '@/components';
import { Button, Icons } from '@ds-project/components';
import { IntegrationLogo } from '@/components/integration-logo/integration-logo';

export function DiscordCard() {
return (
<IntegrationCard
disabled={true}
logo={<IntegrationLogo icon={Icons.DiscordLogoIcon} />}
description="Send notifications about changes, releases or issues with your configuration."
name="Discord"
>
<Button disabled={true}>Coming soon</Button>
</IntegrationCard>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { DiscordCard } from '../_components/discord-card';
export function Discord() {
return <DiscordCard />;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { getMetadata } from '@/lib/metadata';
import { Discord } from './discord/_rsc/discord';
import { Slack } from './slack/_rsc/slack';

export const metadata = getMetadata({ title: 'Notifications' });

export default function Page() {
return (
<section className="flex flex-wrap gap-2">
<Discord />
<Slack />
</section>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use client';

import { IntegrationCard } from '@/components';
import { Button, Icons, LucideIcons } from '@ds-project/components';
import { IntegrationLogo } from '@/components/integration-logo/integration-logo';

export function SlackCard() {
return (
<IntegrationCard
disabled={true}
logo={<IntegrationLogo icon={LucideIcons.SlackIcon} />}
description="Send notifications about changes, releases or issues with your configuration."
name="Slack"
>
<Button disabled={true}>Coming soon</Button>
</IntegrationCard>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { SlackCard } from '../_components/slack-card';
export function Slack() {
return <SlackCard />;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import DefaultPage from './page';

export default DefaultPage;
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
'use server';

import { and, eq } from 'drizzle-orm';

import { Integrations, integrationType } from '@ds-project/database/schema';
import { authorizedAction } from '@/lib/safe-action';
import { z } from 'zod';
import { revalidatePath } from 'next/cache';

export const disableIntegration = authorizedAction
.metadata({ actionName: 'disableIntegration' })
.outputSchema(
z.object({
success: z.literal(true),
})
)
.action(async ({ ctx }) => {
await ctx.database
.delete(Integrations)
.where(and(eq(Integrations.type, integrationType.Enum.github)));

revalidatePath('/app/integrations/outputs');
return { success: true };
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
'use server';

import { eq } from 'drizzle-orm';

import {
githubIntegrationSchema,
Integrations,
integrationType,
} from '@ds-project/database/schema';
import { database } from '@ds-project/database/client';
import { authorizedAction } from '@/lib/safe-action';
import { z } from 'zod';

export const selectRepository = authorizedAction
.metadata({ actionName: 'selectRepository' })
.schema(
z.object({
installationId: z.number(),
repositoryId: z.number(),
tokensPath: z.string().optional(),
})
)
.outputSchema(
z.object({
success: z.literal(true),
})
)
.action(
async ({ parsedInput: { installationId, repositoryId, tokensPath } }) => {
const validatedData = await githubIntegrationSchema.parseAsync({
type: integrationType.enum.github,
installationId,
repositoryId,
tokensPath,
});

await database
.update(Integrations)
.set({
data: validatedData,
})
.where(eq(Integrations.type, integrationType.Enum.github));

return { success: true };
}
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
'use client';

import { IntegrationCard } from '@/components';
import { Icons, Text, useToast } from '@ds-project/components';
import { useCallback, useState } from 'react';
import { SettingsForm } from './settings-form';
import { disableIntegration } from '../_actions/disable-integration.action';
import { useRouter } from 'next/navigation';
import { IntegrationLogo } from '@/components/integration-logo/integration-logo';
import { IntegrationSettings } from '@/components/integration-settings/integration-settings';

interface GithubCardProps {
isEnabled: boolean;
enableUrl: string;
installationId?: number;
selectedRepositoryId?: number;
repositories?: { id: number; name: string }[];
}
export function GithubCard({
isEnabled,
installationId,
repositories,
selectedRepositoryId,
enableUrl,
}: GithubCardProps) {
const router = useRouter();
const { toast } = useToast();
const [isOpen, setIsOpen] = useState(false);

const onEnabledChange = useCallback(
async (_isEnabled: boolean) => {
if (!isEnabled && _isEnabled) {
router.push(enableUrl);
return;
}

const result = await disableIntegration();

if (result?.serverError) {
toast({
title: 'Error',
description: result.serverError,
variant: 'destructive',
});
}

if (result?.data?.success) {
toast({
title: 'Removed',
description: 'GitHub integration has been removed.',
variant: 'default',
});
}
},
[enableUrl, isEnabled, router, toast]
);

const closeHandler = useCallback(() => {
setIsOpen(false);
}, []);

return (
<IntegrationCard
logo={<IntegrationLogo icon={Icons.GitHubLogoIcon} />}
description="Synchronize design tokens to your codebase in GitHub."
name="GitHub"
>
<IntegrationSettings
integrationLogo={<IntegrationLogo icon={Icons.GitHubLogoIcon} />}
isEnabled={isEnabled}
name="GitHub"
onEnabledChange={onEnabledChange}
isOpen={isOpen}
onOpenChange={setIsOpen}
>
{installationId ? (
<SettingsForm
installationId={installationId}
repositories={repositories}
selectedRepositoryId={selectedRepositoryId}
onSuccess={closeHandler}
onCancel={closeHandler}
/>
) : (
<Text>
<p>Enable the integration to configure it.</p>
</Text>
)}
</IntegrationSettings>
</IntegrationCard>
);
}
Loading

0 comments on commit 5bbc1e0

Please sign in to comment.