@atlaskit/editor-plugin-card 1.10.3 → 1.11.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,23 @@
1
1
  # @atlaskit/editor-plugin-card
2
2
 
3
+ ## 1.11.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#97537](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/97537)
8
+ [`7d76404fde3f`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/7d76404fde3f) -
9
+ Fix a bug where the confluence search config modal may appear to be empty when opening an
10
+ existing inline link.
11
+ - Updated dependencies
12
+
13
+ ## 1.11.0
14
+
15
+ ### Minor Changes
16
+
17
+ - [#97997](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/97997)
18
+ [`ee970964e1f2`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/ee970964e1f2) -
19
+ [ux] Replaces the Datasources Toolbar TableIcon with a new custom Icon
20
+
3
21
  ## 1.10.3
4
22
 
5
23
  ### Patch Changes
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
@@ -11,13 +10,13 @@ var _messages = require("@atlaskit/editor-common/messages");
11
10
  var _ui = require("@atlaskit/editor-common/ui");
12
11
  var _utils = require("@atlaskit/editor-common/utils");
13
12
  var _state = require("@atlaskit/editor-prosemirror/state");
14
- var _table = _interopRequireDefault(require("@atlaskit/icon/glyph/table"));
15
13
  var _linkDatasource = require("@atlaskit/link-datasource");
16
14
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
17
15
  var _primitives = require("@atlaskit/primitives");
18
16
  var _doc = require("../pm-plugins/doc");
19
17
  var _pluginKey = require("../pm-plugins/plugin-key");
20
18
  var _CardContextProvider = require("./CardContextProvider");
19
+ var _DatasourceIcon = require("./DatasourceIcon");
21
20
  var _useFetchDatasourceInfo = require("./useFetchDatasourceInfo");
22
21
  /** @jsx jsx */
23
22
 
@@ -97,7 +96,7 @@ var DatasourceAppearanceButtonWithCardContext = function DatasourceAppearanceBut
97
96
  return (0, _react2.jsx)(_primitives.Flex, null, (0, _react2.jsx)(_ui.FloatingToolbarButton, {
98
97
  css: buttonStyles,
99
98
  title: buttonLabel,
100
- icon: (0, _react2.jsx)(_table.default, {
99
+ icon: (0, _react2.jsx)(_DatasourceIcon.DatasourceIcon, {
101
100
  label: buttonLabel
102
101
  }),
103
102
  selected: selected,
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.DatasourceIcon = void 0;
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+ var _react = _interopRequireDefault(require("react"));
10
+ var _icon = _interopRequireDefault(require("@atlaskit/icon"));
11
+ var _primitives = require("@atlaskit/primitives");
12
+ var IconDatasourceGlyph = function IconDatasourceGlyph(props) {
13
+ return /*#__PURE__*/_react.default.createElement("svg", (0, _extends2.default)({
14
+ xmlns: "http://www.w3.org/2000/svg",
15
+ width: "15",
16
+ height: "15",
17
+ viewBox: "0 0 15 15",
18
+ fill: "none"
19
+ }, props), /*#__PURE__*/_react.default.createElement("path", {
20
+ fillRule: "evenodd",
21
+ clipRule: "evenodd",
22
+ d: "M0 2C0 0.89543 0.895431 0 2 0H13C14.1046 0 15 0.895431 15 2V13C15 14.1046 14.1046 15 13 15H2C0.89543 15 0 14.1046 0 13V2ZM5 6C5 5.44772 5.44772 5 6 5L12 5C12.5523 5 13 5.44772 13 6C13 6.55229 12.5523 7 12 7L6 7C5.44772 7 5 6.55228 5 6ZM6 8C5.44772 8 5 8.44771 5 9C5 9.55228 5.44772 10 6 10L12 10C12.5523 10 13 9.55229 13 9C13 8.44772 12.5523 8 12 8L6 8ZM5 12C5 11.4477 5.44772 11 6 11L12 11C12.5523 11 13 11.4477 13 12C13 12.5523 12.5523 13 12 13L6 13C5.44772 13 5 12.5523 5 12ZM3 7C3.55228 7 4 6.55228 4 6C4 5.44772 3.55228 5 3 5C2.44772 5 2 5.44772 2 6C2 6.55228 2.44772 7 3 7ZM5 3C5 2.44772 5.44772 2 6 2L12 2C12.5523 2 13 2.44772 13 3C13 3.55229 12.5523 4 12 4L6 4C5.44772 4 5 3.55228 5 3ZM3 4C3.55228 4 4 3.55228 4 3C4 2.44772 3.55228 2 3 2C2.44772 2 2 2.44772 2 3C2 3.55228 2.44772 4 3 4ZM4 9C4 9.55229 3.55228 10 3 10C2.44772 10 2 9.55229 2 9C2 8.44771 2.44772 8 3 8C3.55228 8 4 8.44771 4 9ZM3 13C3.55228 13 4 12.5523 4 12C4 11.4477 3.55228 11 3 11C2.44772 11 2 11.4477 2 12C2 12.5523 2.44772 13 3 13Z",
23
+ fill: 'currentColor'
24
+ }));
25
+ };
26
+ var wrapperStyles = (0, _primitives.xcss)({
27
+ padding: 'space.050',
28
+ justifyContent: 'center',
29
+ alignItems: 'center',
30
+ width: 'space.300',
31
+ height: 'space.300'
32
+ });
33
+ var DatasourceIcon = exports.DatasourceIcon = function DatasourceIcon(props) {
34
+ return /*#__PURE__*/_react.default.createElement(_primitives.Flex, {
35
+ xcss: wrapperStyles
36
+ }, /*#__PURE__*/_react.default.createElement(_icon.default, (0, _extends2.default)({
37
+ glyph: IconDatasourceGlyph
38
+ }, props)));
39
+ };
@@ -4,9 +4,10 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.default = void 0;
7
+ exports.modalTypeToComponentMap = exports.default = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
  var _hooks = require("@atlaskit/editor-common/hooks");
10
+ var _linkDatasource = require("@atlaskit/link-datasource");
10
11
  var _datasourceErrorBoundary = require("../../datasourceErrorBoundary");
11
12
  var _CardContextProvider = require("../CardContextProvider");
12
13
  var _index = require("./index");
@@ -15,19 +16,42 @@ var ModalWithState = function ModalWithState(_ref) {
15
16
  editorView = _ref.editorView;
16
17
  var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['card']),
17
18
  cardState = _useSharedPluginState.cardState;
18
- if (!(cardState !== null && cardState !== void 0 && cardState.showDatasourceModal)) {
19
+ if (!cardState) {
19
20
  return null;
20
21
  }
22
+ var showDatasourceModal = cardState.showDatasourceModal,
23
+ datasourceModalType = cardState.datasourceModalType;
24
+ if (!showDatasourceModal || !datasourceModalType) {
25
+ return null;
26
+ }
27
+ var _modalTypeToComponent = modalTypeToComponentMap[datasourceModalType],
28
+ datasourceId = _modalTypeToComponent.datasourceId,
29
+ componentType = _modalTypeToComponent.componentType;
21
30
  return /*#__PURE__*/_react.default.createElement(_datasourceErrorBoundary.DatasourceErrorBoundary, {
22
31
  view: editorView,
23
- datasourceModalType: cardState === null || cardState === void 0 ? void 0 : cardState.datasourceModalType
32
+ datasourceModalType: datasourceModalType
24
33
  }, /*#__PURE__*/_react.default.createElement(_CardContextProvider.CardContextProvider, null, function (_ref2) {
25
34
  var cardContext = _ref2.cardContext;
26
35
  return /*#__PURE__*/_react.default.createElement(_index.DatasourceModal, {
27
36
  view: editorView,
28
- modalType: cardState === null || cardState === void 0 ? void 0 : cardState.datasourceModalType,
29
- cardContext: cardContext
37
+ cardContext: cardContext,
38
+ datasourceId: datasourceId,
39
+ componentType: componentType
30
40
  });
31
41
  }));
32
42
  };
43
+ var modalTypeToComponentMap = exports.modalTypeToComponentMap = {
44
+ jira: {
45
+ componentType: _linkDatasource.JiraIssuesConfigModal,
46
+ datasourceId: _linkDatasource.JIRA_LIST_OF_LINKS_DATASOURCE_ID
47
+ },
48
+ 'confluence-search': {
49
+ componentType: _linkDatasource.ConfluenceSearchConfigModal,
50
+ datasourceId: _linkDatasource.CONFLUENCE_SEARCH_DATASOURCE_ID
51
+ },
52
+ assets: {
53
+ componentType: _linkDatasource.AssetsConfigModal,
54
+ datasourceId: _linkDatasource.ASSETS_LIST_OF_LINKS_DATASOURCE_ID
55
+ }
56
+ };
33
57
  var _default = exports.default = ModalWithState;
@@ -10,7 +10,6 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
10
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
11
  var _react = _interopRequireWildcard(require("react"));
12
12
  var _state = require("@atlaskit/editor-prosemirror/state");
13
- var _linkDatasource = require("@atlaskit/link-datasource");
14
13
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
15
14
  var _actions = require("../../pm-plugins/actions");
16
15
  var _doc = require("../../pm-plugins/doc");
@@ -23,44 +22,56 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
23
22
  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; }
24
23
  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; }
25
24
  var DatasourceModal = exports.DatasourceModal = function DatasourceModal(_ref) {
26
- var _existingNode, _existingNode2, _existingNode3;
25
+ var _existingNode$attrs, _existingNode$attrs2;
27
26
  var view = _ref.view,
28
- modalType = _ref.modalType,
29
- cardContext = _ref.cardContext;
27
+ cardContext = _ref.cardContext,
28
+ defaultDatasourceId = _ref.datasourceId,
29
+ Component = _ref.componentType;
30
+ var state = view.state;
31
+ var existingNode = getExistingNode(state);
30
32
  var dispatch = view.dispatch,
31
- state = view.state;
32
- var selection = state.selection;
33
- var existingNode;
34
- if ((0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.enable-datasource-appearance-toolbar')) {
35
- // Check if the selection contains a link mark
36
- var $pos = state.doc.resolve(selection.from);
37
- var isLinkMark = $pos.marks().some(function (mark) {
38
- return mark.type === state.schema.marks.link;
39
- });
40
-
41
- // When selection is a TextNode and a link Mark is present return that node
42
- if (selection instanceof _state.NodeSelection) {
43
- existingNode = selection.node;
44
- } else if (isLinkMark) {
45
- var _state$doc$nodeAt;
46
- existingNode = (_state$doc$nodeAt = state.doc.nodeAt(selection.from)) !== null && _state$doc$nodeAt !== void 0 ? _state$doc$nodeAt : undefined;
47
- }
48
- } else {
49
- existingNode = selection instanceof _state.NodeSelection ? selection.node : undefined;
50
- }
51
- var isRegularCardNode = !!(existingNode && !((_existingNode = existingNode) !== null && _existingNode !== void 0 && (_existingNode = _existingNode.attrs) !== null && _existingNode !== void 0 && _existingNode.datasource));
33
+ transaction = view.state.tr;
34
+ var onClose = (0, _react.useCallback)(function () {
35
+ dispatch((0, _actions.hideDatasourceModal)(transaction));
36
+ }, [dispatch, transaction]);
37
+ var onInsert = useOnInsert(view, existingNode);
38
+ var isRegularCardNode = !!(existingNode && !(existingNode !== null && existingNode !== void 0 && (_existingNode$attrs = existingNode.attrs) !== null && _existingNode$attrs !== void 0 && _existingNode$attrs.datasource));
39
+ var _ref2 = (existingNode === null || existingNode === void 0 || (_existingNode$attrs2 = existingNode.attrs) === null || _existingNode$attrs2 === void 0 ? void 0 : _existingNode$attrs2.datasource) || {},
40
+ _ref2$id = _ref2.id,
41
+ datasourceId = _ref2$id === void 0 ? defaultDatasourceId : _ref2$id,
42
+ _ref2$views = _ref2.views,
43
+ views = _ref2$views === void 0 ? [] : _ref2$views,
44
+ nodeParameters = _ref2.parameters;
45
+ var _resolveColumnsConfig = resolveColumnsConfig(views),
46
+ visibleColumnKeys = _resolveColumnsConfig.visibleColumnKeys,
47
+ wrappedColumnKeys = _resolveColumnsConfig.wrappedColumnKeys,
48
+ columnCustomSizes = _resolveColumnsConfig.columnCustomSizes;
52
49
  var _useFetchDatasourceIn = (0, _useFetchDatasourceInfo.useFetchDatasourceInfo)({
53
50
  isRegularCardNode: isRegularCardNode,
54
- url: (_existingNode2 = existingNode) === null || _existingNode2 === void 0 ? void 0 : _existingNode2.attrs.url,
51
+ url: existingNode === null || existingNode === void 0 ? void 0 : existingNode.attrs.url,
55
52
  cardContext: cardContext,
56
- nodeParameters: (_existingNode3 = existingNode) === null || _existingNode3 === void 0 || (_existingNode3 = _existingNode3.attrs) === null || _existingNode3 === void 0 || (_existingNode3 = _existingNode3.datasource) === null || _existingNode3 === void 0 ? void 0 : _existingNode3.parameters
53
+ nodeParameters: nodeParameters
57
54
  }),
58
55
  parameters = _useFetchDatasourceIn.parameters,
59
56
  ready = _useFetchDatasourceIn.ready;
60
- var onClose = (0, _react.useCallback)(function () {
61
- dispatch((0, _actions.hideDatasourceModal)(view.state.tr));
62
- }, [dispatch, view.state.tr]);
63
- var onInsert = (0, _react.useCallback)(function (newAdf, analyticEvent) {
57
+ if (!ready) {
58
+ return null;
59
+ }
60
+ return /*#__PURE__*/_react.default.createElement(Component, {
61
+ datasourceId: datasourceId,
62
+ viewMode: isRegularCardNode ? 'inline' : 'table' // Want non-datasource cards to open in inline view since they are in table view
63
+ ,
64
+ parameters: parameters,
65
+ url: existingNode === null || existingNode === void 0 ? void 0 : existingNode.attrs.url,
66
+ visibleColumnKeys: visibleColumnKeys,
67
+ columnCustomSizes: columnCustomSizes,
68
+ wrappedColumnKeys: wrappedColumnKeys,
69
+ onCancel: onClose,
70
+ onInsert: onInsert
71
+ });
72
+ };
73
+ var useOnInsert = function useOnInsert(view, existingNode) {
74
+ return (0, _react.useCallback)(function (newAdf, analyticEvent) {
64
75
  if (analyticEvent) {
65
76
  analyticEvent.update(function (payload) {
66
77
  return _objectSpread(_objectSpread({}, payload), {}, {
@@ -82,143 +93,63 @@ var DatasourceModal = exports.DatasourceModal = function DatasourceModal(_ref) {
82
93
  (0, _doc.insertDatasource)(view.state, newAdf, view, analyticEvent);
83
94
  }
84
95
  }, [existingNode, view]);
85
- if (modalType === 'jira') {
86
- var _existingNode4, _tableView$properties, _existingNode5;
87
- if (!ready) {
88
- return null;
89
- }
90
- var _ref2 = ((_existingNode4 = existingNode) === null || _existingNode4 === void 0 || (_existingNode4 = _existingNode4.attrs) === null || _existingNode4 === void 0 ? void 0 : _existingNode4.datasource) || {},
91
- _ref2$id = _ref2.id,
92
- datasourceId = _ref2$id === void 0 ? _linkDatasource.JIRA_LIST_OF_LINKS_DATASOURCE_ID : _ref2$id,
93
- _ref2$views = _ref2.views,
94
- views = _ref2$views === void 0 ? [] : _ref2$views;
95
- var _ref3 = views,
96
- _ref4 = (0, _slicedToArray2.default)(_ref3, 1),
97
- tableView = _ref4[0];
98
- var visibleColumnKeys = [];
99
- var wrappedColumnKeys = [];
100
- var columnCustomSizes;
101
- var columns = tableView === null || tableView === void 0 || (_tableView$properties = tableView.properties) === null || _tableView$properties === void 0 ? void 0 : _tableView$properties.columns;
102
- if (columns) {
103
- columnCustomSizes = {};
104
- var _iterator = _createForOfIteratorHelper(columns),
105
- _step;
106
- try {
107
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
108
- var _step$value = _step.value,
109
- _key = _step$value.key,
110
- width = _step$value.width,
111
- isWrapped = _step$value.isWrapped;
112
- visibleColumnKeys.push(_key);
113
- if (width) {
114
- columnCustomSizes[_key] = width;
115
- }
116
- if (isWrapped) {
117
- wrappedColumnKeys.push(_key);
118
- }
119
- }
120
- } catch (err) {
121
- _iterator.e(err);
122
- } finally {
123
- _iterator.f();
124
- }
125
- }
126
- return /*#__PURE__*/_react.default.createElement("div", {
127
- "data-testid": "jira-config-modal"
128
- }, /*#__PURE__*/_react.default.createElement(_linkDatasource.JiraIssuesConfigModal, {
129
- datasourceId: datasourceId,
130
- viewMode: isRegularCardNode ? 'inline' : 'table' // Want non-datasource cards to open in inline view since they are in table view
131
- ,
132
- visibleColumnKeys: visibleColumnKeys,
133
- parameters: parameters,
134
- url: (_existingNode5 = existingNode) === null || _existingNode5 === void 0 ? void 0 : _existingNode5.attrs.url,
135
- columnCustomSizes: columnCustomSizes,
136
- wrappedColumnKeys: wrappedColumnKeys,
137
- onCancel: onClose,
138
- onInsert: onInsert
139
- }));
140
- }
141
- if (modalType === 'assets') {
142
- var _existingNode6, _tableView$properties2;
143
- var _ref5 = ((_existingNode6 = existingNode) === null || _existingNode6 === void 0 || (_existingNode6 = _existingNode6.attrs) === null || _existingNode6 === void 0 ? void 0 : _existingNode6.datasource) || {},
144
- _ref5$id = _ref5.id,
145
- _datasourceId = _ref5$id === void 0 ? _linkDatasource.ASSETS_LIST_OF_LINKS_DATASOURCE_ID : _ref5$id,
146
- _parameters = _ref5.parameters,
147
- _ref5$views = _ref5.views,
148
- _views = _ref5$views === void 0 ? [] : _ref5$views;
149
- var _ref6 = _views,
150
- _ref7 = (0, _slicedToArray2.default)(_ref6, 1),
151
- _tableView = _ref7[0];
152
- var _visibleColumnKeys = _tableView === null || _tableView === void 0 || (_tableView$properties2 = _tableView.properties) === null || _tableView$properties2 === void 0 ? void 0 : _tableView$properties2.columns.map(function (column) {
153
- return column.key;
96
+ };
97
+ var getExistingNode = function getExistingNode(state) {
98
+ var selection = state.selection;
99
+ var existingNode;
100
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.enable-datasource-appearance-toolbar')) {
101
+ // Check if the selection contains a link mark
102
+ var isLinkMark = state.doc.resolve(selection.from).marks().some(function (mark) {
103
+ return mark.type === state.schema.marks.link;
154
104
  });
155
- return /*#__PURE__*/_react.default.createElement("div", {
156
- "data-testid": "assets-config-modal"
157
- }, /*#__PURE__*/_react.default.createElement(_linkDatasource.AssetsConfigModal, {
158
- datasourceId: _datasourceId,
159
- visibleColumnKeys: _visibleColumnKeys,
160
- parameters: _parameters,
161
- onCancel: onClose,
162
- onInsert: onInsert
163
- }));
164
- }
165
105
 
166
- // TODO: further refactor in https://product-fabric.atlassian.net/browse/EDM-9637
167
- if (modalType === 'confluence-search') {
168
- var _existingNode7, _tableView2$propertie, _existingNode8;
169
- if (!ready) {
170
- return null;
106
+ // When selection is a TextNode and a link Mark is present return that node
107
+ if (selection instanceof _state.NodeSelection) {
108
+ existingNode = selection.node;
109
+ } else if (isLinkMark) {
110
+ var _state$doc$nodeAt;
111
+ existingNode = (_state$doc$nodeAt = state.doc.nodeAt(selection.from)) !== null && _state$doc$nodeAt !== void 0 ? _state$doc$nodeAt : undefined;
171
112
  }
172
- var _ref8 = ((_existingNode7 = existingNode) === null || _existingNode7 === void 0 || (_existingNode7 = _existingNode7.attrs) === null || _existingNode7 === void 0 ? void 0 : _existingNode7.datasource) || {},
173
- _ref8$id = _ref8.id,
174
- _datasourceId2 = _ref8$id === void 0 ? _linkDatasource.CONFLUENCE_SEARCH_DATASOURCE_ID : _ref8$id,
175
- _parameters2 = _ref8.parameters,
176
- _ref8$views = _ref8.views,
177
- _views2 = _ref8$views === void 0 ? [] : _ref8$views;
178
- var _ref9 = _views2,
179
- _ref10 = (0, _slicedToArray2.default)(_ref9, 1),
180
- _tableView2 = _ref10[0];
181
- var _visibleColumnKeys2 = [];
182
- var _wrappedColumnKeys = [];
183
- var _columnCustomSizes;
184
- var _columns = _tableView2 === null || _tableView2 === void 0 || (_tableView2$propertie = _tableView2.properties) === null || _tableView2$propertie === void 0 ? void 0 : _tableView2$propertie.columns;
185
- if (_columns) {
186
- _columnCustomSizes = {};
187
- var _iterator2 = _createForOfIteratorHelper(_columns),
188
- _step2;
189
- try {
190
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
191
- var _step2$value = _step2.value,
192
- _key2 = _step2$value.key,
193
- _width = _step2$value.width,
194
- _isWrapped = _step2$value.isWrapped;
195
- _visibleColumnKeys2.push(_key2);
196
- if (_width) {
197
- _columnCustomSizes[_key2] = _width;
198
- }
199
- if (_isWrapped) {
200
- _wrappedColumnKeys.push(_key2);
201
- }
113
+ } else {
114
+ existingNode = selection instanceof _state.NodeSelection ? selection.node : undefined;
115
+ }
116
+ return existingNode;
117
+ };
118
+ var resolveColumnsConfig = function resolveColumnsConfig(views) {
119
+ var _tableView$properties;
120
+ var _views = (0, _slicedToArray2.default)(views, 1),
121
+ tableView = _views[0];
122
+ var visibleColumnKeys = [];
123
+ var wrappedColumnKeys = [];
124
+ var columnCustomSizes;
125
+ var columns = tableView === null || tableView === void 0 || (_tableView$properties = tableView.properties) === null || _tableView$properties === void 0 ? void 0 : _tableView$properties.columns;
126
+ if (columns) {
127
+ columnCustomSizes = {};
128
+ var _iterator = _createForOfIteratorHelper(columns),
129
+ _step;
130
+ try {
131
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
132
+ var _step$value = _step.value,
133
+ _key = _step$value.key,
134
+ width = _step$value.width,
135
+ isWrapped = _step$value.isWrapped;
136
+ visibleColumnKeys.push(_key);
137
+ if (width) {
138
+ columnCustomSizes[_key] = width;
139
+ }
140
+ if (isWrapped) {
141
+ wrappedColumnKeys.push(_key);
202
142
  }
203
- } catch (err) {
204
- _iterator2.e(err);
205
- } finally {
206
- _iterator2.f();
207
143
  }
144
+ } catch (err) {
145
+ _iterator.e(err);
146
+ } finally {
147
+ _iterator.f();
208
148
  }
209
- return /*#__PURE__*/_react.default.createElement("div", {
210
- "data-testid": "confluence-search-config-modal"
211
- }, /*#__PURE__*/_react.default.createElement(_linkDatasource.ConfluenceSearchConfigModal, {
212
- datasourceId: _datasourceId2,
213
- viewMode: isRegularCardNode ? 'inline' : 'table',
214
- visibleColumnKeys: _visibleColumnKeys2,
215
- parameters: _parameters2,
216
- url: (_existingNode8 = existingNode) === null || _existingNode8 === void 0 ? void 0 : _existingNode8.attrs.url,
217
- columnCustomSizes: _columnCustomSizes,
218
- wrappedColumnKeys: _wrappedColumnKeys,
219
- onCancel: onClose,
220
- onInsert: onInsert
221
- }));
222
149
  }
223
- return null; // null for now until we have modal component that handles other datasources
150
+ return {
151
+ visibleColumnKeys: visibleColumnKeys,
152
+ wrappedColumnKeys: wrappedColumnKeys,
153
+ columnCustomSizes: columnCustomSizes
154
+ };
224
155
  };
@@ -5,13 +5,13 @@ import { cardMessages as messages } from '@atlaskit/editor-common/messages';
5
5
  import { FloatingToolbarButton as Button } from '@atlaskit/editor-common/ui';
6
6
  import { canRenderDatasource } from '@atlaskit/editor-common/utils';
7
7
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
8
- import TableIcon from '@atlaskit/icon/glyph/table';
9
8
  import { buildDatasourceAdf } from '@atlaskit/link-datasource';
10
9
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
11
10
  import { Flex } from '@atlaskit/primitives';
12
11
  import { updateCardViaDatasource } from '../pm-plugins/doc';
13
12
  import { pluginKey } from '../pm-plugins/plugin-key';
14
13
  import { CardContextProvider } from './CardContextProvider';
14
+ import { DatasourceIcon } from './DatasourceIcon';
15
15
  import { useFetchDatasourceInfo } from './useFetchDatasourceInfo';
16
16
  const buttonStyles = css({
17
17
  pointerEvents: 'auto'
@@ -91,7 +91,7 @@ const DatasourceAppearanceButtonWithCardContext = ({
91
91
  return jsx(Flex, null, jsx(Button, {
92
92
  css: buttonStyles,
93
93
  title: buttonLabel,
94
- icon: jsx(TableIcon, {
94
+ icon: jsx(DatasourceIcon, {
95
95
  label: buttonLabel
96
96
  }),
97
97
  selected: selected,
@@ -0,0 +1,32 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import React from 'react';
3
+ import Icon from '@atlaskit/icon';
4
+ import { Flex, xcss } from '@atlaskit/primitives';
5
+ const IconDatasourceGlyph = props => {
6
+ return /*#__PURE__*/React.createElement("svg", _extends({
7
+ xmlns: "http://www.w3.org/2000/svg",
8
+ width: "15",
9
+ height: "15",
10
+ viewBox: "0 0 15 15",
11
+ fill: "none"
12
+ }, props), /*#__PURE__*/React.createElement("path", {
13
+ fillRule: "evenodd",
14
+ clipRule: "evenodd",
15
+ d: "M0 2C0 0.89543 0.895431 0 2 0H13C14.1046 0 15 0.895431 15 2V13C15 14.1046 14.1046 15 13 15H2C0.89543 15 0 14.1046 0 13V2ZM5 6C5 5.44772 5.44772 5 6 5L12 5C12.5523 5 13 5.44772 13 6C13 6.55229 12.5523 7 12 7L6 7C5.44772 7 5 6.55228 5 6ZM6 8C5.44772 8 5 8.44771 5 9C5 9.55228 5.44772 10 6 10L12 10C12.5523 10 13 9.55229 13 9C13 8.44772 12.5523 8 12 8L6 8ZM5 12C5 11.4477 5.44772 11 6 11L12 11C12.5523 11 13 11.4477 13 12C13 12.5523 12.5523 13 12 13L6 13C5.44772 13 5 12.5523 5 12ZM3 7C3.55228 7 4 6.55228 4 6C4 5.44772 3.55228 5 3 5C2.44772 5 2 5.44772 2 6C2 6.55228 2.44772 7 3 7ZM5 3C5 2.44772 5.44772 2 6 2L12 2C12.5523 2 13 2.44772 13 3C13 3.55229 12.5523 4 12 4L6 4C5.44772 4 5 3.55228 5 3ZM3 4C3.55228 4 4 3.55228 4 3C4 2.44772 3.55228 2 3 2C2.44772 2 2 2.44772 2 3C2 3.55228 2.44772 4 3 4ZM4 9C4 9.55229 3.55228 10 3 10C2.44772 10 2 9.55229 2 9C2 8.44771 2.44772 8 3 8C3.55228 8 4 8.44771 4 9ZM3 13C3.55228 13 4 12.5523 4 12C4 11.4477 3.55228 11 3 11C2.44772 11 2 11.4477 2 12C2 12.5523 2.44772 13 3 13Z",
16
+ fill: 'currentColor'
17
+ }));
18
+ };
19
+ const wrapperStyles = xcss({
20
+ padding: 'space.050',
21
+ justifyContent: 'center',
22
+ alignItems: 'center',
23
+ width: 'space.300',
24
+ height: 'space.300'
25
+ });
26
+ export const DatasourceIcon = props => {
27
+ return /*#__PURE__*/React.createElement(Flex, {
28
+ xcss: wrapperStyles
29
+ }, /*#__PURE__*/React.createElement(Icon, _extends({
30
+ glyph: IconDatasourceGlyph
31
+ }, props)));
32
+ };
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
3
+ import { ASSETS_LIST_OF_LINKS_DATASOURCE_ID, AssetsConfigModal, CONFLUENCE_SEARCH_DATASOURCE_ID, ConfluenceSearchConfigModal, JIRA_LIST_OF_LINKS_DATASOURCE_ID, JiraIssuesConfigModal } from '@atlaskit/link-datasource';
3
4
  import { DatasourceErrorBoundary } from '../../datasourceErrorBoundary';
4
5
  import { CardContextProvider } from '../CardContextProvider';
5
6
  import { DatasourceModal } from './index';
@@ -10,18 +11,44 @@ const ModalWithState = ({
10
11
  const {
11
12
  cardState
12
13
  } = useSharedPluginState(api, ['card']);
13
- if (!(cardState !== null && cardState !== void 0 && cardState.showDatasourceModal)) {
14
+ if (!cardState) {
14
15
  return null;
15
16
  }
17
+ const {
18
+ showDatasourceModal,
19
+ datasourceModalType
20
+ } = cardState;
21
+ if (!showDatasourceModal || !datasourceModalType) {
22
+ return null;
23
+ }
24
+ const {
25
+ datasourceId,
26
+ componentType
27
+ } = modalTypeToComponentMap[datasourceModalType];
16
28
  return /*#__PURE__*/React.createElement(DatasourceErrorBoundary, {
17
29
  view: editorView,
18
- datasourceModalType: cardState === null || cardState === void 0 ? void 0 : cardState.datasourceModalType
30
+ datasourceModalType: datasourceModalType
19
31
  }, /*#__PURE__*/React.createElement(CardContextProvider, null, ({
20
32
  cardContext
21
33
  }) => /*#__PURE__*/React.createElement(DatasourceModal, {
22
34
  view: editorView,
23
- modalType: cardState === null || cardState === void 0 ? void 0 : cardState.datasourceModalType,
24
- cardContext: cardContext
35
+ cardContext: cardContext,
36
+ datasourceId: datasourceId,
37
+ componentType: componentType
25
38
  })));
26
39
  };
40
+ export const modalTypeToComponentMap = {
41
+ jira: {
42
+ componentType: JiraIssuesConfigModal,
43
+ datasourceId: JIRA_LIST_OF_LINKS_DATASOURCE_ID
44
+ },
45
+ 'confluence-search': {
46
+ componentType: ConfluenceSearchConfigModal,
47
+ datasourceId: CONFLUENCE_SEARCH_DATASOURCE_ID
48
+ },
49
+ assets: {
50
+ componentType: AssetsConfigModal,
51
+ datasourceId: ASSETS_LIST_OF_LINKS_DATASOURCE_ID
52
+ }
53
+ };
27
54
  export default ModalWithState;