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

Publish test #988

Open
wants to merge 19 commits into
base: feature/chat
Choose a base branch
from
Open
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
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,
};

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

publish (objectId: string) {
const { gateway } = S.Common;

let data: any = {
_meta: {
gateway,
},
};

C.ObjectShow(objectId, 'publish', S.Common.space, (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}`;

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(),
};
};

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