Skip to content

Commit

Permalink
chore(pr): merge pull request #3
Browse files Browse the repository at this point in the history
  • Loading branch information
Aimsucks authored Oct 5, 2024
2 parents d75f6c5 + e4072b0 commit f012dd4
Show file tree
Hide file tree
Showing 55 changed files with 8,416 additions and 6,193 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
uses: SethCohen/[email protected]
with:
webhook_url: ${{ secrets.RELEASE_WEBHOOK_URL }}
color: "2125803"
color: '2125803'

pull-and-start-container:
needs: build-and-push-image
Expand Down
23 changes: 22 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,26 @@
"tabWidth": 4,
"singleQuote": true,
"jsxSingleQuote": true,
"plugins": ["prettier-plugin-tailwindcss"]
"plugins": [
"prettier-plugin-tailwindcss",
"@ianvs/prettier-plugin-sort-imports"
],
"importOrder": [
"<BUILTIN_MODULES>",
"",
"<THIRD_PARTY_MODULES>",
"",
"^@/prisma$",
"^@prisma/(.*)$",
"",
"^@/app/(.*)$",
"",
"^@/components/(.*)$",
"",
"^@/lib/(.*)$",
"",
"^[./]"
],
"importOrderParserPlugins": ["typescript", "jsx", "decorators-legacy"],
"importOrderTypeScriptVersion": "5.0.0"
}
46 changes: 23 additions & 23 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,35 @@

## Short-term

- Add pending/loading to the plugin editing form
- Add pending/loading to the plugin editing form

## Medium-term

- Fix the development environment to actually function on a computer instead of relying on my home server.
- To solve some of the errors during build when no database is
available: https://www.reddit.com/r/nextjs/comments/16yh4xs/will_nextjs_always_require_database_access_at/
- Integrate https://trpc.io/, check T3 stack docs: https://create.t3.gg/en/introduction
- Add "pluginOwner" to UserPlugin table to prevent a user from deleting themselves when editing plugin permissions.
- Give preset descriptions markdown and multi-line support.
- Provide an endpoint to check for "any presets updated since XYZ date" so plugins can store a date and feed it into the
API if they want to present users a list of the updated presets since their last visit.
- Provide an update endpoint that receives preset IDs and version numbers for each one, so I can do the version check
processing on my end, saving bandwidth for plugins that have _a lot_ of presets.
- Mimic the functionality of the GitHub file browser for presets so there can be descriptions, separators, and ordering,
for categories, subcategories, presets, etc.
- Add loading to most of the buttons.
- Fix the development environment to actually function on a computer instead of relying on my home server.
- To solve some of the errors during build when no database is
available: https://www.reddit.com/r/nextjs/comments/16yh4xs/will_nextjs_always_require_database_access_at/
- Integrate https://trpc.io/, check T3 stack docs: https://create.t3.gg/en/introduction
- Add "pluginOwner" to UserPlugin table to prevent a user from deleting themselves when editing plugin permissions.
- Give preset descriptions markdown and multi-line support.
- Provide an endpoint to check for "any presets updated since XYZ date" so plugins can store a date and feed it into the
API if they want to present users a list of the updated presets since their last visit.
- Provide an update endpoint that receives preset IDs and version numbers for each one, so I can do the version check
processing on my end, saving bandwidth for plugins that have _a lot_ of presets.
- Mimic the functionality of the GitHub file browser for presets so there can be descriptions, separators, and ordering,
for categories, subcategories, presets, etc.
- Add loading to most of the buttons.

## Long-term

- Change the versioning model to support rolling back presets or selecting a preset version when importing. This would
have to change either the way presets are unique inside the presets table or it would mean a new table has to be
created to store the preset versions. This might be better to implement only on the web UI considering it would be
annoying to implement in-game.
- Add permissions per-preset and per-category so plugin authors can determine who can edit their presets.
- Change the versioning model to support rolling back presets or selecting a preset version when importing. This would
have to change either the way presets are unique inside the presets table or it would mean a new table has to be
created to store the preset versions. This might be better to implement only on the web UI considering it would be
annoying to implement in-game.
- Add permissions per-preset and per-category so plugin authors can determine who can edit their presets.

## Setup Documentation

- Traefik
- PostgreSQL should basically set itself up
- Minio needs a bucket created from admin panel
- Also needs an access key and secret key generated
- Traefik
- PostgreSQL should basically set itself up
- Minio needs a bucket created from admin panel
- Also needs an access key and secret key generated
9 changes: 6 additions & 3 deletions app/_actions/category.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
'use server';

import { Session } from 'next-auth';
import { auth } from '@/auth';
import { checkUserCanEditPlugin } from '@/lib/authentication';
import { prisma } from '@/prisma';
import { Session } from 'next-auth';
import { revalidatePath } from 'next/cache';

import { prisma } from '@/prisma';

import { categoryFormSchema } from '@/app/_validation/category';

import { checkUserCanEditPlugin } from '@/lib/authentication';

export type FormState = {
message: string;
error?: boolean;
Expand Down
6 changes: 3 additions & 3 deletions app/_actions/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
'use server';

import { auth } from '@/auth';
import mime from 'mime';

import { Session } from 'next-auth';
import { revalidatePath } from 'next/cache';
import { z } from 'zod';

import { auth } from '@/auth';
import { prisma } from '@/prisma';

import {
pluginPermissionsOptionSchema,
pluginUpdateFormSchema,
} from '@/app/_validation/plugin';

import { checkUserCanEditPlugin } from '@/lib/authentication';
import { saveFileInBucket } from '@/lib/s3-file-management';
import { z } from 'zod';

export type FormState = {
message: string;
Expand Down
9 changes: 6 additions & 3 deletions app/_actions/preset.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
'use server';

import { Session } from 'next-auth';
import { auth } from '@/auth';
import { checkUserCanEditPlugin } from '@/lib/authentication';
import { Session } from 'next-auth';
import { revalidatePath } from 'next/cache';

import { prisma } from '@/prisma';

import { presetFormSchema } from '@/app/_validation/preset';
import { revalidatePath } from 'next/cache';

import { checkUserCanEditPlugin } from '@/lib/authentication';

export type FormState = {
message: string;
Expand Down
1 change: 1 addition & 0 deletions app/api/v1/plugins/[slug]/presets/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { NextRequest, NextResponse } from 'next/server';

import { prisma } from '@/prisma';

export async function GET(
Expand Down
1 change: 1 addition & 0 deletions app/api/v1/plugins/[slug]/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { NextRequest, NextResponse } from 'next/server';

import { prisma } from '@/prisma';
import { Plugin } from '@prisma/client';

Expand Down
1 change: 1 addition & 0 deletions app/api/v1/plugins/[slug]/updates/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { NextRequest, NextResponse } from 'next/server';

import { prisma } from '@/prisma';

export async function GET(
Expand Down
9 changes: 7 additions & 2 deletions app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import type { Metadata, Viewport } from 'next';
import { Inter as FontSans } from 'next/font/google';

import { cn } from '@/lib/utils';

import './globals.css';
import SessionWrapper from '@/components/auth/SessionWrapper';

import { config } from '@fortawesome/fontawesome-svg-core';
import { NextIntlClientProvider } from 'next-intl';
import { getLocale, getMessages } from 'next-intl/server';

import SessionWrapper from '@/components/auth/SessionWrapper';
import TopBar from '@/components/base/HeaderBar';
import { config } from '@fortawesome/fontawesome-svg-core';

import '@fortawesome/fontawesome-svg-core/styles.css';

const fontSans = FontSans({
Expand Down
7 changes: 5 additions & 2 deletions app/plugins/[slug]/_components/PresetBrowser.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
'use client';

import CategoryList from '@/app/plugins/[slug]/_components/_list/CategoryList';
import ListItemViewer from '@/app/plugins/[slug]/_components/_viewer/ListItemViewer';
import { useState } from 'react';

import { PluginType } from '@/prisma';

import CategoryList from '@/app/plugins/[slug]/_components/_list/CategoryList';
import ListItemViewer from '@/app/plugins/[slug]/_components/_viewer/ListItemViewer';

import { ItemViewerType, UserPermissionsType } from '@/lib/definitions';

type PresetBrowserProps = {
Expand Down
7 changes: 4 additions & 3 deletions app/plugins/[slug]/_components/_info/PluginButton.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from 'react';
import Link from 'next/link';
import { Button } from '@/components/ui/button';
import { IconDefinition } from '@fortawesome/free-brands-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import Link from 'next/link';
import React from 'react';

import { Button } from '@/components/ui/button';

interface PluginButtonProps {
icon: IconDefinition;
Expand Down
7 changes: 5 additions & 2 deletions app/plugins/[slug]/_components/_info/PluginButtonRow.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import React from 'react';
import { faDiscord, faGithub } from '@fortawesome/free-brands-svg-icons';
import React from 'react';

import { PluginType } from '@/prisma';

import PluginButton from '@/app/plugins/[slug]/_components/_info/PluginButton';
import { UserPermissionsType } from '@/lib/definitions';
import PluginEditButton from '@/app/plugins/[slug]/_components/_info/PluginEditButton';

import { UserPermissionsType } from '@/lib/definitions';

type PluginButtonRowProps = {
plugin: PluginType;
userPermissions: UserPermissionsType;
Expand Down
3 changes: 2 additions & 1 deletion app/plugins/[slug]/_components/_info/PluginEditButton.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
'use client';

import { faEdit } from '@fortawesome/free-regular-svg-icons';

import PluginButton from '@/app/plugins/[slug]/_components/_info/PluginButton';
import { usePluginContext } from '@/app/plugins/[slug]/_components/PluginContext';
import { faEdit } from '@fortawesome/free-regular-svg-icons';

export default function PluginEditButton() {
const { isPluginEditorOpen, setIsPluginEditorOpen } = usePluginContext();
Expand Down
29 changes: 16 additions & 13 deletions app/plugins/[slug]/_components/_info/PluginEditor.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
import { Textarea } from '@/components/ui/textarea';
import { usePluginContext } from '@/app/plugins/[slug]/_components/PluginContext';
import { zodResolver } from '@hookform/resolvers/zod';
import { SaveIcon, XCircle } from 'lucide-react';
import { useSession } from 'next-auth/react';
import { useRef } from 'react';
import { useFormState } from 'react-dom';
import { useForm } from 'react-hook-form';
import { z } from 'zod';

import { PluginType, UserPluginType } from '@/prisma';
import { User } from '@prisma/client';

import { updatePluginAction } from '@/app/_actions/plugin';
import { pluginUpdateFormSchema } from '@/app/_validation/plugin';
import { usePluginContext } from '@/app/plugins/[slug]/_components/PluginContext';

import { Button } from '@/components/ui/button';
import {
Form,
FormControl,
Expand All @@ -9,19 +22,9 @@ import {
FormLabel,
FormMessage,
} from '@/components/ui/form';
import { useForm } from 'react-hook-form';
import { zodResolver } from '@hookform/resolvers/zod';
import { Input } from '@/components/ui/input';
import MultipleSelector, { Option } from '@/components/ui/multi-select';
import { Button } from '@/components/ui/button';
import { SaveIcon, XCircle } from 'lucide-react';
import { useRef } from 'react';
import { pluginUpdateFormSchema } from '@/app/_validation/plugin';
import { z } from 'zod';
import { useFormState } from 'react-dom';
import { updatePluginAction } from '@/app/_actions/plugin';
import { useSession } from 'next-auth/react';
import { PluginType, UserPluginType } from '@/prisma';
import { Textarea } from '@/components/ui/textarea';

type PluginEditorProps = {
plugin: PluginType;
Expand Down
5 changes: 3 additions & 2 deletions app/plugins/[slug]/_components/_info/PluginEditorWrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
'use client';

import PluginEditor from '@/app/plugins/[slug]/_components/_info/PluginEditor';
import { usePluginContext } from '@/app/plugins/[slug]/_components/PluginContext';
import { PluginType } from '@/prisma';
import { User } from '@prisma/client';

import PluginEditor from '@/app/plugins/[slug]/_components/_info/PluginEditor';
import { usePluginContext } from '@/app/plugins/[slug]/_components/PluginContext';

type PluginEditorWrapperProps = {
plugin: PluginType;
users: User[];
Expand Down
13 changes: 8 additions & 5 deletions app/plugins/[slug]/_components/_info/PluginInfo.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import Image from 'next/image';
import { BookText, Clock, Sparkles } from 'lucide-react';
import { getFormatter } from 'next-intl/server';
import Image from 'next/image';

import { PluginType, prisma } from '@/prisma';
import { UserPermissionsType } from '@/lib/definitions';
import PluginFact from '@/app/plugins/[slug]/_components/_info/PluginFact';
import { User } from '@prisma/client';

import PluginButtonRow from '@/app/plugins/[slug]/_components/_info/PluginButtonRow';
import PluginEditorWrapper from '@/app/plugins/[slug]/_components/_info/PluginEditorWrapper';
import { getFormatter } from 'next-intl/server';
import { User } from '@prisma/client';
import PluginFact from '@/app/plugins/[slug]/_components/_info/PluginFact';

import { UserPermissionsType } from '@/lib/definitions';

type PluginInfoProps = {
plugin: PluginType;
Expand Down
12 changes: 7 additions & 5 deletions app/plugins/[slug]/_components/_list/CategoryList.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { Category, Preset } from '@prisma/client';
import { useState } from 'react';
import PresetListItem from '@/app/plugins/[slug]/_components/_list/PresetListItem';

import { Category, Preset } from '@prisma/client';

import CategoryListItem from '@/app/plugins/[slug]/_components/_list/CategoryListItem';
import PresetListItem from '@/app/plugins/[slug]/_components/_list/PresetListItem';

import Add from '@/components/shared/buttons/Add';

import { ItemViewerType, UserPermissionsType } from '@/lib/definitions';

type CategoryListProps = {
Expand Down Expand Up @@ -51,9 +55,7 @@ export default function CategoryList({
<Add
type='top-level category'
className='ml-auto h-10 w-10 rounded-xl bg-punish-800 hover:bg-punish-700'
onClick={() =>
onItemOpen({ categoryId: 0, newCategory: true })
}
onClick={() => onItemOpen({ categoryId: 0 })}
/>
</div>
)}
Expand Down
7 changes: 5 additions & 2 deletions app/plugins/[slug]/_components/_list/CategoryListItem.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { Category, Preset } from '@prisma/client';
import { ChevronUp, ExternalLink } from 'lucide-react';
import { Button } from '@/components/ui/button';

import { Category, Preset } from '@prisma/client';

import Add from '@/components/shared/buttons/Add';
import { Button } from '@/components/ui/button';

import { ItemViewerType, UserPermissionsType } from '@/lib/definitions';

type CategoryProps = {
Expand Down
5 changes: 4 additions & 1 deletion app/plugins/[slug]/_components/_list/PresetListItem.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { ExternalLink } from 'lucide-react';

import { Preset } from '@prisma/client';

import { Button } from '@/components/ui/button';
import { ExternalLink } from 'lucide-react';

import { ItemViewerType } from '@/lib/definitions';

type PresetListItemProps = {
Expand Down
Loading

0 comments on commit f012dd4

Please sign in to comment.