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..dcc9f05fdd --- /dev/null +++ b/flake.nix @@ -0,0 +1,77 @@ +# 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 + pkgs.gdk-pixbuf + ]; + 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 + ''; + }; + + }); +} diff --git a/src/json/text.json b/src/json/text.json index cc8e0d9939..47e3cdb15f 100644 --- a/src/json/text.json +++ b/src/json/text.json @@ -1524,6 +1524,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 ba7c9e492e..fe0630377b 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,16 +106,17 @@ 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 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') }; let openObject = { id: 'openAsObject', icon: 'expand', name: translate('commonOpenObject') }; @@ -180,6 +182,7 @@ class MenuObject extends React.Component { 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); const allowedOpenObject = isFilePreview; @@ -198,6 +201,7 @@ class MenuObject extends React.Component { if (!allowedLinkTo) linkTo = null; if (!allowedPageLink) pageLink = null; if (!allowedAddCollection) addCollection = null; + if (!allowedPublish) pagePublish = null; if (!allowedExport) pageExport = null; if (!allowedPrint) print = null; if (!allowedDownloadFile) downloadFile = null; @@ -245,7 +249,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 ] }, ]); }; @@ -434,6 +438,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 ], () => { @@ -559,4 +568,4 @@ class MenuObject extends React.Component { }; -export default MenuObject; \ No newline at end of file +export default MenuObject; diff --git a/src/ts/component/page/elements/head/editor.tsx b/src/ts/component/page/elements/head/editor.tsx index e536d34771..abd3999cfa 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/interface/block/index.ts b/src/ts/interface/block/index.ts index c3eaa3c584..70832e92fe 100644 --- a/src/ts/interface/block/index.ts +++ b/src/ts/interface/block/index.ts @@ -159,7 +159,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/lib/action.ts b/src/ts/lib/action.ts index 822cc99a38..f672a9b396 100644 --- a/src/ts/lib/action.ts +++ b/src/ts/lib/action.ts @@ -810,6 +810,19 @@ class Action { analytics.event('ThemeSet', { id }); }; + publish (objectId: string) { + C.ObjectPublish(S.Common.space, objectId, (message: any) => { + if (message.error.code) { + console.error(message); + return; + }; + + const { key, cid } = message; + const url = `http://localhost:8787/?cid=${cid}&key=${key}`; + + U.Common.copyToast(translate('commonLink'), url); + }); + }; }; export default new Action(); diff --git a/src/ts/lib/api/command.ts b/src/ts/lib/api/command.ts index d67b73e220..fc6daa898a 100644 --- a/src/ts/lib/api/command.ts +++ b/src/ts/lib/api/command.ts @@ -1363,6 +1363,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(); diff --git a/src/ts/lib/api/response.ts b/src/ts/lib/api/response.ts index 12ce7d565f..c93beb7d60 100644 --- a/src/ts/lib/api/response.ts +++ b/src/ts/lib/api/response.ts @@ -198,6 +198,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), diff --git a/src/ts/model/block.ts b/src/ts/model/block.ts index e20d38bbf2..01f3774a45 100644 --- a/src/ts/model/block.ts +++ b/src/ts/model/block.ts @@ -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); };