Skip to content

Commit

Permalink
reduce repeated types
Browse files Browse the repository at this point in the history
  • Loading branch information
juandjara committed Oct 5, 2023
1 parent 5b82fed commit 3b8c22f
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 24 deletions.
7 changes: 2 additions & 5 deletions app/components/post-details/FrontmatterEditor.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { Permissions } from "@/lib/github"
import type { CollectionFile, ProjectConfig } from "@/lib/projects.server"
import { buttonCN, inputCN, labelCN } from "@/lib/styles"
import { PlusIcon, XMarkIcon } from "@heroicons/react/20/solid"
Expand All @@ -7,11 +8,7 @@ import { useState } from "react"
type LoaderData = {
file: CollectionFile,
config: ProjectConfig,
permissions: {
admin: boolean
push: boolean
pull: boolean
}
permissions: Permissions
}

export default function FrontmatterEditor({ onDraft }: { onDraft: () => void }) {
Expand Down
7 changes: 2 additions & 5 deletions app/components/post-details/PostEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@ import MarkdownEditor from "./markdown-editor/MarkdownEditor"
import MarkdownPreview from "./markdown-editor/MarkdownPreview"
import clsx from "clsx"
import { ArrowLeftIcon, DocumentMagnifyingGlassIcon } from "@heroicons/react/24/outline"
import type { Permissions } from "@/lib/github"

type LoaderData = {
file: CollectionFile,
config: ProjectConfig,
permissions: {
admin: boolean
push: boolean
pull: boolean
}
permissions: Permissions
}

export default function PostEditor({ onDraft }: { onDraft: () => void }) {
Expand Down
8 changes: 2 additions & 6 deletions app/components/source-files/FileDetails.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect, useState } from 'react'
import FileEditor from './FileEditor'
import type { ParsedFile } from '@/lib/github'
import type { ParsedFile, Permissions } from '@/lib/github'
import FileLabel from './FileLabel'
import { Form, Link, useLoaderData, useParams, useTransition } from '@remix-run/react'
import { buttonCN } from '@/lib/styles'
Expand All @@ -9,11 +9,7 @@ import { useProject } from '@/lib/useProjectConfig'
type LoaderData = {
branch: string
file: ParsedFile
permissions: {
admin: boolean
push: boolean
pull: boolean
}
permissions: Permissions
}

function BackIcon() {
Expand Down
7 changes: 2 additions & 5 deletions app/routes/p/$project/$cid/$pid.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { Permissions} from "@/lib/github"
import { deleteFile, getFileContent, getRepoDetails, saveFile } from "@/lib/github"
import type { CollectionFile, ProjectConfig } from "@/lib/projects.server"
import { processFileContent } from "@/lib/projects.server"
Expand All @@ -19,11 +20,7 @@ import PostDetailsHeader from "@/components/post-details/PostDetailHeader"
type LoaderData = {
file: CollectionFile,
config: ProjectConfig,
permissions: {
admin: boolean
push: boolean
pull: boolean
}
permissions: Permissions
}

export const meta: MetaFunction = ({ data }) => {
Expand Down
6 changes: 3 additions & 3 deletions app/routes/p/$project/settings.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ComboBoxLocal } from "@/components/ComboBoxLocal"
import type { TreeItem} from "@/lib/github"
import { getRepoFiles } from "@/lib/github"
import { FileMode, getRepoFiles } from "@/lib/github"
import metaTitle from "@/lib/metaTitle"
import { getProject, getProjectConfig, updateConfigFile } from "@/lib/projects.server"
import { deleteConfigFile, deleteProject, updateProject } from "@/lib/projects.server"
Expand Down Expand Up @@ -71,9 +71,9 @@ export async function loader({ params, request }: LoaderArgs) {
tree.unshift({
path: '/',
type: 'tree' as const,
url: '',
mode: '',
mode: FileMode.TREE,
sha: '',
url: '',
})

return json({ tree: tree.filter((t) => t.type === 'tree') })
Expand Down

0 comments on commit 3b8c22f

Please sign in to comment.