refactor: rename plugins to adapters (#2480)

This commit is contained in:
Himself65
2023-05-22 15:48:01 +08:00
parent 569d71886c
commit 01173babe6
30 changed files with 87 additions and 58 deletions
@@ -44,7 +44,6 @@ beforeAll(() => {
`/workspace/[workspaceId/${WorkspaceSubPath.ALL}`,
`/workspace/[workspaceId/${WorkspaceSubPath.SETTING}`,
`/workspace/[workspaceId/${WorkspaceSubPath.TRASH}`,
`/workspace/[workspaceId/${WorkspaceSubPath.FAVORITE}`,
'/workspace/[workspaceId]/[pageId]',
])
);
@@ -11,14 +11,15 @@ import { __unstableSchemas, AffineSchemas } from '@blocksuite/blocks/models';
import type { Page } from '@blocksuite/store';
import { assertExists } from '@blocksuite/store';
import { renderHook } from '@testing-library/react';
import { createStore, Provider } from 'jotai/index';
import { createStore, Provider } from 'jotai';
import { useRouter } from 'next/router';
import routerMock from 'next-router-mock';
import { createDynamicRouteParser } from 'next-router-mock/dynamic-routes';
import type { FC, PropsWithChildren } from 'react';
import { beforeAll, beforeEach, describe, expect, test, vi } from 'vitest';
import { LocalPlugin } from '../../adapters/local';
import { workspacesAtom } from '../../atoms';
import { LocalPlugin } from '../../plugins/local';
import { BlockSuiteWorkspace } from '../../shared';
import { WorkspaceSubPath } from '../../shared';
import {
@@ -37,7 +38,6 @@ beforeAll(() => {
`/workspace/[workspaceId/${WorkspaceSubPath.ALL}`,
`/workspace/[workspaceId/${WorkspaceSubPath.SETTING}`,
`/workspace/[workspaceId/${WorkspaceSubPath.TRASH}`,
`/workspace/[workspaceId/${WorkspaceSubPath.FAVORITE}`,
'/workspace/[workspaceId]/[pageId]',
])
);
@@ -45,10 +45,11 @@ beforeAll(() => {
async function getJotaiContext() {
const store = createStore();
const ProviderWrapper: React.FC<React.PropsWithChildren> =
function ProviderWrapper({ children }) {
return <Provider store={store}>{children}</Provider>;
};
const ProviderWrapper: FC<PropsWithChildren> = function ProviderWrapper({
children,
}) {
return <Provider store={store}>{children}</Provider>;
};
const workspaces = await store.get(workspacesAtom);
expect(workspaces.length).toBe(0);
return {
@@ -2,7 +2,7 @@ import { WorkspaceFlavour } from '@affine/workspace/type';
import { useRouter } from 'next/router';
import { useCallback } from 'react';
import { WorkspaceAdapters } from '../../plugins';
import { WorkspaceAdapters } from '../../adapters/workspace';
export function useAffineLogIn() {
const router = useRouter();
@@ -2,7 +2,7 @@ import { WorkspaceFlavour } from '@affine/workspace/type';
import { useRouter } from 'next/router';
import { useCallback } from 'react';
import { WorkspaceAdapters } from '../../plugins';
import { WorkspaceAdapters } from '../../adapters/workspace';
export function useAffineLogOut() {
const router = useRouter();
@@ -8,7 +8,7 @@ import {
} from '@affine/workspace/affine/login';
import useSWR from 'swr';
import { affineAuth } from '../../plugins/affine';
import { affineAuth } from '../../shared/apis';
const logger = new DebugLogger('auth-token');
+1 -1
View File
@@ -2,7 +2,7 @@ import type { Member } from '@affine/workspace/affine/api';
import { useCallback } from 'react';
import useSWR from 'swr';
import { QueryKey } from '../../plugins/affine/fetcher';
import { QueryKey } from '../../adapters/affine/fetcher';
import { affineApis } from '../../shared/apis';
export function useMembers(workspaceId: string) {
@@ -3,7 +3,7 @@ import type { AffineLegacyCloudWorkspace } from '@affine/workspace/type';
import { useCallback } from 'react';
import useSWR from 'swr';
import { QueryKey } from '../../plugins/affine/fetcher';
import { QueryKey } from '../../adapters/affine/fetcher';
import { affineApis } from '../../shared/apis';
export function useToggleWorkspacePublish(
@@ -1,6 +1,6 @@
import useSWR from 'swr';
import { QueryKey } from '../../plugins/affine/fetcher';
import { QueryKey } from '../../adapters/affine/fetcher';
export interface QueryEmailMember {
id: string;
@@ -12,7 +12,7 @@ import { WorkspaceFlavour } from '@affine/workspace/type';
import { useSetAtom } from 'jotai';
import { useCallback } from 'react';
import { affineAuth } from '../../plugins/affine';
import { affineAuth } from '../../shared/apis';
import { useTransformWorkspace } from '../use-transform-workspace';
export function useOnTransformWorkspace() {
@@ -4,7 +4,7 @@ import type { WorkspaceRegistry } from '@affine/workspace/type';
import { useSetAtom } from 'jotai';
import { useCallback } from 'react';
import { WorkspaceAdapters } from '../plugins';
import { WorkspaceAdapters } from '../adapters/workspace';
/**
* Transform workspace from one flavour to another
+2 -2
View File
@@ -8,9 +8,9 @@ import { nanoid } from '@blocksuite/store';
import { useAtomValue, useSetAtom } from 'jotai';
import { useCallback } from 'react';
import { LocalPlugin } from '../adapters/local';
import { WorkspaceAdapters } from '../adapters/workspace';
import { workspacesAtom } from '../atoms';
import { WorkspaceAdapters } from '../plugins';
import { LocalPlugin } from '../plugins/local';
import type { AllWorkspace } from '../shared';
export function useWorkspaces(): AllWorkspace[] {