From a42bc63f5d3b75736065e6e754d6e4d000fcff15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Vasconcellos?= Date: Sat, 20 May 2023 01:36:35 -0300 Subject: [PATCH] Some misc fixes (#836) * Fix setup-system breaking in macOS due to unavailable envvar - Remove unused docker build-arg from ffmpeg workflow - Fix Overview Explorer extending below inspector - Fix some left behind formatting problems * Some more formatting --- .github/actions/setup-rust/action.yaml | 2 +- .github/scripts/setup-system.sh | 2 +- .github/workflows/ffmpeg.yml | 2 +- .github/workflows/release.yml | 2 +- apps/desktop/src-tauri/Cargo.toml | 6 +-- .../$libraryId/Explorer/File/ContextMenu.tsx | 31 +++++++++------ .../app/$libraryId/Explorer/OptionsPanel.tsx | 39 +++++++++++++++---- interface/app/$libraryId/Explorer/View.tsx | 17 ++++---- interface/app/$libraryId/Explorer/index.tsx | 9 +---- .../app/$libraryId/KeyManager/NotUnlocked.tsx | 4 +- interface/app/$libraryId/KeyManager/index.tsx | 21 ++-------- .../Layout/Sidebar/LibrariesDropdown.tsx | 2 +- interface/app/$libraryId/location/$id.tsx | 22 ++++++----- .../$libraryId/overview/CategoryButton.tsx | 5 +-- .../app/$libraryId/overview/Statistics.tsx | 18 ++++----- interface/app/$libraryId/overview/index.tsx | 1 - interface/app/$libraryId/search.tsx | 20 +++++++--- .../locations/IndexerRuleEditor/RuleInput.tsx | 16 ++++---- interface/app/$libraryId/spacedrop.tsx | 8 ++-- interface/app/onboarding/alpha.tsx | 2 +- interface/hooks/useCounter.ts | 10 +++-- interface/hooks/useExplorerTopBarOptions.tsx | 2 +- packages/ui/src/RadioGroup.tsx | 4 +- 23 files changed, 131 insertions(+), 114 deletions(-) diff --git a/.github/actions/setup-rust/action.yaml b/.github/actions/setup-rust/action.yaml index 1ffc7c784..dcf56fe8e 100644 --- a/.github/actions/setup-rust/action.yaml +++ b/.github/actions/setup-rust/action.yaml @@ -24,7 +24,7 @@ runs: with: key: ${{ inputs.targets }} save-if: ${{ inputs.save-cache }} - prefix-key: "v0" + prefix-key: 'v0' shared-key: rust-deps # Windows is having disk related problems with target caching cache-targets: ${{ runner.os != 'Windows' }} diff --git a/.github/scripts/setup-system.sh b/.github/scripts/setup-system.sh index 059e33a7e..997d83189 100755 --- a/.github/scripts/setup-system.sh +++ b/.github/scripts/setup-system.sh @@ -316,7 +316,7 @@ elif [ "$SYSNAME" = "Darwin" ]; then for _lib in "${_frameworks_dir}/FFMpeg.framework/Libraries/"*; do if [ -f "$_lib" ]; then # Sign the lib with the local machine certificate (Required for it to work on macOS 13+) - if ! codesign -s "$APPLE_SIGNING_IDENTITY" -f "$_lib" 1>/dev/null 2>&1; then + if ! codesign -s "${APPLE_SIGNING_IDENTITY:--}" -f "$_lib" 1>/dev/null 2>&1; then err "Failed to sign: ${_lib#"$_frameworks_dir"}" \ 'Please open an issue on https://github.com/spacedriveapp/spacedrive/issues' fi diff --git a/.github/workflows/ffmpeg.yml b/.github/workflows/ffmpeg.yml index 12268f9ca..b4beea06f 100644 --- a/.github/workflows/ffmpeg.yml +++ b/.github/workflows/ffmpeg.yml @@ -45,7 +45,7 @@ jobs: run: | set -euxo pipefail cd .github/scripts/ffmpeg-macos - docker build --build-arg FFMPEG_VERSION=$FFMPEG_VERSION --build-arg APPLE_SIGNING_IDENTITY="${{ secrets.APPLE_SIGNING_IDENTITY }}" -o . . + docker build --build-arg FFMPEG_VERSION=$FFMPEG_VERSION -o . . export XZ_OPT='-T0 -9' tar -cJf "ffmpeg-${FFMPEG_VERSION}-x86_64.tar.xz" -C ffmpeg/x86_64 . tar -cJf "ffmpeg-${FFMPEG_VERSION}-arm64.tar.xz" -C ffmpeg/aarch64 . diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e8f124c26..e55909e1c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -51,7 +51,7 @@ jobs: - name: Install Codesigning Certificate if: ${{ runner.os == 'macOS' }} uses: apple-actions/import-codesign-certs@v2 - with: + with: p12-file-base64: ${{ secrets.APPLE_CERTIFICATE }} p12-password: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }} diff --git a/apps/desktop/src-tauri/Cargo.toml b/apps/desktop/src-tauri/Cargo.toml index 1f5c30a60..5c86e07b3 100644 --- a/apps/desktop/src-tauri/Cargo.toml +++ b/apps/desktop/src-tauri/Cargo.toml @@ -9,11 +9,7 @@ repository.workspace = true edition.workspace = true [dependencies] -tauri = { version = "1.3.0", features = [ - "api-all", - "linux-protocol-headers", - "macos-private-api", -] } +tauri = { version = "1.3.0", features = ["api-all", "linux-protocol-headers", "macos-private-api"] } rspc = { workspace = true, features = ["tauri"] } httpz = { workspace = true, features = [ "axum", diff --git a/interface/app/$libraryId/Explorer/File/ContextMenu.tsx b/interface/app/$libraryId/Explorer/File/ContextMenu.tsx index 977b86ae9..5eb53c991 100644 --- a/interface/app/$libraryId/Explorer/File/ContextMenu.tsx +++ b/interface/app/$libraryId/Explorer/File/ContextMenu.tsx @@ -22,9 +22,8 @@ import { useLibraryQuery } from '@sd/client'; import { ContextMenu, dialogManager } from '@sd/ui'; -import { showAlertDialog } from '~/components/AlertDialog'; -import { getExplorerStore, useExplorerStore } from '~/hooks/useExplorerStore'; -import { useOperatingSystem } from '~/hooks/useOperatingSystem'; +import { showAlertDialog } from '~/components'; +import { getExplorerStore, useExplorerStore, useOperatingSystem } from '~/hooks'; import { usePlatform } from '~/util/Platform'; import AssignTagMenuItems from '../AssignTagMenuItems'; import { OpenInNativeExplorer } from '../ContextMenu'; @@ -231,15 +230,23 @@ export default ({ data, className, ...props }: Props) => { - { - fullRescan.mutate(getExplorerStore().locationId!); - }} label="Rescan Directory" icon={Package} /> - { - generateThumbnails.mutate({ - id: getExplorerStore().locationId!, - path: '/' - }); - }} label="Regen Thumbnails" icon={Package} /> + { + fullRescan.mutate(getExplorerStore().locationId!); + }} + label="Rescan Directory" + icon={Package} + /> + { + generateThumbnails.mutate({ + id: getExplorerStore().locationId!, + path: '/' + }); + }} + label="Regen Thumbnails" + icon={Package} + /> {
Sort by - + (getExplorerStore().orderBy = value as ExplorerOrderByKeys) + } + > {Object.entries(sortOptions).map(([value, text]) => ( {text} @@ -59,7 +71,14 @@ export default () => {
Direction - + (getExplorerStore().orderByDirection = value as ExplorerDirection) + } + > Asc Desc @@ -91,9 +110,13 @@ export default () => { )}
Double click action - { + getExplorerConfigStore().openOnDoubleClick = value === 'openFile'; + }} + > Open File Quick Preview diff --git a/interface/app/$libraryId/Explorer/View.tsx b/interface/app/$libraryId/Explorer/View.tsx index 45c8417d2..87aff1b97 100644 --- a/interface/app/$libraryId/Explorer/View.tsx +++ b/interface/app/$libraryId/Explorer/View.tsx @@ -1,8 +1,9 @@ -import { ExplorerItem, isPath, useLibraryContext, useLibraryMutation } from '@sd/client'; import clsx from 'clsx'; import { HTMLAttributes, PropsWithChildren, memo, useRef } from 'react'; import { createSearchParams, useMatch, useNavigate } from 'react-router-dom'; -import { getExplorerStore, useExplorerStore } from '~/hooks/useExplorerStore'; +import { ExplorerItem, isPath, useLibraryContext, useLibraryMutation } from '@sd/client'; +import { getExplorerStore, useExplorerConfigStore, useExplorerStore } from '~/hooks'; +import { usePlatform } from '~/util/Platform'; import { TOP_BAR_HEIGHT } from '../TopBar'; import DismissibleNotice from './DismissibleNotice'; import ContextMenu from './File/ContextMenu'; @@ -11,8 +12,6 @@ import ListView from './ListView'; import MediaView from './MediaView'; import { ViewContext } from './ViewContext'; import { getExplorerItemData, getItemFilePath } from './util'; -import { usePlatform } from '~/util/Platform'; -import { useExplorerConfigStore } from '~/hooks/useExplorerConfigStore'; interface ViewItemProps extends PropsWithChildren, HTMLAttributes { data: ExplorerItem; @@ -40,11 +39,12 @@ export const ViewItem = ({ if (isPath(data) && data.item.is_dir) { navigate({ pathname: `/${library.uuid}/location/${getItemFilePath(data)?.location_id}`, - search: createSearchParams({ path: `${data.item.materialized_path}${data.item.name}/` }).toString() + search: createSearchParams({ + path: `${data.item.materialized_path}${data.item.name}/` + }).toString() }); getExplorerStore().selectedRowIndex = null; - } else if (openFilePath && filePath && explorerConfig.openOnDoubleClick) { data.type === 'Path' && data.item.object_id && @@ -84,7 +84,6 @@ interface Props { hasNextPage?: boolean; isFetchingNextPage?: boolean; viewClassName?: string; - scrollRef?: React.RefObject; } export default memo((props: Props) => { @@ -98,7 +97,7 @@ export default memo((props: Props) => { return (
{ ; } export default function Explorer(props: Props) { @@ -69,17 +68,13 @@ export default function Explorer(props: Props) { hasNextPage={props.hasNextPage} isFetchingNextPage={props.isFetchingNextPage} viewClassName={props.viewClassName} - scrollRef={props.scrollRef} /> )}
{expStore.showInspector && (
- +
)}
diff --git a/interface/app/$libraryId/KeyManager/NotUnlocked.tsx b/interface/app/$libraryId/KeyManager/NotUnlocked.tsx index 681f6fd3d..5e50c7909 100644 --- a/interface/app/$libraryId/KeyManager/NotUnlocked.tsx +++ b/interface/app/$libraryId/KeyManager/NotUnlocked.tsx @@ -2,7 +2,7 @@ import { Spinner } from 'phosphor-react'; import { useState } from 'react'; import { useLibraryMutation, useLibraryQuery } from '@sd/client'; import { Button, PasswordInput } from '@sd/ui'; -import { showAlertDialog } from '~/components/AlertDialog'; +import { showAlertDialog } from '~/components'; // TODO: Should be a form export default () => { @@ -31,7 +31,6 @@ export default () => { disabled={isUnlocking} /> - -
); }; diff --git a/interface/app/$libraryId/KeyManager/index.tsx b/interface/app/$libraryId/KeyManager/index.tsx index a04d67cd1..b8b4e5bdf 100644 --- a/interface/app/$libraryId/KeyManager/index.tsx +++ b/interface/app/$libraryId/KeyManager/index.tsx @@ -1,6 +1,6 @@ import { Gear, Lock, MagnifyingGlass, X } from 'phosphor-react'; import { useLibraryContext, useLibraryMutation, useLibraryQuery } from '@sd/client'; -import { Button, ButtonLink, Input, Tabs } from '@sd/ui'; +import { Button, Tabs } from '@sd/ui'; import KeyList from './List'; import KeyMounter from './Mounter'; import NotSetup from './NotSetup'; @@ -34,12 +34,7 @@ const Unlocked = () => { Keys */} -
@@ -56,18 +51,10 @@ const Unlocked = () => { > - - diff --git a/interface/app/$libraryId/Layout/Sidebar/LibrariesDropdown.tsx b/interface/app/$libraryId/Layout/Sidebar/LibrariesDropdown.tsx index e978d50d6..42c4612a8 100644 --- a/interface/app/$libraryId/Layout/Sidebar/LibrariesDropdown.tsx +++ b/interface/app/$libraryId/Layout/Sidebar/LibrariesDropdown.tsx @@ -26,7 +26,7 @@ export default () => { } // we override the sidebar dropdown item's hover styles // because the dark style clashes with the sidebar - className="mt-1 shadow-none data-[side=bottom]:slide-in-from-top-2 dark:divide-menu-selected/30 dark:border-sidebar-line dark:bg-sidebar-box" + className="data-[side=bottom]:slide-in-from-top-2 mt-1 shadow-none dark:divide-menu-selected/30 dark:border-sidebar-line dark:bg-sidebar-box" alignToTrigger > {libraries.data?.map((lib) => ( diff --git a/interface/app/$libraryId/location/$id.tsx b/interface/app/$libraryId/location/$id.tsx index 1557ef9fe..ce80cea64 100644 --- a/interface/app/$libraryId/location/$id.tsx +++ b/interface/app/$libraryId/location/$id.tsx @@ -1,12 +1,15 @@ -import { useLibraryContext, useLibraryMutation, useRspcLibraryContext } from '@sd/client'; -import { dialogManager } from '@sd/ui'; import { useInfiniteQuery } from '@tanstack/react-query'; import { useEffect, useMemo } from 'react'; import { useKey } from 'rooks'; import { z } from 'zod'; -import { useZodRouteParams } from '~/hooks'; -import { getExplorerStore, useExplorerStore } from '~/hooks/useExplorerStore'; -import { useExplorerTopBarOptions } from '~/hooks/useExplorerTopBarOptions'; +import { useLibraryContext, useLibraryMutation, useRspcLibraryContext } from '@sd/client'; +import { dialogManager } from '@sd/ui'; +import { + getExplorerStore, + useExplorerStore, + useExplorerTopBarOptions, + useZodRouteParams +} from '~/hooks'; import Explorer from '../Explorer'; import DeleteDialog from '../Explorer/File/DeleteDialog'; import { useExplorerOrder, useExplorerSearchParams } from '../Explorer/util'; @@ -19,7 +22,8 @@ const PARAMS = z.object({ export const Component = () => { const [{ path }] = useExplorerSearchParams(); const { id: location_id } = useZodRouteParams(PARAMS); - const { explorerViewOptions, explorerControlOptions, explorerToolOptions } = useExplorerTopBarOptions(); + const { explorerViewOptions, explorerControlOptions, explorerToolOptions } = + useExplorerTopBarOptions(); // we destructure this since `mutate` is a stable reference but the object it's in is not const { mutate: quickRescan } = useLibraryMutation('locations.quickRescan'); @@ -51,7 +55,9 @@ export const Component = () => { return ( <> - +
{ ); }; - - const useItems = () => { const { id: locationId } = useZodRouteParams(PARAMS); const [{ path, take }] = useExplorerSearchParams(); diff --git a/interface/app/$libraryId/overview/CategoryButton.tsx b/interface/app/$libraryId/overview/CategoryButton.tsx index 720f840cb..60af2698b 100644 --- a/interface/app/$libraryId/overview/CategoryButton.tsx +++ b/interface/app/$libraryId/overview/CategoryButton.tsx @@ -1,4 +1,4 @@ -import clsx from "clsx"; +import clsx from 'clsx'; interface CategoryButtonProps { category: string; @@ -28,8 +28,7 @@ export default ({ category, icon, items, selected, onClick }: CategoryButtonProp
); -} - +}; function numberWithCommas(x: number) { return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ','); diff --git a/interface/app/$libraryId/overview/Statistics.tsx b/interface/app/$libraryId/overview/Statistics.tsx index c9a06e8d6..fbd762be5 100644 --- a/interface/app/$libraryId/overview/Statistics.tsx +++ b/interface/app/$libraryId/overview/Statistics.tsx @@ -1,9 +1,9 @@ -import { Statistics, useLibraryContext, useLibraryQuery } from "@sd/client"; -import byteSize from "byte-size"; -import clsx from "clsx"; -import Skeleton from "react-loading-skeleton"; -import useCounter from '~/hooks/useCounter'; -import { usePlatform } from "~/util/Platform"; +import byteSize from 'byte-size'; +import clsx from 'clsx'; +import Skeleton from 'react-loading-skeleton'; +import { Statistics, useLibraryContext, useLibraryQuery } from '@sd/client'; +import { useCounter } from '~/hooks'; +import { usePlatform } from '~/util/Platform'; interface StatItemProps { title: string; @@ -30,7 +30,6 @@ const EMPTY_STATISTICS = { total_unique_bytes: '0' }; - const displayableStatItems = Object.keys(StatItemNames) as unknown as keyof typeof StatItemNames; let mounted = false; @@ -77,7 +76,6 @@ const StatItem = (props: StatItemProps) => { ); }; - export default () => { const platform = usePlatform(); const { library } = useLibraryContext(); @@ -103,5 +101,5 @@ export default () => { })}
- ) -} + ); +}; diff --git a/interface/app/$libraryId/overview/index.tsx b/interface/app/$libraryId/overview/index.tsx index 9fb41ce5c..9b2acb98c 100644 --- a/interface/app/$libraryId/overview/index.tsx +++ b/interface/app/$libraryId/overview/index.tsx @@ -131,7 +131,6 @@ export const Component = () => { onLoadMore={query.fetchNextPage} hasNextPage={query.hasNextPage} isFetchingNextPage={query.isFetchingNextPage} - scrollRef={page?.ref} >
diff --git a/interface/app/$libraryId/search.tsx b/interface/app/$libraryId/search.tsx index c9b568485..c415caa54 100644 --- a/interface/app/$libraryId/search.tsx +++ b/interface/app/$libraryId/search.tsx @@ -2,9 +2,12 @@ import { MagnifyingGlass } from 'phosphor-react'; import { Suspense, memo, useDeferredValue, useEffect, useMemo } from 'react'; import { z } from 'zod'; import { useLibraryQuery } from '@sd/client'; -import { useZodSearchParams } from '~/hooks'; -import { getExplorerStore, useExplorerStore } from '~/hooks/useExplorerStore'; -import { useExplorerTopBarOptions } from '~/hooks/useExplorerTopBarOptions'; +import { + getExplorerStore, + useExplorerStore, + useExplorerTopBarOptions, + useZodSearchParams +} from '~/hooks'; import Explorer from './Explorer'; import { getExplorerItemData } from './Explorer/util'; import TopBarChildren from './TopBar/TopBarChildren'; @@ -19,7 +22,8 @@ export type SearchArgs = z.infer; const ExplorerStuff = memo((props: { args: SearchArgs }) => { const explorerStore = useExplorerStore(); - const { explorerViewOptions, explorerControlOptions, explorerToolOptions } = useExplorerTopBarOptions(); + const { explorerViewOptions, explorerControlOptions, explorerToolOptions } = + useExplorerTopBarOptions(); const query = useLibraryQuery(['search.paths', props.args], { suspense: true, @@ -45,7 +49,13 @@ const ExplorerStuff = memo((props: { args: SearchArgs }) => { <> {items && items.length > 0 ? ( <> - + ) : ( diff --git a/interface/app/$libraryId/settings/library/locations/IndexerRuleEditor/RuleInput.tsx b/interface/app/$libraryId/settings/library/locations/IndexerRuleEditor/RuleInput.tsx index 0b747bf08..8f9b6f119 100644 --- a/interface/app/$libraryId/settings/library/locations/IndexerRuleEditor/RuleInput.tsx +++ b/interface/app/$libraryId/settings/library/locations/IndexerRuleEditor/RuleInput.tsx @@ -125,19 +125,19 @@ export const RuleInput = memo( try { const path = await openDirectoryPickerDialog(platform); const event = { - target: { - value: path - } + target: { + value: path + } } as ChangeEvent; if (path) { - props.onChange?.(event); + props.onChange?.(event); } - } catch (error) { + } catch (error) { showAlertDialog({ - title: 'Error', - value: String(error) + title: 'Error', + value: String(error) }); - } + } }} {...props} /> diff --git a/interface/app/$libraryId/spacedrop.tsx b/interface/app/$libraryId/spacedrop.tsx index 3e16907f3..960aba43d 100644 --- a/interface/app/$libraryId/spacedrop.tsx +++ b/interface/app/$libraryId/spacedrop.tsx @@ -1,8 +1,8 @@ import { GoogleDrive, Mega, iCloud } from '@sd/assets/images'; import clsx from 'clsx'; -import { DeviceMobile, HardDrives, Icon, Laptop, User } from 'phosphor-react'; +import { Icon, User } from 'phosphor-react'; import { tw } from '@sd/ui'; -import { SubtleButton, SubtleButtonContainer } from '~/components/SubtleButton'; +import { SubtleButton, SubtleButtonContainer } from '~/components'; import { OperatingSystem } from '~/util/Platform'; import classes from './spacedrop.module.scss'; @@ -164,9 +164,7 @@ export const Component = () => { <> {/* */}
-
- -
+
); diff --git a/interface/app/onboarding/alpha.tsx b/interface/app/onboarding/alpha.tsx index c1cdba063..5d561440b 100644 --- a/interface/app/onboarding/alpha.tsx +++ b/interface/app/onboarding/alpha.tsx @@ -12,7 +12,7 @@ export default function OnboardingAlpha() { Alpha Background
-
+
Spacedrive

Spacedrive

diff --git a/interface/hooks/useCounter.ts b/interface/hooks/useCounter.ts index d9e01e249..ae5fbc290 100644 --- a/interface/hooks/useCounter.ts +++ b/interface/hooks/useCounter.ts @@ -33,7 +33,13 @@ type UseCounterProps = { saveState?: boolean; }; -const useCounter = ({ name, start = 0, end, duration = 2, saveState = true }: UseCounterProps) => { +export const useCounter = ({ + name, + start = 0, + end, + duration = 2, + saveState = true +}: UseCounterProps) => { const { lastValue, setLastValue } = useCounterState(name); if (saveState && lastValue) { @@ -60,5 +66,3 @@ const useCounter = ({ name, start = 0, end, duration = 2, saveState = true }: Us return value; }; - -export default useCounter; diff --git a/interface/hooks/useExplorerTopBarOptions.tsx b/interface/hooks/useExplorerTopBarOptions.tsx index da673fd04..d41595cf8 100644 --- a/interface/hooks/useExplorerTopBarOptions.tsx +++ b/interface/hooks/useExplorerTopBarOptions.tsx @@ -12,8 +12,8 @@ import { } from 'phosphor-react'; import OptionsPanel from '~/app/$libraryId/Explorer/OptionsPanel'; import { TOP_BAR_ICON_STYLE, ToolOption } from '~/app/$libraryId/TopBar'; -import { getExplorerStore, useExplorerStore } from './useExplorerStore'; import { KeyManager } from '../app/$libraryId/KeyManager'; +import { getExplorerStore, useExplorerStore } from './useExplorerStore'; export const useExplorerTopBarOptions = () => { const explorerStore = useExplorerStore(); diff --git a/packages/ui/src/RadioGroup.tsx b/packages/ui/src/RadioGroup.tsx index 46725d4df..aabd2ad4c 100644 --- a/packages/ui/src/RadioGroup.tsx +++ b/packages/ui/src/RadioGroup.tsx @@ -3,7 +3,7 @@ import { cx } from 'class-variance-authority'; import clsx from 'clsx'; import { forwardRef } from 'react'; -export interface RootProps extends RadioGroup.RadioGroupProps { } +export interface RootProps extends RadioGroup.RadioGroupProps {} export const Root = forwardRef( ({ children, className, ...props }, ref) => { return ( @@ -18,7 +18,7 @@ export const Root = forwardRef( // RadioGroup.Item // )`rounded-md border border-app-line bg-app-box px-4 py-2 flex items-center space-x-2`; -export interface ItemProps extends RadioGroup.RadioGroupItemProps { } +export interface ItemProps extends RadioGroup.RadioGroupItemProps {} export const Item = ({ children, ...props }: ItemProps) => { return (