@gravity-ui/blog-constructor 2.1.0-alpha.1 → 2.1.2-alpha.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +15 -0
- package/build/cjs/components/FeedHeader/components/Controls/Controls.js +3 -2
- package/build/cjs/components/Paginator/Paginator.css +3 -0
- package/build/cjs/components/Paginator/components/PaginatorItem.js +31 -4
- package/build/cjs/components/PostInfo/components/Save.js +10 -6
- package/build/cjs/components/PostInfo/components/Sharing.js +2 -2
- package/build/cjs/constructor/BlogConstructorProvider.d.ts +1 -1
- package/build/cjs/constructor/BlogConstructorProvider.js +2 -2
- package/build/cjs/models/common.d.ts +2 -1
- package/build/cjs/models/common.js +1 -0
- package/build/cjs/utils/common.d.ts +1 -0
- package/build/cjs/utils/common.js +6 -1
- package/build/esm/components/FeedHeader/components/Controls/Controls.js +3 -2
- package/build/esm/components/Paginator/Paginator.css +3 -0
- package/build/esm/components/Paginator/components/PaginatorItem.js +9 -2
- package/build/esm/components/PostInfo/components/Save.js +9 -5
- package/build/esm/components/PostInfo/components/Sharing.js +1 -1
- package/build/esm/constructor/BlogConstructorProvider.d.ts +1 -1
- package/build/esm/constructor/BlogConstructorProvider.js +1 -1
- package/build/esm/models/common.d.ts +2 -1
- package/build/esm/models/common.js +1 -0
- package/build/esm/utils/common.d.ts +1 -0
- package/build/esm/utils/common.js +4 -0
- package/package.json +1 -1
- package/server/models/common.d.ts +2 -1
- package/server/models/common.js +1 -0
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,20 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [2.0.2](https://github.com/gravity-ui/blog-constructor/compare/v2.0.1...v2.0.2) (2023-04-05)
|
4
|
+
|
5
|
+
|
6
|
+
### Bug Fixes
|
7
|
+
|
8
|
+
* covering pagination buttons into 'a' tag ([#23](https://github.com/gravity-ui/blog-constructor/issues/23)) ([e603f2e](https://github.com/gravity-ui/blog-constructor/commit/e603f2e2b0f86d492132174a1c8172786e7a09a1))
|
9
|
+
|
10
|
+
## [2.0.1](https://github.com/gravity-ui/blog-constructor/compare/v2.0.0...v2.0.1) (2023-04-04)
|
11
|
+
|
12
|
+
|
13
|
+
### Bug Fixes
|
14
|
+
|
15
|
+
* throw virtualization threshold prop in Select ([#26](https://github.com/gravity-ui/blog-constructor/issues/26)) ([ccb0f19](https://github.com/gravity-ui/blog-constructor/commit/ccb0f19a904e54fd43ca66195da9e94925d0a26f))
|
16
|
+
* throw virtualization threshold prop in Select ([#26](https://github.com/gravity-ui/blog-constructor/issues/26)) ([0aa5aed](https://github.com/gravity-ui/blog-constructor/commit/0aa5aeda9a0afd99ae8590c6b666c033a12b7fba))
|
17
|
+
|
3
18
|
## [2.0.0](https://github.com/gravity-ui/blog-constructor/compare/v1.1.2...v2.0.0) (2023-04-03)
|
4
19
|
|
5
20
|
|
@@ -41,6 +41,7 @@ const cn_1 = require("../../../../utils/cn");
|
|
41
41
|
const b = (0, cn_1.block)('feed-controls');
|
42
42
|
const ICON_SIZE = 16;
|
43
43
|
const DEFAULT_PAGE = 1;
|
44
|
+
const VIRTUALIZATION_THRESHOLD = 1000;
|
44
45
|
const Controls = ({ setIsFetching, tags = [], services = [], handleChangeQuery, queryParams, }) => {
|
45
46
|
const { hasLikes } = (0, react_1.useContext)(LikesContext_1.LikesContext);
|
46
47
|
const { savedOnly: savedOnlyInitial, search: searchInitial, tags: tagInitial, services: servicesInitial, } = queryParams || {};
|
@@ -91,13 +92,13 @@ const Controls = ({ setIsFetching, tags = [], services = [], handleChangeQuery,
|
|
91
92
|
initial: [tagInitial],
|
92
93
|
list: tagsItems,
|
93
94
|
defaultLabel: (0, i18n_1.i18)(i18n_1.Keyset.AllTags),
|
94
|
-
}), disablePortal: true, renderOption: customRenders_1.renderOption })),
|
95
|
+
}), disablePortal: true, virtualizationThreshold: VIRTUALIZATION_THRESHOLD, renderOption: customRenders_1.renderOption })),
|
95
96
|
services.length > 0 ? (react_1.default.createElement("div", { className: b('filter-item') },
|
96
97
|
react_1.default.createElement(uikit_1.Select, { className: b('select'), size: "xl", multiple: true, filterable: true, disablePortal: true, options: services, defaultValue: servicesItems, popupClassName: b('popup'), onUpdate: handleServicesSelect, placeholder: (0, i18n_1.i18)(i18n_1.Keyset.AllServices), renderControl: (0, customRenders_1.renderSwitcher)({
|
97
98
|
initial: servicesItems,
|
98
99
|
list: services,
|
99
100
|
defaultLabel: (0, i18n_1.i18)(i18n_1.Keyset.AllServices),
|
100
|
-
}), renderOption: customRenders_1.renderOption, renderFilter: customRenders_1.renderFilter }))) : null,
|
101
|
+
}), virtualizationThreshold: VIRTUALIZATION_THRESHOLD, renderOption: customRenders_1.renderOption, renderFilter: customRenders_1.renderFilter }))) : null,
|
101
102
|
hasLikes ? (react_1.default.createElement("div", { className: b('filter-item', { 'width-auto': true }) },
|
102
103
|
react_1.default.createElement(uikit_1.Button, { view: 'outlined', className: b('saved-only-button', { savedOnly }), size: "xl", onClick: handleSavedOnly },
|
103
104
|
react_1.default.createElement(uikit_1.Icon, { data: Save_1.Save, size: ICON_SIZE, className: b('icon', { savedOnly }) }),
|
@@ -1,15 +1,42 @@
|
|
1
1
|
"use strict";
|
2
|
-
var
|
3
|
-
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
19
|
+
if (mod && mod.__esModule) return mod;
|
20
|
+
var result = {};
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
+
__setModuleDefault(result, mod);
|
23
|
+
return result;
|
4
24
|
};
|
5
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
26
|
exports.PaginatorItem = void 0;
|
7
|
-
const react_1 =
|
27
|
+
const react_1 = __importStar(require("react"));
|
8
28
|
const uikit_1 = require("@gravity-ui/uikit");
|
29
|
+
const LocaleContext_1 = require("../../../contexts/LocaleContext");
|
30
|
+
const common_1 = require("../../../utils/common");
|
9
31
|
const cn_1 = require("../../../utils/cn");
|
10
32
|
const b = (0, cn_1.block)('paginator');
|
11
33
|
const PaginatorItem = ({ dataKey, mods, content, onClick, loading = false, }) => {
|
34
|
+
const { locale } = (0, react_1.useContext)(LocaleContext_1.LocaleContext);
|
35
|
+
const urlPath = (0, common_1.getBlogPath)((locale === null || locale === void 0 ? void 0 : locale.pathPrefix) || '');
|
12
36
|
const itemKey = Number(dataKey) > 0 ? Number(dataKey) : dataKey;
|
13
|
-
|
37
|
+
const navTag = itemKey > 0 ? `${mods.type || 'page'}=${itemKey}` : itemKey;
|
38
|
+
const navigationLink = `${urlPath || ''}?${navTag}`;
|
39
|
+
return (react_1.default.createElement("a", { href: navigationLink, className: b('link', mods), onClick: (event) => event.preventDefault() },
|
40
|
+
react_1.default.createElement(uikit_1.Button, { view: "flat", size: "xl", className: b('item', mods), onClick: () => onClick === null || onClick === void 0 ? void 0 : onClick(itemKey), loading: loading && Boolean(mods.active) }, content)));
|
14
41
|
};
|
15
42
|
exports.PaginatorItem = PaginatorItem;
|
@@ -27,16 +27,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
27
27
|
};
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
29
29
|
exports.Save = void 0;
|
30
|
-
const
|
30
|
+
const page_constructor_1 = require("@gravity-ui/page-constructor");
|
31
31
|
const uikit_1 = require("@gravity-ui/uikit");
|
32
|
-
const
|
33
|
-
const
|
32
|
+
const react_1 = __importStar(require("react"));
|
33
|
+
const UserContext_1 = require("../../../contexts/UserContext");
|
34
|
+
const metrika_js_1 = __importDefault(require("../../../counters/metrika.js"));
|
34
35
|
const utils_1 = require("../../../counters/utils");
|
35
36
|
// @ts-ignore
|
36
|
-
const metrika_js_1 = __importDefault(require("../../../counters/metrika.js"));
|
37
37
|
const Save_1 = require("../../../icons/Save");
|
38
38
|
const SaveFilled_1 = require("../../../icons/SaveFilled");
|
39
|
-
const
|
39
|
+
const common_1 = require("../../../models/common");
|
40
|
+
const cn_1 = require("../../../utils/cn");
|
41
|
+
const common_2 = require("../../../utils/common");
|
40
42
|
const ICON_SIZE = 16;
|
41
43
|
const b = (0, cn_1.block)('post-info');
|
42
44
|
/**
|
@@ -53,6 +55,7 @@ const b = (0, cn_1.block)('post-info');
|
|
53
55
|
*/
|
54
56
|
const Save = ({ title, postId, hasUserLike, handleUserLike, metrikaGoal, size, theme, dataQa, }) => {
|
55
57
|
const { uid } = (0, react_1.useContext)(UserContext_1.UserContext);
|
58
|
+
const handleAnalytics = (0, page_constructor_1.useAnalytics)(common_1.DefaultEventNames.SaveButton);
|
56
59
|
return (react_1.default.createElement("div", { className: b('item', { size }), onClick: (event) => {
|
57
60
|
// both preventDefault and stopImmediatePropagation required to work properly
|
58
61
|
// https://stackoverflow.com/questions/24415631/reactjs-syntheticevent-stoppropagation-only-works-with-react-events
|
@@ -61,9 +64,10 @@ const Save = ({ title, postId, hasUserLike, handleUserLike, metrikaGoal, size, t
|
|
61
64
|
if (!uid) {
|
62
65
|
return;
|
63
66
|
}
|
64
|
-
(0,
|
67
|
+
(0, common_2.postLikeStatus)(postId, Boolean(hasUserLike));
|
65
68
|
handleUserLike();
|
66
69
|
metrika_js_1.default.reachGoal(utils_1.MetrikaCounter.CrossSite, metrikaGoal);
|
70
|
+
handleAnalytics();
|
67
71
|
}, "data-qa": `${dataQa ? dataQa + '-' : ''}save` },
|
68
72
|
react_1.default.createElement("div", { className: b('content', { cursor: Boolean(uid), theme }) },
|
69
73
|
react_1.default.createElement("span", { className: b('icon') },
|
@@ -27,7 +27,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
27
27
|
};
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
29
29
|
exports.Sharing = void 0;
|
30
|
-
const
|
30
|
+
const page_constructor_1 = require("@gravity-ui/page-constructor");
|
31
31
|
const uikit_1 = require("@gravity-ui/uikit");
|
32
32
|
const react_1 = __importStar(require("react"));
|
33
33
|
const MobileContext_1 = require("../../../contexts/MobileContext");
|
@@ -46,7 +46,7 @@ const Sharing = ({ theme, metrikaGoal }) => {
|
|
46
46
|
const router = (0, react_1.useContext)(RouterContext_1.RouterContext);
|
47
47
|
const isMobile = (0, react_1.useContext)(MobileContext_1.MobileContext);
|
48
48
|
const { shareOptions } = (0, react_1.useContext)(PostPageContext_1.PostPageContext);
|
49
|
-
const handleAnalyticsGlobal = (0,
|
49
|
+
const handleAnalyticsGlobal = (0, page_constructor_1.useAnalytics)(common_1.DefaultEventNames.ShareButton);
|
50
50
|
const handleMetrika = (0, react_1.useCallback)(() => {
|
51
51
|
metrika_js_1.default.reachGoal(utils_1.MetrikaCounter.CrossSite, metrikaGoal);
|
52
52
|
}, [metrikaGoal]);
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import { AnalyticsContextProps } from '@gravity-ui/page-constructor
|
2
|
+
import { AnalyticsContextProps } from '@gravity-ui/page-constructor';
|
3
3
|
import { RouterContextProps } from '../contexts/RouterContext';
|
4
4
|
import { UserContextProps } from '../contexts/UserContext';
|
5
5
|
import { DeviceContextProps } from '../contexts/DeviceContext';
|
@@ -25,7 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
26
26
|
exports.BlogConstructorProvider = void 0;
|
27
27
|
const react_1 = __importStar(require("react"));
|
28
|
-
const
|
28
|
+
const page_constructor_1 = require("@gravity-ui/page-constructor");
|
29
29
|
const MobileContext_1 = require("../contexts/MobileContext");
|
30
30
|
const LocaleContext_1 = require("../contexts/LocaleContext");
|
31
31
|
const RouterContext_1 = require("../contexts/RouterContext");
|
@@ -41,7 +41,7 @@ const BlogConstructorProvider = ({ isMobile, locale = {}, router = {}, theme = c
|
|
41
41
|
react_1.default.createElement(MobileContext_1.MobileContext.Provider, { value: Boolean(isMobile), key: "is-mobile-context" }),
|
42
42
|
react_1.default.createElement(UserContext_1.UserContext.Provider, { value: user, key: "user-context" }),
|
43
43
|
react_1.default.createElement(DeviceContext_1.DeviceContext.Provider, { value: device, key: "device-context" }),
|
44
|
-
react_1.default.createElement(
|
44
|
+
react_1.default.createElement(page_constructor_1.AnalyticsContext.Provider, { value: analytics, key: "analytics-context" }),
|
45
45
|
].reduceRight((prev, provider) => react_1.default.cloneElement(provider, {}, prev), children);
|
46
46
|
return react_1.default.createElement(react_1.Fragment, null, context);
|
47
47
|
};
|
@@ -150,5 +150,6 @@ export type SetQueryType = (params: Query, options?: {
|
|
150
150
|
[y: string]: boolean;
|
151
151
|
}) => Promise<void> | void;
|
152
152
|
export declare enum DefaultEventNames {
|
153
|
-
ShareButton = "share-button-click"
|
153
|
+
ShareButton = "share-button-click",
|
154
|
+
SaveButton = "save-button-click"
|
154
155
|
}
|
@@ -23,4 +23,5 @@ var BlockType;
|
|
23
23
|
var DefaultEventNames;
|
24
24
|
(function (DefaultEventNames) {
|
25
25
|
DefaultEventNames["ShareButton"] = "share-button-click";
|
26
|
+
DefaultEventNames["SaveButton"] = "save-button-click";
|
26
27
|
})(DefaultEventNames = exports.DefaultEventNames || (exports.DefaultEventNames = {}));
|
@@ -34,6 +34,7 @@ type GetBreadcrumbsProps = {
|
|
34
34
|
tags?: Tag[];
|
35
35
|
pathPrefix?: string;
|
36
36
|
};
|
37
|
+
export declare const getBlogPath: (pathPrefix: string) => string;
|
37
38
|
export declare const getBreadcrumbs: ({ tags, pathPrefix }: GetBreadcrumbsProps) => HeaderBreadCrumbsProps;
|
38
39
|
export declare const isMetrikaExist: (goal: NewMetrikaGoal, existGoals: NewMetrikaGoal[]) => boolean;
|
39
40
|
export declare const getBlogElementMetrika: (blogCustomGoal: NewMetrikaGoal, existingGoals?: MetrikaGoal) => string | string[] | NewMetrikaGoal[];
|
@@ -11,7 +11,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
11
11
|
return t;
|
12
12
|
};
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
14
|
-
exports.scrollOnPageChange = exports.getFeedQueryParams = exports.getBlogElementMetrika = exports.isMetrikaExist = exports.getBreadcrumbs = exports.updateContentSizes = exports.getTagFilterUrl = exports.postLikeStatus = exports.getTags = exports.scrollToHash = exports.getPageSearchParams = exports.getAbsolutePath = void 0;
|
14
|
+
exports.scrollOnPageChange = exports.getFeedQueryParams = exports.getBlogElementMetrika = exports.isMetrikaExist = exports.getBreadcrumbs = exports.getBlogPath = exports.updateContentSizes = exports.getTagFilterUrl = exports.postLikeStatus = exports.getTags = exports.scrollToHash = exports.getPageSearchParams = exports.getAbsolutePath = void 0;
|
15
15
|
const url_1 = require("url");
|
16
16
|
const lodash_1 = require("lodash");
|
17
17
|
const page_constructor_1 = require("@gravity-ui/page-constructor");
|
@@ -65,6 +65,11 @@ const updateContentSizes = (_a) => {
|
|
65
65
|
return (Object.assign(Object.assign({}, contentData), { size: size || constants_1.CONTENT_DEFAULT_SIZE, colSizes: colSizes || constants_1.CONTENT_DEFAULT_COL_SIZES, theme: theme || constants_1.CONTENT_DEFAULT_THEME }));
|
66
66
|
};
|
67
67
|
exports.updateContentSizes = updateContentSizes;
|
68
|
+
const getBlogPath = (pathPrefix) => {
|
69
|
+
const prefix = pathPrefix ? `/${pathPrefix}/` : '/';
|
70
|
+
return `${prefix}blog`;
|
71
|
+
};
|
72
|
+
exports.getBlogPath = getBlogPath;
|
68
73
|
const getBreadcrumbs = ({ tags, pathPrefix }) => {
|
69
74
|
const prefix = pathPrefix ? `/${pathPrefix}/` : '/';
|
70
75
|
const breadcrumbs = {
|
@@ -13,6 +13,7 @@ import './Controls.css';
|
|
13
13
|
const b = block('feed-controls');
|
14
14
|
const ICON_SIZE = 16;
|
15
15
|
const DEFAULT_PAGE = 1;
|
16
|
+
const VIRTUALIZATION_THRESHOLD = 1000;
|
16
17
|
export const Controls = ({ setIsFetching, tags = [], services = [], handleChangeQuery, queryParams, }) => {
|
17
18
|
const { hasLikes } = useContext(LikesContext);
|
18
19
|
const { savedOnly: savedOnlyInitial, search: searchInitial, tags: tagInitial, services: servicesInitial, } = queryParams || {};
|
@@ -63,13 +64,13 @@ export const Controls = ({ setIsFetching, tags = [], services = [], handleChange
|
|
63
64
|
initial: [tagInitial],
|
64
65
|
list: tagsItems,
|
65
66
|
defaultLabel: i18(Keyset.AllTags),
|
66
|
-
}), disablePortal: true, renderOption: renderOption })),
|
67
|
+
}), disablePortal: true, virtualizationThreshold: VIRTUALIZATION_THRESHOLD, renderOption: renderOption })),
|
67
68
|
services.length > 0 ? (React.createElement("div", { className: b('filter-item') },
|
68
69
|
React.createElement(Select, { className: b('select'), size: "xl", multiple: true, filterable: true, disablePortal: true, options: services, defaultValue: servicesItems, popupClassName: b('popup'), onUpdate: handleServicesSelect, placeholder: i18(Keyset.AllServices), renderControl: renderSwitcher({
|
69
70
|
initial: servicesItems,
|
70
71
|
list: services,
|
71
72
|
defaultLabel: i18(Keyset.AllServices),
|
72
|
-
}), renderOption: renderOption, renderFilter: renderFilter }))) : null,
|
73
|
+
}), virtualizationThreshold: VIRTUALIZATION_THRESHOLD, renderOption: renderOption, renderFilter: renderFilter }))) : null,
|
73
74
|
hasLikes ? (React.createElement("div", { className: b('filter-item', { 'width-auto': true }) },
|
74
75
|
React.createElement(Button, { view: 'outlined', className: b('saved-only-button', { savedOnly }), size: "xl", onClick: handleSavedOnly },
|
75
76
|
React.createElement(Icon, { data: Save, size: ICON_SIZE, className: b('icon', { savedOnly }) }),
|
@@ -1,9 +1,16 @@
|
|
1
|
-
import React from 'react';
|
1
|
+
import React, { useContext } from 'react';
|
2
2
|
import { Button } from '@gravity-ui/uikit';
|
3
|
+
import { LocaleContext } from '../../../contexts/LocaleContext';
|
4
|
+
import { getBlogPath } from '../../../utils/common';
|
3
5
|
import { block } from '../../../utils/cn';
|
4
6
|
import '../Paginator.css';
|
5
7
|
const b = block('paginator');
|
6
8
|
export const PaginatorItem = ({ dataKey, mods, content, onClick, loading = false, }) => {
|
9
|
+
const { locale } = useContext(LocaleContext);
|
10
|
+
const urlPath = getBlogPath((locale === null || locale === void 0 ? void 0 : locale.pathPrefix) || '');
|
7
11
|
const itemKey = Number(dataKey) > 0 ? Number(dataKey) : dataKey;
|
8
|
-
|
12
|
+
const navTag = itemKey > 0 ? `${mods.type || 'page'}=${itemKey}` : itemKey;
|
13
|
+
const navigationLink = `${urlPath || ''}?${navTag}`;
|
14
|
+
return (React.createElement("a", { href: navigationLink, className: b('link', mods), onClick: (event) => event.preventDefault() },
|
15
|
+
React.createElement(Button, { view: "flat", size: "xl", className: b('item', mods), onClick: () => onClick === null || onClick === void 0 ? void 0 : onClick(itemKey), loading: loading && Boolean(mods.active) }, content)));
|
9
16
|
};
|
@@ -1,13 +1,15 @@
|
|
1
|
-
import
|
1
|
+
import { useAnalytics } from '@gravity-ui/page-constructor';
|
2
2
|
import { Icon } from '@gravity-ui/uikit';
|
3
|
-
import {
|
4
|
-
import {
|
3
|
+
import React, { useContext } from 'react';
|
4
|
+
import { UserContext } from '../../../contexts/UserContext';
|
5
|
+
import metrika from '../../../counters/metrika.js';
|
5
6
|
import { MetrikaCounter } from '../../../counters/utils';
|
6
7
|
// @ts-ignore
|
7
|
-
import metrika from '../../../counters/metrika.js';
|
8
8
|
import { Save as SaveIcon } from '../../../icons/Save';
|
9
9
|
import { SaveFilled } from '../../../icons/SaveFilled';
|
10
|
-
import {
|
10
|
+
import { DefaultEventNames } from '../../../models/common';
|
11
|
+
import { block } from '../../../utils/cn';
|
12
|
+
import { postLikeStatus } from '../../../utils/common';
|
11
13
|
import '../PostInfo.css';
|
12
14
|
const ICON_SIZE = 16;
|
13
15
|
const b = block('post-info');
|
@@ -25,6 +27,7 @@ const b = block('post-info');
|
|
25
27
|
*/
|
26
28
|
export const Save = ({ title, postId, hasUserLike, handleUserLike, metrikaGoal, size, theme, dataQa, }) => {
|
27
29
|
const { uid } = useContext(UserContext);
|
30
|
+
const handleAnalytics = useAnalytics(DefaultEventNames.SaveButton);
|
28
31
|
return (React.createElement("div", { className: b('item', { size }), onClick: (event) => {
|
29
32
|
// both preventDefault and stopImmediatePropagation required to work properly
|
30
33
|
// https://stackoverflow.com/questions/24415631/reactjs-syntheticevent-stoppropagation-only-works-with-react-events
|
@@ -36,6 +39,7 @@ export const Save = ({ title, postId, hasUserLike, handleUserLike, metrikaGoal,
|
|
36
39
|
postLikeStatus(postId, Boolean(hasUserLike));
|
37
40
|
handleUserLike();
|
38
41
|
metrika.reachGoal(MetrikaCounter.CrossSite, metrikaGoal);
|
42
|
+
handleAnalytics();
|
39
43
|
}, "data-qa": `${dataQa ? dataQa + '-' : ''}save` },
|
40
44
|
React.createElement("div", { className: b('content', { cursor: Boolean(uid), theme }) },
|
41
45
|
React.createElement("span", { className: b('icon') },
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { useAnalytics } from '@gravity-ui/page-constructor
|
1
|
+
import { useAnalytics } from '@gravity-ui/page-constructor';
|
2
2
|
import { SharePopover } from '@gravity-ui/uikit';
|
3
3
|
import React, { useCallback, useContext } from 'react';
|
4
4
|
import { MobileContext } from '../../../contexts/MobileContext';
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import { AnalyticsContextProps } from '@gravity-ui/page-constructor
|
2
|
+
import { AnalyticsContextProps } from '@gravity-ui/page-constructor';
|
3
3
|
import { RouterContextProps } from '../contexts/RouterContext';
|
4
4
|
import { UserContextProps } from '../contexts/UserContext';
|
5
5
|
import { DeviceContextProps } from '../contexts/DeviceContext';
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import React, { Fragment } from 'react';
|
2
|
-
import { AnalyticsContext
|
2
|
+
import { AnalyticsContext } from '@gravity-ui/page-constructor';
|
3
3
|
import { MobileContext } from '../contexts/MobileContext';
|
4
4
|
import { LocaleContext } from '../contexts/LocaleContext';
|
5
5
|
import { RouterContext } from '../contexts/RouterContext';
|
@@ -150,5 +150,6 @@ export type SetQueryType = (params: Query, options?: {
|
|
150
150
|
[y: string]: boolean;
|
151
151
|
}) => Promise<void> | void;
|
152
152
|
export declare enum DefaultEventNames {
|
153
|
-
ShareButton = "share-button-click"
|
153
|
+
ShareButton = "share-button-click",
|
154
|
+
SaveButton = "save-button-click"
|
154
155
|
}
|
@@ -34,6 +34,7 @@ type GetBreadcrumbsProps = {
|
|
34
34
|
tags?: Tag[];
|
35
35
|
pathPrefix?: string;
|
36
36
|
};
|
37
|
+
export declare const getBlogPath: (pathPrefix: string) => string;
|
37
38
|
export declare const getBreadcrumbs: ({ tags, pathPrefix }: GetBreadcrumbsProps) => HeaderBreadCrumbsProps;
|
38
39
|
export declare const isMetrikaExist: (goal: NewMetrikaGoal, existGoals: NewMetrikaGoal[]) => boolean;
|
39
40
|
export declare const getBlogElementMetrika: (blogCustomGoal: NewMetrikaGoal, existingGoals?: MetrikaGoal) => string | string[] | NewMetrikaGoal[];
|
@@ -57,6 +57,10 @@ export const updateContentSizes = (_a) => {
|
|
57
57
|
var { size, colSizes, theme } = _a, contentData = __rest(_a, ["size", "colSizes", "theme"]);
|
58
58
|
return (Object.assign(Object.assign({}, contentData), { size: size || CONTENT_DEFAULT_SIZE, colSizes: colSizes || CONTENT_DEFAULT_COL_SIZES, theme: theme || CONTENT_DEFAULT_THEME }));
|
59
59
|
};
|
60
|
+
export const getBlogPath = (pathPrefix) => {
|
61
|
+
const prefix = pathPrefix ? `/${pathPrefix}/` : '/';
|
62
|
+
return `${prefix}blog`;
|
63
|
+
};
|
60
64
|
export const getBreadcrumbs = ({ tags, pathPrefix }) => {
|
61
65
|
const prefix = pathPrefix ? `/${pathPrefix}/` : '/';
|
62
66
|
const breadcrumbs = {
|
package/package.json
CHANGED
@@ -150,5 +150,6 @@ export type SetQueryType = (params: Query, options?: {
|
|
150
150
|
[y: string]: boolean;
|
151
151
|
}) => Promise<void> | void;
|
152
152
|
export declare enum DefaultEventNames {
|
153
|
-
ShareButton = "share-button-click"
|
153
|
+
ShareButton = "share-button-click",
|
154
|
+
SaveButton = "save-button-click"
|
154
155
|
}
|
package/server/models/common.js
CHANGED
@@ -23,4 +23,5 @@ var BlockType;
|
|
23
23
|
var DefaultEventNames;
|
24
24
|
(function (DefaultEventNames) {
|
25
25
|
DefaultEventNames["ShareButton"] = "share-button-click";
|
26
|
+
DefaultEventNames["SaveButton"] = "save-button-click";
|
26
27
|
})(DefaultEventNames = exports.DefaultEventNames || (exports.DefaultEventNames = {}));
|