Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cypress/support/document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as Y from 'yjs';
export interface FromBlockJSON {
type: string;
children: FromBlockJSON[];
data: Record<string, number | string | boolean>;
data: Record<string, number | string | boolean | null>;
text: Op[];
}

Expand Down
31 changes: 18 additions & 13 deletions src/@types/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@
"openMenu": "Click to open menu",
"dragRow": "Drag to reorder the row",
"viewDataBase": "View database",
"referencePage": "This {name} is referenced",
"referencePage": "This {{name}} is referenced",
"addBlockBelow": "Add a block below",
"aiGenerate": "Generate"
},
Expand Down Expand Up @@ -508,6 +508,8 @@
"namespaceLengthAtLeast2Characters": "The namespace must be at least 2 characters long",
"onlyWorkspaceOwnerCanUpdateNamespace": "Only workspace owner can update the namespace",
"onlyWorkspaceOwnerCanRemoveHomepage": "Only workspace owner can remove the homepage",
"onlyWorkspaceOwnerCanChangeHomepage": "Only workspace owner can change the homepage",
"onlyProCanSetHomepage": "Only Pro Plan workspace owner can set the homepage",
"setHomepageFailed": "Failed to set homepage",
"namespaceTooLong": "The namespace is too long, please try another one",
"namespaceTooShort": "The namespace is too short, please try another one",
Expand Down Expand Up @@ -1522,7 +1524,7 @@
"cannotFindCreatableField": "Cannot find a suitable field to sort by",
"deleteAllSorts": "Delete all sorts",
"addSort": "Add sort",
"sortsActive": "Cannot {intention} while sorting",
"sortsActive": "Cannot {{intention}} while sorting",
"removeSorting": "Would you like to remove all the sorts in this view and continue?",
"fieldInUse": "You are already sorting by this field"
},
Expand Down Expand Up @@ -1732,7 +1734,7 @@
"toggleList": "Toggle list",
"emptyToggleHeading": "Empty toggle h{}. Click to add content.",
"emptyToggleList": "Empty toggle list. Click to add content.",
"emptyToggleHeadingWeb": "Empty toggle h{level}. Click to add content",
"emptyToggleHeadingWeb": "Empty toggle h{{level}}. Click to add content",
"quoteList": "Quote list",
"numberedList": "Numbered list",
"bulletedList": "Bulleted list",
Expand Down Expand Up @@ -2169,8 +2171,8 @@
},
"unSupportBlock": "The current version does not support this Block.",
"views": {
"deleteContentTitle": "Are you sure want to delete the {pageType}?",
"deleteContentCaption": "if you delete this {pageType}, you can restore it from the trash."
"deleteContentTitle": "Are you sure want to delete the {{pageType}}?",
"deleteContentCaption": "if you delete this {{pageType}}, you can restore it from the trash."
},
"colors": {
"custom": "Custom",
Expand Down Expand Up @@ -2676,8 +2678,8 @@
"signInError": "Sign in error",
"login": "Sign up or log in",
"fileBlock": {
"uploadedAt": "Uploaded on {time}",
"linkedAt": "Link added on {time}",
"uploadedAt": "Uploaded on {{time}}",
"linkedAt": "Link added on {{time}}",
"empty": "Upload or embed a file",
"uploadFailed": "Upload failed, please try again",
"retry": "Retry"
Expand Down Expand Up @@ -2745,7 +2747,7 @@
"featured": "PIN to Featured",
"relatedTemplates": "Related Templates",
"requiredField": "{field} is required",
"addCategory": "Add \"{category}\"",
"addCategory": "Add \"{{category}}\"",
"addNewCategory": "Add new category",
"addNewCreator": "Add new creator",
"deleteCategory": "Delete category",
Expand Down Expand Up @@ -2785,7 +2787,7 @@
"addRelatedTemplate": "Add related template",
"removeRelatedTemplate": "Remove related template",
"uploadAvatar": "Upload avatar",
"searchInCategory": "Search in {category}",
"searchInCategory": "Search in {{category}}",
"label": "Templates"
},
"fileDropzone": {
Expand Down Expand Up @@ -2823,7 +2825,7 @@
"alreadyAccepted": "You've already accepted the invitation",
"errorModal": {
"title": "Something went wrong",
"description": "Your current account {email} may not have access to this workspace. Please log in with the correct account or contact the workspace owner for help.",
"description": "Your current account {{email}} may not have access to this workspace. Please log in with the correct account or contact the workspace owner for help.",
"contactOwner": "Contact owner",
"close": "Back to home",
"changeAccount": "Change account"
Expand Down Expand Up @@ -2865,7 +2867,7 @@
},
"upgradePlanModal": {
"title": "Upgrade to Pro",
"message": "{name} has reached the free member limit. Upgrade to the Pro Plan to invite more members.",
"message": "{{name}} has reached the free member limit. Upgrade to the Pro Plan to invite more members.",
"upgradeSteps": "How to upgrade your plan on AppFlowy:",
"step1": "1. Go to Settings",
"step2": "2. Click on 'Plan'",
Expand Down Expand Up @@ -2945,7 +2947,7 @@
"upgrade": "upgrade",
"addEmail": "[email protected], [email protected]...",
"requestInvites": "Send invites",
"inviteAlready": "You've already invited this email: {email}",
"inviteAlready": "You've already invited this email: {{email}}",
"inviteSuccess": "Invitation sent successfully",
"description": "Input emails below with commas between them. Charges are based on member count.",
"emails": "Email"
Expand Down Expand Up @@ -3042,5 +3044,8 @@
"memberCount_many": "{{count}} members",
"memberCount_other": "{{count}} members",
"aiMatch": "AI match",
"titleMatch": "Title match"
"titleMatch": "Title match",
"namespace": "Namespace",
"manageNamespaceDescription": "Manage your namespace and homepage",
"homepage": "Homepage"
}
124 changes: 122 additions & 2 deletions src/application/services/js-services/http/http_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ import {
CreateSpacePayload,
UpdateSpacePayload,
Role,
WorkspaceMember, QuickNote, QuickNoteEditorData, CreateWorkspacePayload, UpdateWorkspacePayload,
WorkspaceMember,
QuickNote,
QuickNoteEditorData,
CreateWorkspacePayload,
UpdateWorkspacePayload,
PublishViewPayload,
UploadPublishNamespacePayload,
} from '@/application/types';
import { GlobalComment, Reaction } from '@/application/comment.type';
import { initGrantService, refreshToken } from '@/application/services/js-services/http/gotrue';
Expand Down Expand Up @@ -328,6 +334,48 @@ export async function getUserWorkspaceInfo (): Promise<{
return Promise.reject(data);
}

export async function publishView (workspaceId: string, viewId: string, payload?: PublishViewPayload) {
const url = `/api/workspace/${workspaceId}/page-view/${viewId}/publish`;
const response = await axiosInstance?.post<{
code: number;
message: string;
}>(url, payload);

if (response?.data.code === 0) {
return;
}

return Promise.reject(response?.data);
}

export async function unpublishView (workspaceId: string, viewId: string) {
const url = `/api/workspace/${workspaceId}/page-view/${viewId}/unpublish`;
const response = await axiosInstance?.post<{
code: number;
message: string;
}>(url);

if (response?.data.code === 0) {
return;
}

return Promise.reject(response?.data);
}

export async function updatePublishNamespace (workspaceId: string, payload: UploadPublishNamespacePayload) {
const url = `/api/workspace/${workspaceId}/publish-namespace`;
const response = await axiosInstance?.put<{
code: number;
message: string;
}>(url, payload);

if (response?.data.code === 0) {
return;
}

return Promise.reject(response?.data);
}

export async function getPublishViewMeta (namespace: string, publishName: string) {
const url = `/api/workspace/v1/published/${namespace}/${publishName}`;
const response = await axiosInstance?.get<{
Expand Down Expand Up @@ -485,12 +533,15 @@ export async function getPublishView (publishNamespace: string, publishName: str
}

export async function getPublishInfoWithViewId (viewId: string) {
const url = `/api/workspace/published-info/${viewId}`;
const url = `/api/workspace/v1/published-info/${viewId}`;
const response = await axiosInstance?.get<{
code: number;
data?: {
namespace: string;
publish_name: string;
publisher_email: string;
view_id: string;
publish_timestamp: string;
};
message: string;
}>(url);
Expand Down Expand Up @@ -596,6 +647,75 @@ export async function getView (workspaceId: string, viewId: string, depth: numbe
return Promise.reject(data);
}

export async function getPublishNamespace (workspaceId: string) {
const url = `/api/workspace/${workspaceId}/publish-namespace`;
const response = await axiosInstance?.get<{
code: number;
data?: string;
message: string;
}>(url);

const data = response?.data;

if (data?.code === 0 && data.data) {
return data.data;
}

return Promise.reject(data);
}

export async function getPublishHomepage (workspaceId: string) {
const url = `/api/workspace/${workspaceId}/publish-default`;
const response = await axiosInstance?.get<{
code: number;
data?: {
namespace: string;
publish_name: string;
publisher_email: string;
view_id: string;
};
message: string;
}>(url);

const data = response?.data;

if (data?.code === 0 && data.data) {
return data.data;
}

return Promise.reject(data);
}

export async function updatePublishHomepage (workspaceId: string, viewId: string) {
const url = `/api/workspace/${workspaceId}/publish-default`;
const response = await axiosInstance?.put<{
code: number;
message: string;
}>(url, {
view_id: viewId,
});

if (response?.data.code === 0) {
return;
}

return Promise.reject(response?.data);
}

export async function removePublishHomepage (workspaceId: string) {
const url = `/api/workspace/${workspaceId}/publish-default`;
const response = await axiosInstance?.delete<{
code: number;
message: string;
}>(url);

if (response?.data.code === 0) {
return;
}

return Promise.reject(response?.data);
}

export async function getPublishOutline (publishNamespace: string) {
const url = `/api/workspace/published-outline/${publishNamespace}`;
const response = await axiosInstance?.get<{
Expand Down
49 changes: 46 additions & 3 deletions src/application/services/js-services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ import {
import {
CreatePagePayload, CreateSpacePayload, CreateWorkspacePayload,
DatabaseRelations,
DuplicatePublishView, QuickNoteEditorData,
DuplicatePublishView, PublishViewPayload, QuickNoteEditorData,
SubscriptionInterval, SubscriptionPlan,
Types, UpdatePagePayload, UpdateSpacePayload, UpdateWorkspacePayload, WorkspaceMember,
Types, UpdatePagePayload, UpdateSpacePayload, UpdateWorkspacePayload, UploadPublishNamespacePayload, WorkspaceMember,
YjsEditorKey,
} from '@/application/types';
import { applyYDoc } from '@/application/ydoc/apply';
Expand Down Expand Up @@ -65,6 +65,43 @@ export class AFClientService implements AFService {
return this.clientId;
}

async publishView (workspaceId: string, viewId: string, payload?: PublishViewPayload) {
if (this.publishViewInfo.has(viewId)) {
this.publishViewInfo.delete(viewId);
}

return APIService.publishView(workspaceId, viewId, payload);
}

async unpublishView (workspaceId: string, viewId: string) {
if (this.publishViewInfo.has(viewId)) {
this.publishViewInfo.delete(viewId);
}

return APIService.unpublishView(workspaceId, viewId);
}

async updatePublishNamespace (workspaceId: string, payload: UploadPublishNamespacePayload) {
this.publishViewInfo.clear();
return APIService.updatePublishNamespace(workspaceId, payload);
}

async getPublishNamespace (workspaceId: string) {
return APIService.getPublishNamespace(workspaceId);
}

async getPublishHomepage (workspaceId: string) {
return APIService.getPublishHomepage(workspaceId);
}

async updatePublishHomepage (workspaceId: string, viewId: string) {
return APIService.updatePublishHomepage(workspaceId, viewId);
}

async removePublishHomepage (workspaceId: string) {
return APIService.removePublishHomepage(workspaceId);
}

async getPublishViewMeta (namespace: string, publishName: string) {
const name = `${namespace}_${publishName}`;

Expand Down Expand Up @@ -165,6 +202,9 @@ export class AFClientService implements AFService {
return this.publishViewInfo.get(viewId) as {
namespace: string;
publishName: string;
publisherEmail: string;
viewId: string;
publishedAt: string;
};
}

Expand All @@ -179,6 +219,9 @@ export class AFClientService implements AFService {
const data = {
namespace,
publishName: info.publish_name,
publisherEmail: info.publisher_email,
viewId: info.view_id,
publishedAt: info.publish_timestamp,
};

this.publishViewInfo.set(viewId, data);
Expand Down Expand Up @@ -569,7 +612,7 @@ export class AFClientService implements AFService {
return APIService.deleteQuickNote(workspaceId, id);
}

searchWorkspace(workspaceId: string, query: string) {
searchWorkspace (workspaceId: string, query: string) {
return APIService.searchWorkspace(workspaceId, query);
}
}
Loading
Loading