Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/JS-5093: Publishing #988

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
a8c5c08
add publish menu button
ra3orblade Aug 21, 2024
e04e9cd
refactoring
ra3orblade Aug 21, 2024
24b8c0a
refactoring
ra3orblade Aug 21, 2024
7a98e10
fix publish action state
ra3orblade Aug 21, 2024
daeae38
Merge branch 'main' of github.com:anyproto/anytype-ts into feature/pu…
ra3orblade Aug 23, 2024
5663593
Merge branch 'main' of github.com:anyproto/anytype-ts into feature/pu…
ra3orblade Aug 23, 2024
9aa5a8c
Merge branch 'main' of github.com:anyproto/anytype-ts into feature/pu…
ra3orblade Aug 24, 2024
be1426c
merge
ra3orblade Oct 2, 2024
7262098
Add publish
mcrakhman Oct 10, 2024
ebe1832
map ObjectPublish and call
zarkone Oct 10, 2024
59c2f4a
copy published url to clipboard and show in toast
zarkone Oct 11, 2024
83cdd8b
workaround object show
zarkone Oct 11, 2024
b4f0419
Merge branch 'main' of github.com:anyproto/anytype-ts into publish-test
ra3orblade Oct 12, 2024
6dac777
code review
ra3orblade Oct 12, 2024
12ec6b6
Merge branch 'feature/chat' of github.com:anyproto/anytype-ts into pu…
ra3orblade Oct 14, 2024
478002f
fix error message if
zarkone Oct 14, 2024
b752486
add nix flakes for dev env
zarkone Oct 15, 2024
01c5d1c
merge
ra3orblade Oct 16, 2024
e765673
Merge branch 'feature/chat' of github.com:anyproto/anytype-ts into pu…
ra3orblade Oct 16, 2024
508d48f
Merge branch 'feature/chat' into publish-test
zarkone Oct 18, 2024
a101897
Merge branch 'main' into publish-test
zarkone Oct 23, 2024
a60aa6a
Merge branch 'main' into publish-test
zarkone Oct 24, 2024
cb743fe
send pageId instead of json content
zarkone Oct 24, 2024
4610102
Merge branch 'main' of github.com:anyproto/anytype-ts into publish-test
ra3orblade Oct 25, 2024
22a0694
Merge branch 'main' of github.com:anyproto/anytype-ts into publish-test
ra3orblade Oct 29, 2024
abc9f9c
Merge branch 'main' into publish-test
zarkone Nov 12, 2024
33b97c3
Merge branch 'main' into publish-test
zarkone Nov 12, 2024
20cbb8e
flakes, add pixbuf for new electron
zarkone Nov 12, 2024
b160e44
log error
zarkone Nov 12, 2024
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
59 changes: 59 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

76 changes: 76 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# nix-ld should be enabled in configuration.nix:
# programs.nix-ld.enable = true;
# programs.nix-ld.libraries = with pkgs; [
# gtk3
# # Add any missing dynamic libraries for unpackaged programs
# # here, NOT in environment.systemPackages
# ];

{
description = "";
inputs.nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1.0.tar.gz";
inputs.flake-utils.url = "github:numtide/flake-utils";

outputs = { self, nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {
inherit system;
config = { allowUnfree = true; };
};
deps = [
pkgs.appimage-run
# commit hook
pkgs.husky
# build deps
pkgs.libxcrypt
pkgs.libsecret
pkgs.pkg-config
pkgs.jq
pkgs.nodejs_22

# keytar build fails on npm install because python312 has distutils removed
pkgs.python311

# electron binary launch deps.
# see also https://nix.dev/guides/faq#how-to-run-non-nix-executables
pkgs.glib
pkgs.nss
pkgs.nspr
pkgs.dbus
pkgs.atk
pkgs.cups
pkgs.libdrm
pkgs.gtk3
pkgs.adwaita-icon-theme
pkgs.pango
pkgs.cairo
pkgs.xorg.libX11
pkgs.xorg.libX11
pkgs.xorg.libXcomposite
pkgs.xorg.libXdamage
pkgs.xorg.libXext
pkgs.xorg.libXfixes
pkgs.xorg.libXrandr
pkgs.mesa
pkgs.expat
pkgs.libxkbcommon
pkgs.xorg.libxcb
pkgs.alsa-lib
pkgs.libGL
];
XDG_ICONS_PATH = "${pkgs.hicolor-icon-theme}/share:${pkgs.adwaita-icon-theme}/share";
in {
devShell = pkgs.mkShell {
name = "anytype-ts-dev";
SERVER_PORT = 9090;
ANY_SYNC_NETWORK = "/home/zarkone/anytype/local-network-config.yml";
LD_LIBRARY_PATH = "${pkgs.lib.strings.makeLibraryPath deps}";
nativeBuildInputs = deps;
shellHook = ''
# fixes "No GSettings schemas" error
export XDG_DATA_DIRS=$GSETTINGS_SCHEMAS_PATH:$XDG_ICONS_PATH:$XDG_DATA_DIRS
'';
};

});
}
1 change: 1 addition & 0 deletions src/json/text.json
Original file line number Diff line number Diff line change
Expand Up @@ -1521,6 +1521,7 @@
"menuObjectPrint": "Print",
"menuObjectSearchOnPage": "Search in Object",
"menuObjectExport": "Export",
"menuObjectPublish": "Publish to Web",
"menuObjectReloadFromSource": "Reload from Source",
"menuObjectUseAsTemplate": "Use as Template",
"menuObjectUnlockPage": "Unlock Object",
Expand Down
19 changes: 14 additions & 5 deletions src/ts/component/menu/object.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class MenuObject extends React.Component<I.Menu> {
};

getSections () {
const { config } = S.Common;
const { param } = this.props;
const { data } = param;
const { blockId, rootId, isFilePreview } = data;
Expand All @@ -105,16 +106,17 @@ class MenuObject extends React.Component<I.Menu> {
let template = null;
let setDefaultTemplate = null;

let pageExport = { id: 'pageExport', icon: 'export', name: translate('menuObjectExport') };
let print = { id: 'print', name: translate('menuObjectPrint'), caption: `${cmd} + P` };
let linkTo = { id: 'linkTo', icon: 'linkTo', name: translate('commonLinkTo'), arrow: true };
let addCollection = { id: 'addCollection', icon: 'collection', name: translate('commonAddToCollection'), arrow: true };
let search = { id: 'search', name: translate('menuObjectSearchOnPage'), caption: `${cmd} + F` };
let history = { id: 'history', name: translate('commonVersionHistory'), caption: (U.Common.isPlatformMac() ? `${cmd} + Y` : `Ctrl + H`) };
let createWidget = { id: 'createWidget', icon: 'createWidget', name: translate('menuObjectCreateWidget') };
let pageCopy = { id: 'pageCopy', icon: 'copy', name: translate('commonDuplicate') };
let pageLink = { id: 'pageLink', icon: 'link', name: translate('commonCopyLink') };
let pageReload = { id: 'pageReload', icon: 'reload', name: translate('menuObjectReloadFromSource') };
let createWidget = { id: 'createWidget', icon: 'createWidget', name: translate('menuObjectCreateWidget') };
let pageExport = { id: 'pageExport', icon: 'export', name: translate('menuObjectExport') };
let pagePublish = { id: 'pagePublish', icon: 'publish', name: translate('menuObjectPublish') };
let downloadFile = { id: 'downloadFile', icon: 'download', name: translate('commonDownload') };
let openFile = { id: 'openFile', icon: 'expand', name: translate('menuObjectDownloadOpen') };

Expand Down Expand Up @@ -179,6 +181,7 @@ class MenuObject extends React.Component<I.Menu> {
const allowedWidget = canWrite && !object.isArchived && !S.Block.checkBlockTypeExists(rootId);
const allowedExport = !isFilePreview && !U.Object.isChatLayout(object.layout);
const allowedPrint = !isFilePreview;
const allowedPublish = config.experimental;
const allowedDownloadFile = U.Object.isInFileLayouts(object.layout);
const allowedOpenFile = U.Object.isInFileLayouts(object.layout);

Expand All @@ -198,8 +201,9 @@ class MenuObject extends React.Component<I.Menu> {
if (!allowedAddCollection) addCollection = null;
if (!allowedExport) pageExport = null;
if (!allowedPrint) print = null;
if (!allowedDownloadFile) downloadFile = null;
if (!allowedOpenFile) openFile = null;
if (!allowedPublish) pagePublish = null;
if (!allowedDownloadFile) downloadFile = null;
if (!allowedOpenFile) openFile = null;

if (!canWrite) {
template = null;
Expand Down Expand Up @@ -238,7 +242,7 @@ class MenuObject extends React.Component<I.Menu> {
{ children: [ linkTo, addCollection, template ] },
{ children: [ search, history, pageCopy, archive ] },
{ children: [ pageLink, pageReload ] },
{ children: [ print, pageExport ] },
{ children: [ print, pageExport, pagePublish ] },
];
};

Expand Down Expand Up @@ -427,6 +431,11 @@ class MenuObject extends React.Component<I.Menu> {
S.Popup.open('export', { data: { objectIds: [ rootId ], allowHtml: true, route } });
break;
};

case 'pagePublish': {
Action.publish(object.id);
break;
};

case 'pageArchive': {
Action.archive([ object.id ], () => {
Expand Down
4 changes: 1 addition & 3 deletions src/ts/component/page/elements/head/editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@ const PageHeadEditor = observer(class PageHeadEditor extends React.Component<Pro
const header = S.Block.getLeaf(rootId, 'header');
const cover = new M.Block({ id: rootId + '-cover', type: I.BlockType.Cover, hAlign: object.layoutAlign, childrenIds: [], fields: {}, content: {} });
const icon: any = new M.Block({ id: rootId + '-icon', type: I.BlockType.IconPage, hAlign: object.layoutAlign, childrenIds: [], fields: {}, content: {} });
const isHuman = U.Object.isHumanLayout(object.layout);
const isParticipant = U.Object.isParticipantLayout(object.layout);

if (isHuman || isParticipant) {
if (U.Object.isInHumanLayouts(object.layout)) {
icon.type = I.BlockType.IconUser;
};

Expand Down
4 changes: 1 addition & 3 deletions src/ts/component/page/main/history/left.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ const HistoryLeft = observer(class HistoryLeft extends React.Component<Props> {
const cn = [ 'editorWrapper', check.className ];
const isSet = U.Object.isSetLayout(object.layout);
const isCollection = U.Object.isCollectionLayout(object.layout);
const isHuman = U.Object.isHumanLayout(object.layout);
const isParticipant = U.Object.isParticipantLayout(object.layout);

let head = null;
let children = S.Block.getChildren(rootId, rootId);
Expand All @@ -56,7 +54,7 @@ const HistoryLeft = observer(class HistoryLeft extends React.Component<Props> {
children = children.filter(it => it.isDataview());
check.withIcon = false;
} else
if (isHuman || isParticipant) {
if (U.Object.isInHumanLayouts(object.layout)) {
icon.type = I.BlockType.IconUser;
};

Expand Down
1 change: 0 additions & 1 deletion src/ts/interface/block/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ export interface Block {
isLayoutColumn?(): boolean;
isLayoutDiv?(): boolean;
isLayoutHeader?(): boolean;
isLayoutFooter?(): boolean;
isLayoutTableRows?(): boolean;
isLayoutTableColumns?(): boolean;

Expand Down
14 changes: 6 additions & 8 deletions src/ts/interface/block/layout.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { I } from 'Lib';

export enum LayoutStyle {
Row = 0,
Column = 1,
Div = 2,
Header = 3,
TableRows = 4,
TableColumns = 5,

Footer = 100,
Row = 0,
Column = 1,
Div = 2,
Header = 3,
TableRows = 4,
TableColumns = 5,
Comment on lines +4 to +9
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why to format it like that?

};

export interface ContentLayout {
Expand Down
12 changes: 12 additions & 0 deletions src/ts/lib/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,18 @@ class Action {
analytics.event('ThemeSet', { id });
};

publish (objectId: string) {
C.ObjectPublish(S.Common.space, objectId, (message: any) => {
if (message.error.code) {
return;
};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can just skip brackets and make in online.
if (message.error.code) return

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not write one-line if clauses.


const { key, cid } = message;
const url = `http://localhost:8787/?cid=${cid}&key=${key}`;

U.Common.copyToast(translate('commonLink'), url);
});
};
};

export default new Action();
10 changes: 10 additions & 0 deletions src/ts/lib/api/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1358,6 +1358,16 @@ export const ObjectShow = (objectId: string, traceId: string, spaceId: string, c
});
};

export const ObjectPublish = (spaceId: string, objectId: string, callBack?: (message: any) => void) => {
const request = new Rpc.Object.Publish.Request();

request.setObjectid(objectId);
request.setSpaceid(spaceId);

dispatcher.request(ObjectPublish.name, request, callBack);
};


export const ObjectClose = (objectId: string, spaceId: string, callBack?: (message: any) => void) => {
const request = new Rpc.Object.Close.Request();

Expand Down
7 changes: 7 additions & 0 deletions src/ts/lib/api/response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,13 @@ export const ObjectShow = (response: Rpc.Object.Show.Response) => {
};
};

export const ObjectPublish = (response: Rpc.Object.Publish.Response) => {
return {
cid: response.getPublishcid(),
key: response.getPublishfilekey(),
};
};

Comment on lines +201 to +207
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

export const ObjectPublish = (response: Rpc.Object.Publish.Response) => ({
		cid: response.getPublishcid(),
		key: response.getPublishfilekey(),
})

I find it nicer

export const ObjectSearch = (response: Rpc.Object.Search.Response) => {
return {
records: (response.getRecordsList() || []).map(Decode.struct),
Expand Down
4 changes: 0 additions & 4 deletions src/ts/model/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,6 @@ class Block implements I.Block {
return this.isLayout() && (this.content.style == I.LayoutStyle.Header);
};

isLayoutFooter (): boolean {
return this.isLayout() && (this.content.style == I.LayoutStyle.Footer);
};

isLayoutTableRows (): boolean {
return this.isLayout() && (this.content.style == I.LayoutStyle.TableRows);
};
Expand Down
Loading