From cc8f14c6af0d2b0275b4be956db9dfd475d9b766 Mon Sep 17 00:00:00 2001 From: Utku <74243531+utkubakir@users.noreply.github.com> Date: Thu, 25 May 2023 17:49:54 +0300 Subject: [PATCH] fix icon & run pnpm format and lint fix (#859) * fix icon & run pnpm format and lint fix * format --- .prettierignore | 5 +- apps/landing/postcss.config.js | 10 +- .../authjs-adapter-drizzle-mysql/index.ts | 308 +++++++++--------- docs/company/about/credits.mdx | 8 +- .../app/$libraryId/Explorer/OptionsPanel.tsx | 28 +- .../Layout/Sidebar/JobManager/Job.tsx | 6 +- .../Layout/Sidebar/JobManager/JobGroup.tsx | 6 +- .../Layout/Sidebar/LibrarySection.tsx | 2 +- .../$libraryId/TopBar/NavigationButtons.tsx | 10 +- interface/app/$libraryId/TopBar/SearchBar.tsx | 2 +- .../app/$libraryId/TopBar/TopBarOptions.tsx | 8 +- interface/app/$libraryId/location/$id.tsx | 4 +- interface/app/$libraryId/search.tsx | 23 +- .../settings/library/locations/ListItem.tsx | 3 +- .../src => interface/components}/Folder.tsx | 16 +- interface/hooks/useExplorerStore.tsx | 4 +- interface/hooks/useExplorerTopBarOptions.tsx | 4 +- packages/ui/src/index.ts | 1 - 18 files changed, 230 insertions(+), 218 deletions(-) rename {packages/ui/src => interface/components}/Folder.tsx (53%) diff --git a/.prettierignore b/.prettierignore index 741aa3cb7..b85a60718 100644 --- a/.prettierignore +++ b/.prettierignore @@ -17,4 +17,7 @@ apps/desktop/src/index.tsx # codegen from rspc -- not supposed to look nice /packages/client/src/core.ts -apps/desktop/src/commands.ts \ No newline at end of file +apps/desktop/src/commands.ts + +.next/ +.contentlayer/ \ No newline at end of file diff --git a/apps/landing/postcss.config.js b/apps/landing/postcss.config.js index 33ad091d2..054c147cb 100644 --- a/apps/landing/postcss.config.js +++ b/apps/landing/postcss.config.js @@ -1,6 +1,6 @@ module.exports = { - plugins: { - tailwindcss: {}, - autoprefixer: {}, - }, -} + plugins: { + tailwindcss: {}, + autoprefixer: {} + } +}; diff --git a/apps/landing/src/app/api/[...auth]/authjs-adapter-drizzle-mysql/index.ts b/apps/landing/src/app/api/[...auth]/authjs-adapter-drizzle-mysql/index.ts index 6fbd825f7..2673edadf 100644 --- a/apps/landing/src/app/api/[...auth]/authjs-adapter-drizzle-mysql/index.ts +++ b/apps/landing/src/app/api/[...auth]/authjs-adapter-drizzle-mysql/index.ts @@ -15,11 +15,11 @@ * * @module @next-auth/drizzle-adapter */ -import type { DbClient, Schema } from "./schema"; -import { and, eq } from "drizzle-orm"; -import type { Adapter } from "@auth/core/adapters"; +import type { Adapter } from '@auth/core/adapters'; +import { and, eq } from 'drizzle-orm'; // @ts-expect-error -import { v4 as uuid } from "uuid"; +import { v4 as uuid } from 'uuid'; +import type { DbClient, Schema } from './schema'; /** * ## Setup @@ -111,167 +111,165 @@ import { v4 as uuid } from "uuid"; * **/ export function DrizzleAdapterMySQL( - client: DbClient, - { users, sessions, verificationTokens, accounts }: Schema + client: DbClient, + { users, sessions, verificationTokens, accounts }: Schema ): Adapter { - return { - createUser: async (data) => { - const id = uuid(); + return { + createUser: async (data) => { + const id = uuid(); - await client.insert(users).values({ ...data, id }); + await client.insert(users).values({ ...data, id }); - return client - .select() - .from(users) - .where(eq(users.id, id)) - .then((res) => res[0]); - }, - getUser: async (data) => { - return ( - client - .select() - .from(users) - .where(eq(users.id, data)) - .then((res) => res[0]) ?? null - ); - }, - getUserByEmail: async (data) => { - return ( - client - .select() - .from(users) - .where(eq(users.email, data)) - .then((res) => res[0]) ?? null - ); - }, - createSession: async (data) => { - await client.insert(sessions).values(data); + return client + .select() + .from(users) + .where(eq(users.id, id)) + .then((res) => res[0]); + }, + getUser: async (data) => { + return ( + client + .select() + .from(users) + .where(eq(users.id, data)) + .then((res) => res[0]) ?? null + ); + }, + getUserByEmail: async (data) => { + return ( + client + .select() + .from(users) + .where(eq(users.email, data)) + .then((res) => res[0]) ?? null + ); + }, + createSession: async (data) => { + await client.insert(sessions).values(data); - return client - .select() - .from(sessions) - .where(eq(sessions.sessionToken, data.sessionToken)) - .then((res) => res[0]); - }, - getSessionAndUser: async (data) => { - return ( - client - .select({ - session: sessions, - user: users, - }) - .from(sessions) - .where(eq(sessions.sessionToken, data)) - .innerJoin(users, eq(users.id, sessions.userId)) - .then((res) => res[0]) ?? null - ); - }, - updateUser: async (data) => { - if (!data.id) { - throw new Error("No user id."); - } + return client + .select() + .from(sessions) + .where(eq(sessions.sessionToken, data.sessionToken)) + .then((res) => res[0]); + }, + getSessionAndUser: async (data) => { + return ( + client + .select({ + session: sessions, + user: users + }) + .from(sessions) + .where(eq(sessions.sessionToken, data)) + .innerJoin(users, eq(users.id, sessions.userId)) + .then((res) => res[0]) ?? null + ); + }, + updateUser: async (data) => { + if (!data.id) { + throw new Error('No user id.'); + } - await client.update(users).set(data).where(eq(users.id, data.id)); + await client.update(users).set(data).where(eq(users.id, data.id)); - return client - .select() - .from(users) - .where(eq(users.id, data.id)) - .then((res) => res[0]); - }, - updateSession: async (data) => { - await client - .update(sessions) - .set(data) - .where(eq(sessions.sessionToken, data.sessionToken)); + return client + .select() + .from(users) + .where(eq(users.id, data.id)) + .then((res) => res[0]); + }, + updateSession: async (data) => { + await client + .update(sessions) + .set(data) + .where(eq(sessions.sessionToken, data.sessionToken)); - return client - .select() - .from(sessions) - .where(eq(sessions.sessionToken, data.sessionToken)) - .then((res) => res[0]); - }, - linkAccount: async (rawAccount) => { - await client - .insert(accounts) - .values(rawAccount) - .then((res) => res[0]); - }, - getUserByAccount: async (account) => { - const user = - (await client - .select() - .from(users) - .innerJoin( - accounts, - and( - eq(accounts.providerAccountId, account.providerAccountId), - eq(accounts.provider, account.provider) - ) - ) - .then((res) => res[0])) ?? null; + return client + .select() + .from(sessions) + .where(eq(sessions.sessionToken, data.sessionToken)) + .then((res) => res[0]); + }, + linkAccount: async (rawAccount) => { + await client + .insert(accounts) + .values(rawAccount) + .then((res) => res[0]); + }, + getUserByAccount: async (account) => { + const user = + (await client + .select() + .from(users) + .innerJoin( + accounts, + and( + eq(accounts.providerAccountId, account.providerAccountId), + eq(accounts.provider, account.provider) + ) + ) + .then((res) => res[0])) ?? null; - return user?.users; - }, - deleteSession: async (sessionToken) => { - await client - .delete(sessions) - .where(eq(sessions.sessionToken, sessionToken)); - }, - createVerificationToken: async (token) => { - await client.insert(verificationTokens).values(token); + return user?.users; + }, + deleteSession: async (sessionToken) => { + await client.delete(sessions).where(eq(sessions.sessionToken, sessionToken)); + }, + createVerificationToken: async (token) => { + await client.insert(verificationTokens).values(token); - return client - .select() - .from(verificationTokens) - .where(eq(verificationTokens.identifier, token.identifier)) - .then((res) => res[0]); - }, - useVerificationToken: async (token) => { - try { - const deletedToken = - (await client - .select() - .from(verificationTokens) - .where( - and( - eq(verificationTokens.identifier, token.identifier), - eq(verificationTokens.token, token.token) - ) - ) - .then((res) => res[0])) ?? null; + return client + .select() + .from(verificationTokens) + .where(eq(verificationTokens.identifier, token.identifier)) + .then((res) => res[0]); + }, + useVerificationToken: async (token) => { + try { + const deletedToken = + (await client + .select() + .from(verificationTokens) + .where( + and( + eq(verificationTokens.identifier, token.identifier), + eq(verificationTokens.token, token.token) + ) + ) + .then((res) => res[0])) ?? null; - await client - .delete(verificationTokens) - .where( - and( - eq(verificationTokens.identifier, token.identifier), - eq(verificationTokens.token, token.token) - ) - ); + await client + .delete(verificationTokens) + .where( + and( + eq(verificationTokens.identifier, token.identifier), + eq(verificationTokens.token, token.token) + ) + ); - return deletedToken; - } catch (err) { - throw new Error("No verification token found."); - } - }, - deleteUser: async (id) => { - await client - .delete(users) - .where(eq(users.id, id)) - .then((res) => res[0]); - }, - unlinkAccount: async (account) => { - await client - .delete(accounts) - .where( - and( - eq(accounts.providerAccountId, account.providerAccountId), - eq(accounts.provider, account.provider) - ) - ); + return deletedToken; + } catch (err) { + throw new Error('No verification token found.'); + } + }, + deleteUser: async (id) => { + await client + .delete(users) + .where(eq(users.id, id)) + .then((res) => res[0]); + }, + unlinkAccount: async (account) => { + await client + .delete(accounts) + .where( + and( + eq(accounts.providerAccountId, account.providerAccountId), + eq(accounts.provider, account.provider) + ) + ); - return undefined; - }, - }; + return undefined; + } + }; } diff --git a/docs/company/about/credits.mdx b/docs/company/about/credits.mdx index 140d0e6a8..84d2d3bf6 100644 --- a/docs/company/about/credits.mdx +++ b/docs/company/about/credits.mdx @@ -13,8 +13,8 @@ Jamie Pine, Brendan Allan, Oscar Beaumont, Ericson Soares, Utku Bakır, Haden Fl ## Contributors - Avatars of the top contributors the the Spacedrive repository. Follow link for names and data. + Avatars of the top contributors the the Spacedrive repository. Follow link for names and data. diff --git a/interface/app/$libraryId/Explorer/OptionsPanel.tsx b/interface/app/$libraryId/Explorer/OptionsPanel.tsx index 9d66cc8ef..beda53ba8 100644 --- a/interface/app/$libraryId/Explorer/OptionsPanel.tsx +++ b/interface/app/$libraryId/Explorer/OptionsPanel.tsx @@ -1,10 +1,10 @@ -import { RadixCheckbox, Select, SelectOption, Slider, tw } from '@sd/ui'; import { z } from 'zod'; +import { RadixCheckbox, Select, SelectOption, Slider, tw } from '@sd/ui'; import { FilePathSearchOrderingKeys, + SortOrder, getExplorerConfigStore, getExplorerStore, - SortOrder, useExplorerConfigStore, useExplorerStore } from '~/hooks'; @@ -13,13 +13,13 @@ const Heading = tw.div`text-ink-dull text-xs font-semibold`; const Subheading = tw.div`text-ink-dull mb-1 text-xs font-medium`; const sortOptions: Record = { - none: 'None', - name: 'Name', - sizeInBytes: 'Size', - dateCreated: 'Date created', - dateModified: 'Date modified', - dateIndexed: 'Date indexed', - "object.dateAccessed": "Date accessed" + 'none': 'None', + 'name': 'Name', + 'sizeInBytes': 'Size', + 'dateCreated': 'Date created', + 'dateModified': 'Date modified', + 'dateIndexed': 'Date indexed', + 'object.dateAccessed': 'Date accessed' }; export default () => { @@ -78,11 +78,15 @@ export default () => { size="sm" className="w-full" onChange={(value) => - (getExplorerStore().orderByDirection = value as z.infer) + (getExplorerStore().orderByDirection = value as z.infer< + typeof SortOrder + >) } > - {SortOrder.options.map(o => ( - {o.value} + {SortOrder.options.map((o) => ( + + {o.value} + ))} diff --git a/interface/app/$libraryId/Layout/Sidebar/JobManager/Job.tsx b/interface/app/$libraryId/Layout/Sidebar/JobManager/Job.tsx index b40129883..c717624a7 100644 --- a/interface/app/$libraryId/Layout/Sidebar/JobManager/Job.tsx +++ b/interface/app/$libraryId/Layout/Sidebar/JobManager/Job.tsx @@ -152,10 +152,10 @@ function Job({ job, clearJob, className, isGroup }: JobProps) { )} /> -
+
- {niceData.name} + {niceData.name}

{job.status === 'Queued' &&

{job.status}:

} {niceData.subtext} @@ -165,7 +165,7 @@ function Job({ job, clearJob, className, isGroup }: JobProps) {
-
+
{/* {job.status === 'Running' && ( )} @@ -67,10 +67,10 @@ function JobGroup({ data, clearJob }: JobGroupProps) { src={Folder} className={clsx('relative left-[-2px] top-2 z-10 mr-3 h-6 w-6')} /> -
+
-

+

{allJobsCompleted ? `Added location "${ data.metadata.init.location.name || '' diff --git a/interface/app/$libraryId/Layout/Sidebar/LibrarySection.tsx b/interface/app/$libraryId/Layout/Sidebar/LibrarySection.tsx index 63b510852..b207d35bb 100644 --- a/interface/app/$libraryId/Layout/Sidebar/LibrarySection.tsx +++ b/interface/app/$libraryId/Layout/Sidebar/LibrarySection.tsx @@ -2,8 +2,8 @@ import { Laptop } from '@sd/assets/icons'; import clsx from 'clsx'; import { Link, NavLink } from 'react-router-dom'; import { arraysEqual, useBridgeQuery, useLibraryQuery, useOnlineLocations } from '@sd/client'; -import { Folder } from '@sd/ui'; import { AddLocationButton } from '~/app/$libraryId/settings/library/locations/AddLocationButton'; +import { Folder } from '~/components/Folder'; import { SubtleButton } from '~/components/SubtleButton'; import SidebarLink from './Link'; import Section from './Section'; diff --git a/interface/app/$libraryId/TopBar/NavigationButtons.tsx b/interface/app/$libraryId/TopBar/NavigationButtons.tsx index b9a5b3068..b5a52c009 100644 --- a/interface/app/$libraryId/TopBar/NavigationButtons.tsx +++ b/interface/app/$libraryId/TopBar/NavigationButtons.tsx @@ -1,6 +1,6 @@ -import { Tooltip } from '@sd/ui'; import { ArrowLeft, ArrowRight } from 'phosphor-react'; import { useNavigate } from 'react-router'; +import { Tooltip } from '@sd/ui'; import { useSearchStore } from '~/hooks'; import TopBarButton from './TopBarButton'; @@ -13,22 +13,22 @@ export const NavigationButtons = () => {

navigate(-1)} disabled={isFocused || idx === 0} > - + navigate(1)} disabled={isFocused || idx === history.length - 1} > - +
diff --git a/interface/app/$libraryId/TopBar/SearchBar.tsx b/interface/app/$libraryId/TopBar/SearchBar.tsx index 60f35d444..d54b81a66 100644 --- a/interface/app/$libraryId/TopBar/SearchBar.tsx +++ b/interface/app/$libraryId/TopBar/SearchBar.tsx @@ -27,7 +27,7 @@ export default () => { const searchPath = useResolvedPath('search'); - const [value, setValue] = useState(searchParams.search ?? ""); + const [value, setValue] = useState(searchParams.search ?? ''); const updateParams = useDebouncedCallback((value: string) => { startTransition(() => diff --git a/interface/app/$libraryId/TopBar/TopBarOptions.tsx b/interface/app/$libraryId/TopBar/TopBarOptions.tsx index ae2a0044a..c5dcb6a39 100644 --- a/interface/app/$libraryId/TopBar/TopBarOptions.tsx +++ b/interface/app/$libraryId/TopBar/TopBarOptions.tsx @@ -57,10 +57,10 @@ export default ({ options }: TopBarChildrenProps) => { const roundingCondition = individual ? 'both' : index === 0 - ? 'left' - : index === group.length - 1 - ? 'right' - : 'none'; + ? 'left' + : index === group.length - 1 + ? 'right' + : 'none'; return (
{ - + {path ? getLastSectionOfPath(path) : location.data?.name} diff --git a/interface/app/$libraryId/search.tsx b/interface/app/$libraryId/search.tsx index 361c03001..46c62d5b2 100644 --- a/interface/app/$libraryId/search.tsx +++ b/interface/app/$libraryId/search.tsx @@ -3,8 +3,8 @@ import { Suspense, memo, useDeferredValue, useEffect, useMemo } from 'react'; import { z } from 'zod'; import { useLibraryQuery } from '@sd/client'; import { - getExplorerStore, SortOrder, + getExplorerStore, useExplorerStore, useExplorerTopBarOptions, useZodSearchParams @@ -17,7 +17,7 @@ import TopBarOptions from './TopBar/TopBarOptions'; export const SEARCH_PARAMS = z.object({ search: z.string().optional(), take: z.coerce.number().optional(), - order: z.union([z.object({ name: SortOrder }), z.object({ name: SortOrder })]).optional(), + order: z.union([z.object({ name: SortOrder }), z.object({ name: SortOrder })]).optional() }); export type SearchArgs = z.infer; @@ -30,12 +30,15 @@ const ExplorerStuff = memo((props: { args: SearchArgs }) => { const { search, ...args } = props.args; const query = useLibraryQuery( - ['search.paths', { - ...args, - filter: { - search - }, - }], + [ + 'search.paths', + { + ...args, + filter: { + search + } + } + ], { suspense: true, enabled: !!search @@ -80,9 +83,7 @@ const ExplorerStuff = memo((props: { args: SearchArgs }) => { )}

- {search - ? `No results found for "${search}"` - : 'Search for files...'} + {search ? `No results found for "${search}"` : 'Search for files...'}

)} diff --git a/interface/app/$libraryId/settings/library/locations/ListItem.tsx b/interface/app/$libraryId/settings/library/locations/ListItem.tsx index 97c184e08..04213d739 100644 --- a/interface/app/$libraryId/settings/library/locations/ListItem.tsx +++ b/interface/app/$libraryId/settings/library/locations/ListItem.tsx @@ -3,7 +3,8 @@ import { Repeat, Trash } from 'phosphor-react'; import { useState } from 'react'; import { useNavigate } from 'react-router'; import { Location, Node, arraysEqual, useLibraryMutation, useOnlineLocations } from '@sd/client'; -import { Button, Card, Folder, Tooltip, dialogManager } from '@sd/ui'; +import { Button, Card, Tooltip, dialogManager } from '@sd/ui'; +import { Folder } from '~/components/Folder'; import DeleteDialog from './DeleteDialog'; interface Props { diff --git a/packages/ui/src/Folder.tsx b/interface/components/Folder.tsx similarity index 53% rename from packages/ui/src/Folder.tsx rename to interface/components/Folder.tsx index 691e8fc1a..34977f876 100644 --- a/packages/ui/src/Folder.tsx +++ b/interface/components/Folder.tsx @@ -1,5 +1,5 @@ -import { ReactComponent as folderWhiteSvg } from '@sd/assets/svgs/folder-white.svg'; -import { ReactComponent as folderSvg } from '@sd/assets/svgs/folder.svg'; +import folderWhiteSvg from '@sd/assets/svgs/folder-white.svg'; +import folderSvg from '@sd/assets/svgs/folder.svg'; interface FolderProps { /** @@ -21,7 +21,13 @@ interface FolderProps { export function Folder(props: FolderProps) { const { size = 24 } = props; - const Icon = props.white ? folderWhiteSvg : folderSvg; - - return ; + return ( + Folder icon + ); } diff --git a/interface/hooks/useExplorerStore.tsx b/interface/hooks/useExplorerStore.tsx index 172b4890d..c5cfb657b 100644 --- a/interface/hooks/useExplorerStore.tsx +++ b/interface/hooks/useExplorerStore.tsx @@ -1,7 +1,7 @@ import { proxy, useSnapshot } from 'valtio'; +import { z } from 'zod'; import { ExplorerItem, FilePathSearchOrdering, ObjectSearchOrdering } from '@sd/client'; import { resetStore } from '@sd/client'; -import { z } from "zod" type Join = K extends string | number ? P extends string | number @@ -26,7 +26,7 @@ export type CutCopyType = 'Cut' | 'Copy'; export type FilePathSearchOrderingKeys = UnionKeys | 'none'; export type ObjectSearchOrderingKyes = UnionKeys | 'none'; -export const SortOrder = z.union([z.literal("Asc"), z.literal("Desc")]) +export const SortOrder = z.union([z.literal('Asc'), z.literal('Desc')]); const state = { locationId: null as number | null, diff --git a/interface/hooks/useExplorerTopBarOptions.tsx b/interface/hooks/useExplorerTopBarOptions.tsx index a9328f121..64287e89c 100644 --- a/interface/hooks/useExplorerTopBarOptions.tsx +++ b/interface/hooks/useExplorerTopBarOptions.tsx @@ -10,11 +10,11 @@ import { SquaresFour, Tag } from 'phosphor-react'; +import { useLibraryMutation } from '@sd/client'; import OptionsPanel from '~/app/$libraryId/Explorer/OptionsPanel'; import { TOP_BAR_ICON_STYLE, ToolOption } from '~/app/$libraryId/TopBar/TopBarOptions'; import { KeyManager } from '../app/$libraryId/KeyManager'; import { getExplorerStore, useExplorerStore } from './useExplorerStore'; -import { useLibraryMutation } from '@sd/client'; export const useExplorerTopBarOptions = () => { const explorerStore = useExplorerStore(); @@ -100,7 +100,7 @@ export const useExplorerTopBarOptions = () => { toolTipLabel: 'Reload', onClick: () => { if (explorerStore.locationId) { - reload.mutate({ location_id: explorerStore.locationId, sub_path: '' }) + reload.mutate({ location_id: explorerStore.locationId, sub_path: '' }); } }, icon: , diff --git a/packages/ui/src/index.ts b/packages/ui/src/index.ts index d2e7e0b08..fa0f24d9f 100644 --- a/packages/ui/src/index.ts +++ b/packages/ui/src/index.ts @@ -21,4 +21,3 @@ export * from './Slider'; export * from './Divider'; export * from './Shortcut'; export * from './ProgressBar'; -export * from './Folder';