From a8c5c080afdd7f03892013e0012433887401d03e Mon Sep 17 00:00:00 2001 From: Andrew Simachev Date: Wed, 21 Aug 2024 07:58:32 +0200 Subject: [PATCH 01/14] add publish menu button --- src/json/text.json | 1 + src/ts/component/menu/object.tsx | 19 ++++++++++++++----- src/ts/lib/action.ts | 8 ++++++++ 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/json/text.json b/src/json/text.json index 5c59347ee6..a598183804 100644 --- a/src/json/text.json +++ b/src/json/text.json @@ -1477,6 +1477,7 @@ "menuObjectPrint": "Print", "menuObjectSearchOnPage": "Search in Object", "menuObjectExport": "Export", + "menuObjectPublish": "Publish to Web", "menuObjectReloadFromSource": "Reload from Source", "menuObjectUseAsTemplate": "Use as Template", "menuObjectUnlockPage": "Unlock Object", diff --git a/src/ts/component/menu/object.tsx b/src/ts/component/menu/object.tsx index 6db5e039dd..b8635df08d 100644 --- a/src/ts/component/menu/object.tsx +++ b/src/ts/component/menu/object.tsx @@ -87,6 +87,7 @@ class MenuObject extends React.Component { }; getSections () { + const { config } = S.Common; const { param } = this.props; const { data } = param; const { blockId, rootId, isFilePreview } = data; @@ -105,18 +106,19 @@ class MenuObject extends React.Component { 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 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 download = { id: 'download', icon: 'download', name: translate('commonDownload') }; let open = { id: 'open', icon: 'expand', name: translate('menuObjectDownloadOpen') }; + 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 pageExport = { id: 'pageExport', icon: 'export', name: translate('menuObjectExport') }; + let pagePublish = { id: 'pagePublish', icon: 'publish', name: translate('menuObjectPublish') }; if (isTemplate) { template = { id: 'pageCreate', icon: 'template', name: translate('commonCreateObject') }; @@ -179,6 +181,7 @@ class MenuObject extends React.Component { const allowedPrint = !isFilePreview; const allowedDownload = U.Object.isInFileLayouts(object.layout); const allowedOpen = U.Object.isInFileLayouts(object.layout); + const allowedPublish = config.experimental; if (!allowedArchive) archive = null; if (!allowedLock) pageLock = null; @@ -198,6 +201,7 @@ class MenuObject extends React.Component { if (!allowedPrint) print = null; if (!allowedDownload) download = null; if (!allowedOpen) open = null; + if (!allowedPublish) pagePublish = null; if (!canWrite) { template = null; @@ -236,7 +240,7 @@ class MenuObject extends React.Component { { children: [ linkTo, addCollection, template ] }, { children: [ search, history, pageCopy, archive ] }, { children: [ pageLink, pageReload ] }, - { children: [ print, pageExport ] }, + { children: [ print, pageExport, pagePublish ] }, ]; }; @@ -424,6 +428,11 @@ class MenuObject extends React.Component { S.Popup.open('export', { data: { objectIds: [ rootId ], allowHtml: true, route } }); break; }; + + case 'pagePublish': { + Action.publish(object.id); + break; + }; case 'pageArchive': { Action.archive([ object.id ], () => onBack()); diff --git a/src/ts/lib/action.ts b/src/ts/lib/action.ts index 62f359dabf..43256df541 100644 --- a/src/ts/lib/action.ts +++ b/src/ts/lib/action.ts @@ -804,6 +804,14 @@ class Action { analytics.event('ThemeSet', { id }); }; + publish (id: string) { + C.ObjectShow(id, '', S.Common.space, (message: any) => { + if (!message.error.code) { + U.Common.clipboardCopy({ text: JSON.stringify(message.objectView) }); + }; + }); + }; + }; export default new Action(); From e04e9cdc92367320c3df330646b7832c038cd721 Mon Sep 17 00:00:00 2001 From: Andrew Simachev Date: Wed, 21 Aug 2024 08:11:09 +0200 Subject: [PATCH 02/14] refactoring --- src/ts/interface/block/index.ts | 1 - src/ts/interface/block/layout.ts | 14 ++++++-------- src/ts/model/block.ts | 4 ---- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/ts/interface/block/index.ts b/src/ts/interface/block/index.ts index 87a0663edf..2cb934ee26 100644 --- a/src/ts/interface/block/index.ts +++ b/src/ts/interface/block/index.ts @@ -152,7 +152,6 @@ export interface Block { isLayoutColumn?(): boolean; isLayoutDiv?(): boolean; isLayoutHeader?(): boolean; - isLayoutFooter?(): boolean; isLayoutTableRows?(): boolean; isLayoutTableColumns?(): boolean; diff --git a/src/ts/interface/block/layout.ts b/src/ts/interface/block/layout.ts index a6e8d6cee8..a64336f206 100644 --- a/src/ts/interface/block/layout.ts +++ b/src/ts/interface/block/layout.ts @@ -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, }; export interface ContentLayout { diff --git a/src/ts/model/block.ts b/src/ts/model/block.ts index f3db3dc0cd..d47d9e8f27 100644 --- a/src/ts/model/block.ts +++ b/src/ts/model/block.ts @@ -215,10 +215,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); }; From 24b8c0a9db1874040e3f963c423b725c9d494630 Mon Sep 17 00:00:00 2001 From: Andrew Simachev Date: Wed, 21 Aug 2024 11:42:11 +0200 Subject: [PATCH 03/14] refactoring --- src/ts/component/page/elements/head/editor.tsx | 4 +--- src/ts/component/page/main/history/left.tsx | 4 +--- src/ts/lib/action.ts | 12 +++++++++++- src/ts/lib/util/object.ts | 4 ++++ 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/ts/component/page/elements/head/editor.tsx b/src/ts/component/page/elements/head/editor.tsx index ab1b7e1a58..1c8de9f6c6 100644 --- a/src/ts/component/page/elements/head/editor.tsx +++ b/src/ts/component/page/elements/head/editor.tsx @@ -35,10 +35,8 @@ const PageHeadEditor = observer(class PageHeadEditor extends React.Component { 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); @@ -56,7 +54,7 @@ const HistoryLeft = observer(class HistoryLeft extends React.Component { children = children.filter(it => it.isDataview()); check.withIcon = false; } else - if (isHuman || isParticipant) { + if (U.Object.isInHumanLayouts(object.layout)) { icon.type = I.BlockType.IconUser; }; diff --git a/src/ts/lib/action.ts b/src/ts/lib/action.ts index 43256df541..7d7a6897b1 100644 --- a/src/ts/lib/action.ts +++ b/src/ts/lib/action.ts @@ -805,9 +805,19 @@ class Action { }; publish (id: string) { + const { gateway } = S.Common; + + let data: any = { + _meta: { + gateway, + }, + }; + C.ObjectShow(id, '', S.Common.space, (message: any) => { if (!message.error.code) { - U.Common.clipboardCopy({ text: JSON.stringify(message.objectView) }); + data = Object.assign(data, message.objectView); + + U.Common.clipboardCopy({ text: JSON.stringify(data) }); }; }); }; diff --git a/src/ts/lib/util/object.ts b/src/ts/lib/util/object.ts index 60b99707ba..9ce8175383 100644 --- a/src/ts/lib/util/object.ts +++ b/src/ts/lib/util/object.ts @@ -286,6 +286,10 @@ class UtilObject { return this.getPageLayouts().includes(layout); }; + isInHumanLayouts (layout: I.ObjectLayout): boolean { + return [ I.ObjectLayout.Human, I.ObjectLayout.Participant ].includes(layout); + }; + // --------------------------------------------------------- // isSetLayout (layout: I.ObjectLayout): boolean { From 7a98e1054a73b148d583c97a95189feae0015fec Mon Sep 17 00:00:00 2001 From: Andrew Simachev Date: Wed, 21 Aug 2024 12:22:31 +0200 Subject: [PATCH 04/14] fix publish action state --- src/ts/lib/action.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ts/lib/action.ts b/src/ts/lib/action.ts index 7d7a6897b1..2d1fa73cc8 100644 --- a/src/ts/lib/action.ts +++ b/src/ts/lib/action.ts @@ -813,7 +813,7 @@ class Action { }, }; - C.ObjectShow(id, '', S.Common.space, (message: any) => { + C.ObjectShow(id, 'publish', S.Common.space, (message: any) => { if (!message.error.code) { data = Object.assign(data, message.objectView); From 72620988f0e097d45e365289d75c75ee05ed6ad7 Mon Sep 17 00:00:00 2001 From: mcrakhman Date: Thu, 10 Oct 2024 15:57:35 +0200 Subject: [PATCH 05/14] Add publish --- src/ts/lib/action.ts | 5 +++-- src/ts/lib/api/command.ts | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/ts/lib/action.ts b/src/ts/lib/action.ts index 2fe1b7ce33..e8b1822480 100644 --- a/src/ts/lib/action.ts +++ b/src/ts/lib/action.ts @@ -798,7 +798,7 @@ class Action { analytics.event('ThemeSet', { id }); }; - publish (id: string) { + publish (objectId: string) { const { gateway } = S.Common; let data: any = { @@ -807,12 +807,13 @@ class Action { }, }; - C.ObjectShow(id, 'publish', S.Common.space, (message: any) => { + C.ObjectPublish(S.Common.space, objectId, (message: any) => { if (!message.error.code) { data = Object.assign(data, message.objectView); U.Common.clipboardCopy({ text: JSON.stringify(data) }); }; + console.log(message); }); }; diff --git a/src/ts/lib/api/command.ts b/src/ts/lib/api/command.ts index fcc0e0afa7..445bd92d6d 100644 --- a/src/ts/lib/api/command.ts +++ b/src/ts/lib/api/command.ts @@ -1358,6 +1358,20 @@ 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, (message: any) => { + if (callBack) { + callBack(message); + }; + }); +}; + + export const ObjectClose = (objectId: string, spaceId: string, callBack?: (message: any) => void) => { const request = new Rpc.Object.Close.Request(); @@ -2216,4 +2230,4 @@ export const ChatGetMessagesByIds = (objectId: string, ids: string[], callBack?: request.setMessageidsList(ids); dispatcher.request(ChatGetMessagesByIds.name, request, callBack); -}; \ No newline at end of file +}; From ebe1832126775625d8bd3f6e78c71269fc7798ea Mon Sep 17 00:00:00 2001 From: Anatolii Smolianinov Date: Thu, 10 Oct 2024 20:08:01 +0200 Subject: [PATCH 06/14] map ObjectPublish and call --- src/ts/lib/action.ts | 6 ++---- src/ts/lib/api/response.ts | 7 +++++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/ts/lib/action.ts b/src/ts/lib/action.ts index e8b1822480..f02060a9bd 100644 --- a/src/ts/lib/action.ts +++ b/src/ts/lib/action.ts @@ -807,11 +807,9 @@ class Action { }, }; - C.ObjectPublish(S.Common.space, objectId, (message: any) => { + C.ObjectPublish(S.Common.space, objectId, (message: any) => { + console.log("--- message:", message); if (!message.error.code) { - data = Object.assign(data, message.objectView); - - U.Common.clipboardCopy({ text: JSON.stringify(data) }); }; console.log(message); }); diff --git a/src/ts/lib/api/response.ts b/src/ts/lib/api/response.ts index 5de5b4cb04..b6a5813139 100644 --- a/src/ts/lib/api/response.ts +++ b/src/ts/lib/api/response.ts @@ -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(), + }; +}; + export const ObjectSearch = (response: Rpc.Object.Search.Response) => { return { records: (response.getRecordsList() || []).map(Decode.struct), From 59c2f4a5950d848305052034985f2a0edadd3619 Mon Sep 17 00:00:00 2001 From: Anatolii Smolianinov Date: Fri, 11 Oct 2024 17:38:09 +0200 Subject: [PATCH 07/14] copy published url to clipboard and show in toast --- src/ts/lib/action.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/ts/lib/action.ts b/src/ts/lib/action.ts index f02060a9bd..ed50b1785d 100644 --- a/src/ts/lib/action.ts +++ b/src/ts/lib/action.ts @@ -807,11 +807,16 @@ class Action { }, }; - C.ObjectPublish(S.Common.space, objectId, (message: any) => { - console.log("--- message:", message); - if (!message.error.code) { + C.ObjectPublish(S.Common.space, objectId, (message: any) => { + if (message.error.code) { + return; }; - console.log(message); + + const { key, cid } = message; + const publishedUrl = `http://localhost:8787/?cid=${cid}&key=${key}`; + Preview.toastShow({ text: `Published! URL copied to clipboard: ${publishedUrl}` }); + U.Common.clipboardCopy({ text: publishedUrl }); + }); }; From 83cdd8b8f94fcf09c461b28302ff3eada715554a Mon Sep 17 00:00:00 2001 From: Anatolii Smolianinov Date: Fri, 11 Oct 2024 17:55:33 +0200 Subject: [PATCH 08/14] workaround object show json was generated by castom code from mapping, I don't know how to do the same in easy way in middleware yet. So for now I'm just sending the whole object instead of id. --- src/ts/lib/action.ts | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/ts/lib/action.ts b/src/ts/lib/action.ts index ed50b1785d..5b67b3b46c 100644 --- a/src/ts/lib/action.ts +++ b/src/ts/lib/action.ts @@ -807,17 +807,23 @@ class Action { }, }; - C.ObjectPublish(S.Common.space, objectId, (message: any) => { - if (message.error.code) { - return; - }; + C.ObjectShow(objectId, 'publish', S.Common.space, (message: any) => { + if (!message.error.code) { + data = Object.assign(data, message.objectView); - const { key, cid } = message; - const publishedUrl = `http://localhost:8787/?cid=${cid}&key=${key}`; - Preview.toastShow({ text: `Published! URL copied to clipboard: ${publishedUrl}` }); - U.Common.clipboardCopy({ text: publishedUrl }); + C.ObjectPublish(S.Common.space, JSON.stringify(data), (message: any) => { + if (message.error.code) { + return; + }; + const { key, cid } = message; + const publishedUrl = `http://localhost:8787/?cid=${cid}&key=${key}`; + Preview.toastShow({ text: `Published! URL copied to clipboard: ${publishedUrl}` }); + U.Common.clipboardCopy({ text: publishedUrl }); + }); + }; }); + }; }; From 6dac777641d21c53774860d32ead3148d30627d0 Mon Sep 17 00:00:00 2001 From: Andrew Simachev Date: Sat, 12 Oct 2024 13:01:39 +0200 Subject: [PATCH 09/14] code review --- src/ts/lib/action.ts | 24 +++++++++++++----------- src/ts/lib/api/command.ts | 6 +----- src/ts/lib/api/response.ts | 8 ++++---- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/ts/lib/action.ts b/src/ts/lib/action.ts index a209bebe22..ded79334d0 100644 --- a/src/ts/lib/action.ts +++ b/src/ts/lib/action.ts @@ -836,19 +836,21 @@ class Action { C.ObjectShow(objectId, 'publish', S.Common.space, (message: any) => { if (!message.error.code) { - data = Object.assign(data, message.objectView); + return; + }; - C.ObjectPublish(S.Common.space, JSON.stringify(data), (message: any) => { - if (message.error.code) { - return; - }; + data = Object.assign(data, message.objectView); - const { key, cid } = message; - const publishedUrl = `http://localhost:8787/?cid=${cid}&key=${key}`; - Preview.toastShow({ text: `Published! URL copied to clipboard: ${publishedUrl}` }); - U.Common.clipboardCopy({ text: publishedUrl }); - }); - }; + C.ObjectPublish(S.Common.space, JSON.stringify(data), (message: any) => { + if (message.error.code) { + return; + }; + + const { key, cid } = message; + const url = `http://localhost:8787/?cid=${cid}&key=${key}`; + + U.Common.copyToast(translate('commonLink'), url); + }); }); }; diff --git a/src/ts/lib/api/command.ts b/src/ts/lib/api/command.ts index 11842edcf6..f8b39fd715 100644 --- a/src/ts/lib/api/command.ts +++ b/src/ts/lib/api/command.ts @@ -1364,11 +1364,7 @@ export const ObjectPublish = (spaceId: string, objectId: string, callBack?: (mes request.setObjectid(objectId); request.setSpaceid(spaceId); - dispatcher.request(ObjectPublish.name, request, (message: any) => { - if (callBack) { - callBack(message); - }; - }); + dispatcher.request(ObjectPublish.name, request, callBack); }; diff --git a/src/ts/lib/api/response.ts b/src/ts/lib/api/response.ts index b6a5813139..a87645fcc1 100644 --- a/src/ts/lib/api/response.ts +++ b/src/ts/lib/api/response.ts @@ -193,10 +193,10 @@ export const ObjectShow = (response: Rpc.Object.Show.Response) => { }; export const ObjectPublish = (response: Rpc.Object.Publish.Response) => { - return { - cid: response.getPublishcid(), - key: response.getPublishfilekey(), - }; + return { + cid: response.getPublishcid(), + key: response.getPublishfilekey(), + }; }; export const ObjectSearch = (response: Rpc.Object.Search.Response) => { From 478002f8cf5de67356a6058d0b31c890d03ecbf5 Mon Sep 17 00:00:00 2001 From: Anatolii Smolianinov Date: Mon, 14 Oct 2024 16:26:06 +0200 Subject: [PATCH 10/14] fix error message if --- src/ts/lib/action.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ts/lib/action.ts b/src/ts/lib/action.ts index fdd88a4855..da0ec87ea9 100644 --- a/src/ts/lib/action.ts +++ b/src/ts/lib/action.ts @@ -843,7 +843,7 @@ class Action { }; C.ObjectShow(objectId, 'publish', S.Common.space, (message: any) => { - if (!message.error.code) { + if (message.error.code) { return; }; From b752486427b55719847695e5ea7a18b72134fc9b Mon Sep 17 00:00:00 2001 From: Anatolii Smolianinov Date: Tue, 15 Oct 2024 17:17:51 +0200 Subject: [PATCH 11/14] add nix flakes for dev env --- flake.lock | 59 ++++++++++++++++++++++++++++++++++++++++++ flake.nix | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 135 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000000..e231028dfc --- /dev/null +++ b/flake.lock @@ -0,0 +1,59 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1725103162, + "narHash": "sha256-Ym04C5+qovuQDYL/rKWSR+WESseQBbNAe5DsXNx5trY=", + "rev": "12228ff1752d7b7624a54e9c1af4b222b3c1073b", + "revCount": 674318, + "type": "tarball", + "url": "https://api.flakehub.com/f/pinned/NixOS/nixpkgs/0.1.674318%2Brev-12228ff1752d7b7624a54e9c1af4b222b3c1073b/0191adaa-df39-7d38-92e0-798658d0033f/source.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://flakehub.com/f/NixOS/nixpkgs/0.1.0.tar.gz" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000000..466bd3efb6 --- /dev/null +++ b/flake.nix @@ -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 + ''; + }; + + }); +} From cb743fef29dba9133b4f049e2d2e4c0fbeba3d98 Mon Sep 17 00:00:00 2001 From: Anatolii Smolianinov Date: Thu, 24 Oct 2024 19:06:02 +0200 Subject: [PATCH 12/14] send pageId instead of json content --- src/ts/lib/action.ts | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/src/ts/lib/action.ts b/src/ts/lib/action.ts index e4cf38a794..3cb765d8a8 100644 --- a/src/ts/lib/action.ts +++ b/src/ts/lib/action.ts @@ -811,35 +811,17 @@ class Action { }; publish (objectId: string) { - const { gateway } = S.Common; - - let data: any = { - _meta: { - gateway, - }, - }; - - C.ObjectShow(objectId, 'publish', S.Common.space, (message: any) => { + C.ObjectPublish(S.Common.space, objectId, (message: any) => { if (message.error.code) { return; }; - data = Object.assign(data, message.objectView); - - C.ObjectPublish(S.Common.space, JSON.stringify(data), (message: any) => { - if (message.error.code) { - return; - }; - - const { key, cid } = message; - const url = `http://localhost:8787/?cid=${cid}&key=${key}`; + const { key, cid } = message; + const url = `http://localhost:8787/?cid=${cid}&key=${key}`; - U.Common.copyToast(translate('commonLink'), url); - }); + U.Common.copyToast(translate('commonLink'), url); }); - }; - }; export default new Action(); From 20cbb8eace8779b10d501a8b1aa0e7f0e9a12f5d Mon Sep 17 00:00:00 2001 From: Anatolii Smolianinov Date: Tue, 12 Nov 2024 18:20:03 +0100 Subject: [PATCH 13/14] flakes, add pixbuf for new electron --- flake.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/flake.nix b/flake.nix index 466bd3efb6..dcc9f05fdd 100644 --- a/flake.nix +++ b/flake.nix @@ -57,6 +57,7 @@ pkgs.xorg.libxcb pkgs.alsa-lib pkgs.libGL + pkgs.gdk-pixbuf ]; XDG_ICONS_PATH = "${pkgs.hicolor-icon-theme}/share:${pkgs.adwaita-icon-theme}/share"; in { From b160e4404481ead98d8553ec1d9eb7a918832ff2 Mon Sep 17 00:00:00 2001 From: Anatolii Smolianinov Date: Tue, 12 Nov 2024 18:30:12 +0100 Subject: [PATCH 14/14] log error --- src/ts/lib/action.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ts/lib/action.ts b/src/ts/lib/action.ts index 3cb765d8a8..f672a9b396 100644 --- a/src/ts/lib/action.ts +++ b/src/ts/lib/action.ts @@ -813,6 +813,7 @@ class Action { publish (objectId: string) { C.ObjectPublish(S.Common.space, objectId, (message: any) => { if (message.error.code) { + console.error(message); return; };