feat(core): support share edgeless mode (#4856)

Close #3287

<!--
copilot:all
-->
### <samp>🤖 Generated by Copilot at d3fdf86</samp>

### Summary
📄🚀🔗

<!--
1.  📄 - This emoji represents the page and edgeless modes of sharing a page, as well as the GraphQL operations and types related to public pages.
2.  🚀 - This emoji represents the functionality of publishing and revoking public pages, as well as the confirmation modal and the notifications for the user.
3.  🔗 - This emoji represents the sharing URL and the query parameter for the share mode, as well as the hooks and functions that generate and use the URL.
-->
This pull request adds a feature to the frontend component of AFFiNE that allows the user to share a page in either `page` or `edgeless` mode, which affects the appearance and functionality of the page. It also adds the necessary GraphQL operations, types, and schema to support this feature in the backend, and updates the tests and the storybook stories accordingly.

*  Modify the `useIsSharedPage` hook to accept an optional `shareMode` argument and use the `getWorkspacePublicPagesQuery`, `publishPageMutation`, and `revokePublicPageMutation` from `@affine/graphql`
This commit is contained in:
JimmFly
2023-11-15 07:49:25 +00:00
committed by LongYinan
parent e7e617a791
commit ddd7cab414
39 changed files with 800 additions and 332 deletions

View File

@@ -0,0 +1,8 @@
query getWorkspacePublicPages($workspaceId: String!) {
workspace(id: $workspaceId) {
publicPages {
id
mode
}
}
}

View File

@@ -1,5 +0,0 @@
query getWorkspaceSharedPages($workspaceId: String!) {
workspace(id: $workspaceId) {
sharedPages
}
}

View File

@@ -320,15 +320,18 @@ query getWorkspacePublicById($id: String!) {
}`,
};
export const getWorkspaceSharedPagesQuery = {
id: 'getWorkspaceSharedPagesQuery' as const,
operationName: 'getWorkspaceSharedPages',
export const getWorkspacePublicPagesQuery = {
id: 'getWorkspacePublicPagesQuery' as const,
operationName: 'getWorkspacePublicPages',
definitionName: 'workspace',
containsFile: false,
query: `
query getWorkspaceSharedPages($workspaceId: String!) {
query getWorkspacePublicPages($workspaceId: String!) {
workspace(id: $workspaceId) {
sharedPages
publicPages {
id
mode
}
}
}`,
};
@@ -428,6 +431,20 @@ query prices {
}`,
};
export const publishPageMutation = {
id: 'publishPageMutation' as const,
operationName: 'publishPage',
definitionName: 'publishPage',
containsFile: false,
query: `
mutation publishPage($workspaceId: String!, $pageId: String!, $mode: PublicPageMode = Page) {
publishPage(workspaceId: $workspaceId, pageId: $pageId, mode: $mode) {
id
mode
}
}`,
};
export const removeAvatarMutation = {
id: 'removeAvatarMutation' as const,
operationName: 'removeAvatar',
@@ -469,14 +486,18 @@ mutation revokeMemberPermission($workspaceId: String!, $userId: String!) {
}`,
};
export const revokePageMutation = {
id: 'revokePageMutation' as const,
operationName: 'revokePage',
definitionName: 'revokePage',
export const revokePublicPageMutation = {
id: 'revokePublicPageMutation' as const,
operationName: 'revokePublicPage',
definitionName: 'revokePublicPage',
containsFile: false,
query: `
mutation revokePage($workspaceId: String!, $pageId: String!) {
revokePage(workspaceId: $workspaceId, pageId: $pageId)
mutation revokePublicPage($workspaceId: String!, $pageId: String!) {
revokePublicPage(workspaceId: $workspaceId, pageId: $pageId) {
id
mode
public
}
}`,
};
@@ -537,17 +558,6 @@ mutation setWorkspacePublicById($id: ID!, $public: Boolean!) {
}`,
};
export const sharePageMutation = {
id: 'sharePageMutation' as const,
operationName: 'sharePage',
definitionName: 'sharePage',
containsFile: false,
query: `
mutation sharePage($workspaceId: String!, $pageId: String!) {
sharePage(workspaceId: $workspaceId, pageId: $pageId)
}`,
};
export const signInMutation = {
id: 'signInMutation' as const,
operationName: 'signIn',

View File

@@ -0,0 +1,10 @@
mutation publishPage(
$workspaceId: String!
$pageId: String!
$mode: PublicPageMode = Page
) {
publishPage(workspaceId: $workspaceId, pageId: $pageId, mode: $mode) {
id
mode
}
}

View File

@@ -1,3 +0,0 @@
mutation revokePage($workspaceId: String!, $pageId: String!) {
revokePage(workspaceId: $workspaceId, pageId: $pageId)
}

View File

@@ -0,0 +1,7 @@
mutation revokePublicPage($workspaceId: String!, $pageId: String!) {
revokePublicPage(workspaceId: $workspaceId, pageId: $pageId) {
id
mode
public
}
}

View File

@@ -1,3 +0,0 @@
mutation sharePage($workspaceId: String!, $pageId: String!) {
sharePage(workspaceId: $workspaceId, pageId: $pageId)
}

View File

@@ -340,13 +340,20 @@ export type GetWorkspacePublicByIdQuery = {
workspace: { __typename?: 'WorkspaceType'; public: boolean };
};
export type GetWorkspaceSharedPagesQueryVariables = Exact<{
export type GetWorkspacePublicPagesQueryVariables = Exact<{
workspaceId: Scalars['String']['input'];
}>;
export type GetWorkspaceSharedPagesQuery = {
export type GetWorkspacePublicPagesQuery = {
__typename?: 'Query';
workspace: { __typename?: 'WorkspaceType'; sharedPages: Array<string> };
workspace: {
__typename?: 'WorkspaceType';
publicPages: Array<{
__typename?: 'WorkspacePage';
id: string;
mode: PublicPageMode;
}>;
};
};
export type GetWorkspaceQueryVariables = Exact<{
@@ -422,6 +429,21 @@ export type PricesQuery = {
}>;
};
export type PublishPageMutationVariables = Exact<{
workspaceId: Scalars['String']['input'];
pageId: Scalars['String']['input'];
mode?: InputMaybe<PublicPageMode>;
}>;
export type PublishPageMutation = {
__typename?: 'Mutation';
publishPage: {
__typename?: 'WorkspacePage';
id: string;
mode: PublicPageMode;
};
};
export type RemoveAvatarMutationVariables = Exact<{ [key: string]: never }>;
export type RemoveAvatarMutation = {
@@ -455,14 +477,19 @@ export type RevokeMemberPermissionMutation = {
revoke: boolean;
};
export type RevokePageMutationVariables = Exact<{
export type RevokePublicPageMutationVariables = Exact<{
workspaceId: Scalars['String']['input'];
pageId: Scalars['String']['input'];
}>;
export type RevokePageMutation = {
export type RevokePublicPageMutation = {
__typename?: 'Mutation';
revokePage: boolean;
revokePublicPage: {
__typename?: 'WorkspacePage';
id: string;
mode: PublicPageMode;
public: boolean;
};
};
export type SendChangeEmailMutationVariables = Exact<{
@@ -516,13 +543,6 @@ export type SetWorkspacePublicByIdMutation = {
updateWorkspace: { __typename?: 'WorkspaceType'; id: string };
};
export type SharePageMutationVariables = Exact<{
workspaceId: Scalars['String']['input'];
pageId: Scalars['String']['input'];
}>;
export type SharePageMutation = { __typename?: 'Mutation'; sharePage: boolean };
export type SignInMutationVariables = Exact<{
email: Scalars['String']['input'];
password: Scalars['String']['input'];
@@ -683,9 +703,9 @@ export type Queries =
response: GetWorkspacePublicByIdQuery;
}
| {
name: 'getWorkspaceSharedPagesQuery';
variables: GetWorkspaceSharedPagesQueryVariables;
response: GetWorkspaceSharedPagesQuery;
name: 'getWorkspacePublicPagesQuery';
variables: GetWorkspacePublicPagesQueryVariables;
response: GetWorkspacePublicPagesQuery;
}
| {
name: 'getWorkspaceQuery';
@@ -774,6 +794,11 @@ export type Mutations =
variables: LeaveWorkspaceMutationVariables;
response: LeaveWorkspaceMutation;
}
| {
name: 'publishPageMutation';
variables: PublishPageMutationVariables;
response: PublishPageMutation;
}
| {
name: 'removeAvatarMutation';
variables: RemoveAvatarMutationVariables;
@@ -790,9 +815,9 @@ export type Mutations =
response: RevokeMemberPermissionMutation;
}
| {
name: 'revokePageMutation';
variables: RevokePageMutationVariables;
response: RevokePageMutation;
name: 'revokePublicPageMutation';
variables: RevokePublicPageMutationVariables;
response: RevokePublicPageMutation;
}
| {
name: 'sendChangeEmailMutation';
@@ -819,11 +844,6 @@ export type Mutations =
variables: SetWorkspacePublicByIdMutationVariables;
response: SetWorkspacePublicByIdMutation;
}
| {
name: 'sharePageMutation';
variables: SharePageMutationVariables;
response: SharePageMutation;
}
| {
name: 'signInMutation';
variables: SignInMutationVariables;