@atlaskit/editor-plugin-card 0.7.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @atlaskit/editor-plugin-card
2
2
 
3
+ ## 0.7.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`bab3ac9e64e`](https://bitbucket.org/atlassian/atlassian-frontend/commits/bab3ac9e64e) - Passing analytic events with attributes from link-datasource modal to editor.
8
+ - Updated dependencies
9
+
3
10
  ## 0.7.0
4
11
 
5
12
  ### Minor Changes
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.DatasourceModal = void 0;
9
9
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
11
  var _react = _interopRequireWildcard(require("react"));
11
12
  var _state = require("@atlaskit/editor-prosemirror/state");
12
13
  var _linkDatasource = require("@atlaskit/link-datasource");
@@ -14,6 +15,8 @@ var _actions = require("../../pm-plugins/actions");
14
15
  var _doc = require("../../pm-plugins/doc");
15
16
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
16
17
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
18
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
19
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
17
20
  var DatasourceModal = function DatasourceModal(_ref) {
18
21
  var view = _ref.view,
19
22
  modalType = _ref.modalType;
@@ -24,11 +27,20 @@ var DatasourceModal = function DatasourceModal(_ref) {
24
27
  var onClose = (0, _react.useCallback)(function () {
25
28
  dispatch((0, _actions.hideDatasourceModal)(state.tr));
26
29
  }, [dispatch, state.tr]);
27
- var onInsert = (0, _react.useCallback)(function (newAdf) {
30
+ var onInsert = (0, _react.useCallback)(function (newAdf, analyticEvent) {
31
+ if (analyticEvent) {
32
+ analyticEvent.update(function (payload) {
33
+ return _objectSpread(_objectSpread({}, payload), {}, {
34
+ attributes: _objectSpread(_objectSpread({}, payload.attributes), {}, {
35
+ inputMethod: 'datasource_config'
36
+ })
37
+ });
38
+ });
39
+ }
28
40
  if (existingNode) {
29
- (0, _doc.updateCardFromDatasourceModal)(state, existingNode, newAdf, view);
41
+ (0, _doc.updateCardFromDatasourceModal)(state, existingNode, newAdf, view, analyticEvent);
30
42
  } else {
31
- (0, _doc.insertDatasource)(state, newAdf, view);
43
+ (0, _doc.insertDatasource)(state, newAdf, view, analyticEvent);
32
44
  }
33
45
  }, [existingNode, state, view]);
34
46
  if (modalType === 'jira') {
@@ -29,8 +29,9 @@ function getSearchMethod(creationMethod, metadata) {
29
29
  }
30
30
  var sourceEvent = metadata.sourceEvent;
31
31
  if (sourceEvent instanceof _analyticsNext.UIAnalyticsEvent) {
32
+ var _event$payload$attrib;
32
33
  var event = sourceEvent;
33
- return event.payload.searchMethod;
34
+ return (_event$payload$attrib = event.payload.attributes) === null || _event$payload$attrib === void 0 ? void 0 : _event$payload$attrib.searchMethod;
34
35
  }
35
36
  return 'unknown';
36
37
  }
@@ -48,8 +49,9 @@ function getAnalyticAttributesFromNode(datasourceAttrs, metadata) {
48
49
  inputMethod: metadata.inputMethod
49
50
  })) !== null && _getMethod !== void 0 ? _getMethod : '';
50
51
  } else if (metadata.sourceEvent instanceof _analyticsNext.UIAnalyticsEvent) {
51
- inputMethod = metadata.sourceEvent.payload.inputMethod;
52
- actions = metadata.sourceEvent.payload.actions;
52
+ var _metadata$sourceEvent, _metadata$sourceEvent2;
53
+ inputMethod = (_metadata$sourceEvent = metadata.sourceEvent.payload.attributes) === null || _metadata$sourceEvent === void 0 ? void 0 : _metadata$sourceEvent.inputMethod;
54
+ actions = (_metadata$sourceEvent2 = metadata.sourceEvent.payload.attributes) === null || _metadata$sourceEvent2 === void 0 ? void 0 : _metadata$sourceEvent2.actions;
53
55
  }
54
56
  var displayedColumnCount = getDisplayedColumnCount(datasourceAttrs);
55
57
  var searchMethod = getSearchMethod(inputMethod, metadata);
@@ -18,11 +18,20 @@ export const DatasourceModal = ({
18
18
  const onClose = useCallback(() => {
19
19
  dispatch(hideDatasourceModal(state.tr));
20
20
  }, [dispatch, state.tr]);
21
- const onInsert = useCallback(newAdf => {
21
+ const onInsert = useCallback((newAdf, analyticEvent) => {
22
+ if (analyticEvent) {
23
+ analyticEvent.update(payload => ({
24
+ ...payload,
25
+ attributes: {
26
+ ...payload.attributes,
27
+ inputMethod: 'datasource_config'
28
+ }
29
+ }));
30
+ }
22
31
  if (existingNode) {
23
- updateCardFromDatasourceModal(state, existingNode, newAdf, view);
32
+ updateCardFromDatasourceModal(state, existingNode, newAdf, view, analyticEvent);
24
33
  } else {
25
- insertDatasource(state, newAdf, view);
34
+ insertDatasource(state, newAdf, view, analyticEvent);
26
35
  }
27
36
  }, [existingNode, state, view]);
28
37
  if (modalType === 'jira') {
@@ -19,8 +19,9 @@ function getSearchMethod(creationMethod, metadata) {
19
19
  sourceEvent
20
20
  } = metadata;
21
21
  if (sourceEvent instanceof UIAnalyticsEvent) {
22
+ var _event$payload$attrib;
22
23
  const event = sourceEvent;
23
- return event.payload.searchMethod;
24
+ return (_event$payload$attrib = event.payload.attributes) === null || _event$payload$attrib === void 0 ? void 0 : _event$payload$attrib.searchMethod;
24
25
  }
25
26
  return 'unknown';
26
27
  }
@@ -41,8 +42,9 @@ function getAnalyticAttributesFromNode(datasourceAttrs, metadata) {
41
42
  inputMethod: metadata.inputMethod
42
43
  })) !== null && _getMethod !== void 0 ? _getMethod : '';
43
44
  } else if (metadata.sourceEvent instanceof UIAnalyticsEvent) {
44
- inputMethod = metadata.sourceEvent.payload.inputMethod;
45
- actions = metadata.sourceEvent.payload.actions;
45
+ var _metadata$sourceEvent, _metadata$sourceEvent2;
46
+ inputMethod = (_metadata$sourceEvent = metadata.sourceEvent.payload.attributes) === null || _metadata$sourceEvent === void 0 ? void 0 : _metadata$sourceEvent.inputMethod;
47
+ actions = (_metadata$sourceEvent2 = metadata.sourceEvent.payload.attributes) === null || _metadata$sourceEvent2 === void 0 ? void 0 : _metadata$sourceEvent2.actions;
46
48
  }
47
49
  const displayedColumnCount = getDisplayedColumnCount(datasourceAttrs);
48
50
  const searchMethod = getSearchMethod(inputMethod, metadata);
@@ -1,4 +1,7 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2
5
  import React, { useCallback } from 'react';
3
6
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
4
7
  import { ASSETS_LIST_OF_LINKS_DATASOURCE_ID, AssetsConfigModal, JIRA_LIST_OF_LINKS_DATASOURCE_ID, JiraIssuesConfigModal } from '@atlaskit/link-datasource';
@@ -14,11 +17,20 @@ export var DatasourceModal = function DatasourceModal(_ref) {
14
17
  var onClose = useCallback(function () {
15
18
  dispatch(hideDatasourceModal(state.tr));
16
19
  }, [dispatch, state.tr]);
17
- var onInsert = useCallback(function (newAdf) {
20
+ var onInsert = useCallback(function (newAdf, analyticEvent) {
21
+ if (analyticEvent) {
22
+ analyticEvent.update(function (payload) {
23
+ return _objectSpread(_objectSpread({}, payload), {}, {
24
+ attributes: _objectSpread(_objectSpread({}, payload.attributes), {}, {
25
+ inputMethod: 'datasource_config'
26
+ })
27
+ });
28
+ });
29
+ }
18
30
  if (existingNode) {
19
- updateCardFromDatasourceModal(state, existingNode, newAdf, view);
31
+ updateCardFromDatasourceModal(state, existingNode, newAdf, view, analyticEvent);
20
32
  } else {
21
- insertDatasource(state, newAdf, view);
33
+ insertDatasource(state, newAdf, view, analyticEvent);
22
34
  }
23
35
  }, [existingNode, state, view]);
24
36
  if (modalType === 'jira') {
@@ -22,8 +22,9 @@ function getSearchMethod(creationMethod, metadata) {
22
22
  }
23
23
  var sourceEvent = metadata.sourceEvent;
24
24
  if (sourceEvent instanceof UIAnalyticsEvent) {
25
+ var _event$payload$attrib;
25
26
  var event = sourceEvent;
26
- return event.payload.searchMethod;
27
+ return (_event$payload$attrib = event.payload.attributes) === null || _event$payload$attrib === void 0 ? void 0 : _event$payload$attrib.searchMethod;
27
28
  }
28
29
  return 'unknown';
29
30
  }
@@ -41,8 +42,9 @@ function getAnalyticAttributesFromNode(datasourceAttrs, metadata) {
41
42
  inputMethod: metadata.inputMethod
42
43
  })) !== null && _getMethod !== void 0 ? _getMethod : '';
43
44
  } else if (metadata.sourceEvent instanceof UIAnalyticsEvent) {
44
- inputMethod = metadata.sourceEvent.payload.inputMethod;
45
- actions = metadata.sourceEvent.payload.actions;
45
+ var _metadata$sourceEvent, _metadata$sourceEvent2;
46
+ inputMethod = (_metadata$sourceEvent = metadata.sourceEvent.payload.attributes) === null || _metadata$sourceEvent === void 0 ? void 0 : _metadata$sourceEvent.inputMethod;
47
+ actions = (_metadata$sourceEvent2 = metadata.sourceEvent.payload.attributes) === null || _metadata$sourceEvent2 === void 0 ? void 0 : _metadata$sourceEvent2.actions;
46
48
  }
47
49
  var displayedColumnCount = getDisplayedColumnCount(datasourceAttrs);
48
50
  var searchMethod = getSearchMethod(inputMethod, metadata);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-card",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "Card plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -45,7 +45,7 @@
45
45
  "@atlaskit/editor-shared-styles": "^2.6.0",
46
46
  "@atlaskit/icon": "^21.12.0",
47
47
  "@atlaskit/link-analytics": "^8.3.0",
48
- "@atlaskit/link-datasource": "^1.1.0",
48
+ "@atlaskit/link-datasource": "^1.2.0",
49
49
  "@atlaskit/platform-feature-flags": "^0.2.0",
50
50
  "@atlaskit/smart-card": "^26.26.0",
51
51
  "@atlaskit/theme": "^12.6.0",