@atlaskit/editor-plugin-card 0.2.3 → 0.2.4

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,11 @@
1
1
  # @atlaskit/editor-plugin-card
2
2
 
3
+ ## 0.2.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [`6255c2ad1c9`](https://bitbucket.org/atlassian/atlassian-frontend/commits/6255c2ad1c9) - [ux] Adds ability to open Assets datasource dialog using the slash command in the editor, behind a feature flag
8
+
3
9
  ## 0.2.3
4
10
 
5
11
  ### Patch Changes
@@ -15,6 +15,16 @@ var messages = (0, _reactIntlNext.defineMessages)({
15
15
  id: 'fabric.editor.datasource.jiraIssue.description',
16
16
  defaultMessage: 'Insert issues from Jira Cloud with enhanced search, filtering, and configuration',
17
17
  description: 'Insert a jira datasource table'
18
+ },
19
+ datasourceAssetsObjects: {
20
+ id: 'fabric.editor.datasource.assetsObjects',
21
+ defaultMessage: 'Assets',
22
+ description: 'Text displayed when selecting the type of data to include onto the page, in this case: JSM Assets objects'
23
+ },
24
+ datasourceAssetsObjectsDescription: {
25
+ id: 'fabric.editor.datasource.assetsObjects.description',
26
+ defaultMessage: 'Insert objects from Assets in Jira Service Management with search and filtering',
27
+ description: 'Description text displayed when selecting the type of data to include onto the page, in this case: JSM Assets objects'
18
28
  }
19
29
  });
20
30
  exports.messages = messages;
@@ -116,8 +116,12 @@ var cardPlugin = function cardPlugin(options, api) {
116
116
  floatingToolbar: (0, _toolbar.floatingToolbar)(options, featureFlags, options.platform, options.linkPicker, api),
117
117
  quickInsert: function quickInsert(_ref3) {
118
118
  var formatMessage = _ref3.formatMessage;
119
- if (options.allowDatasource && (0, _utils.canRenderDatasource)(_linkDatasource.JIRA_LIST_OF_LINKS_DATASOURCE_ID)) {
120
- return [{
119
+ var quickInsertArray = [];
120
+ if (!options.allowDatasource) {
121
+ return quickInsertArray;
122
+ }
123
+ if ((0, _utils.canRenderDatasource)(_linkDatasource.JIRA_LIST_OF_LINKS_DATASOURCE_ID)) {
124
+ quickInsertArray.push({
121
125
  id: 'datasource',
122
126
  title: formatMessage(_messages.messages.datasourceJiraIssue),
123
127
  description: formatMessage(_messages.messages.datasourceJiraIssueDescription),
@@ -130,9 +134,25 @@ var cardPlugin = function cardPlugin(options, api) {
130
134
  (0, _actions.showDatasourceModal)('jira')(tr);
131
135
  return tr;
132
136
  }
133
- }];
137
+ });
138
+ }
139
+ if ((0, _utils.canRenderDatasource)(_linkDatasource.ASSETS_LIST_OF_LINKS_DATASOURCE_ID)) {
140
+ quickInsertArray.push({
141
+ id: 'datasource',
142
+ title: formatMessage(_messages.messages.datasourceAssetsObjects),
143
+ description: formatMessage(_messages.messages.datasourceAssetsObjectsDescription),
144
+ keywords: ['assets'],
145
+ icon: function icon() {
146
+ return /*#__PURE__*/_react.default.createElement(_quickInsert.IconDatasourceAssetsObjects, null);
147
+ },
148
+ action: function action(insert) {
149
+ var tr = insert(undefined);
150
+ (0, _actions.showDatasourceModal)('assets')(tr);
151
+ return tr;
152
+ }
153
+ });
134
154
  }
135
- return [];
155
+ return quickInsertArray;
136
156
  }
137
157
  }
138
158
  };
@@ -55,6 +55,30 @@ var DatasourceModal = function DatasourceModal(_ref) {
55
55
  onInsert: onInsert
56
56
  }));
57
57
  }
58
+ if (modalType === 'assets') {
59
+ var _existingNode$attrs2, _tableView$properties2;
60
+ var _ref5 = (existingNode === null || existingNode === void 0 ? void 0 : (_existingNode$attrs2 = existingNode.attrs) === null || _existingNode$attrs2 === void 0 ? void 0 : _existingNode$attrs2.datasource) || {},
61
+ _ref5$id = _ref5.id,
62
+ _datasourceId = _ref5$id === void 0 ? _linkDatasource.ASSETS_LIST_OF_LINKS_DATASOURCE_ID : _ref5$id,
63
+ _parameters = _ref5.parameters,
64
+ _ref5$views = _ref5.views,
65
+ _views = _ref5$views === void 0 ? [] : _ref5$views;
66
+ var _ref6 = _views,
67
+ _ref7 = (0, _slicedToArray2.default)(_ref6, 1),
68
+ _tableView = _ref7[0];
69
+ var _visibleColumnKeys = _tableView === null || _tableView === void 0 ? void 0 : (_tableView$properties2 = _tableView.properties) === null || _tableView$properties2 === void 0 ? void 0 : _tableView$properties2.columns.map(function (column) {
70
+ return column.key;
71
+ });
72
+ return /*#__PURE__*/_react.default.createElement("div", {
73
+ "data-testid": "assets-config-modal"
74
+ }, /*#__PURE__*/_react.default.createElement(_linkDatasource.AssetsConfigModal, {
75
+ datasourceId: _datasourceId,
76
+ visibleColumnKeys: _visibleColumnKeys,
77
+ parameters: _parameters,
78
+ onCancel: onClose,
79
+ onInsert: onInsert
80
+ }));
81
+ }
58
82
  return null; // null for now until we have modal component that handles other datasources
59
83
  };
60
84
  exports.DatasourceModal = DatasourceModal;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-card",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "sideEffects": false
5
5
  }
@@ -9,5 +9,15 @@ export const messages = defineMessages({
9
9
  id: 'fabric.editor.datasource.jiraIssue.description',
10
10
  defaultMessage: 'Insert issues from Jira Cloud with enhanced search, filtering, and configuration',
11
11
  description: 'Insert a jira datasource table'
12
+ },
13
+ datasourceAssetsObjects: {
14
+ id: 'fabric.editor.datasource.assetsObjects',
15
+ defaultMessage: 'Assets',
16
+ description: 'Text displayed when selecting the type of data to include onto the page, in this case: JSM Assets objects'
17
+ },
18
+ datasourceAssetsObjectsDescription: {
19
+ id: 'fabric.editor.datasource.assetsObjects.description',
20
+ defaultMessage: 'Insert objects from Assets in Jira Service Management with search and filtering',
21
+ description: 'Description text displayed when selecting the type of data to include onto the page, in this case: JSM Assets objects'
12
22
  }
13
23
  });
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
2
  import { blockCard, embedCard, inlineCard } from '@atlaskit/adf-schema';
3
- import { IconDatasourceJiraIssue } from '@atlaskit/editor-common/quick-insert';
3
+ import { IconDatasourceAssetsObjects, IconDatasourceJiraIssue } from '@atlaskit/editor-common/quick-insert';
4
4
  import { canRenderDatasource } from '@atlaskit/editor-common/utils';
5
- import { JIRA_LIST_OF_LINKS_DATASOURCE_ID } from '@atlaskit/link-datasource';
5
+ import { ASSETS_LIST_OF_LINKS_DATASOURCE_ID, JIRA_LIST_OF_LINKS_DATASOURCE_ID } from '@atlaskit/link-datasource';
6
6
  import { messages } from './messages';
7
7
  import { hideLinkToolbar, showDatasourceModal } from './pm-plugins/actions';
8
8
  import { changeSelectedCardToLink, queueCardsFromChangedTr, setSelectedCardAppearance } from './pm-plugins/doc';
@@ -110,8 +110,12 @@ export const cardPlugin = (options, api) => {
110
110
  quickInsert: ({
111
111
  formatMessage
112
112
  }) => {
113
- if (options.allowDatasource && canRenderDatasource(JIRA_LIST_OF_LINKS_DATASOURCE_ID)) {
114
- return [{
113
+ const quickInsertArray = [];
114
+ if (!options.allowDatasource) {
115
+ return quickInsertArray;
116
+ }
117
+ if (canRenderDatasource(JIRA_LIST_OF_LINKS_DATASOURCE_ID)) {
118
+ quickInsertArray.push({
115
119
  id: 'datasource',
116
120
  title: formatMessage(messages.datasourceJiraIssue),
117
121
  description: formatMessage(messages.datasourceJiraIssueDescription),
@@ -122,9 +126,23 @@ export const cardPlugin = (options, api) => {
122
126
  showDatasourceModal('jira')(tr);
123
127
  return tr;
124
128
  }
125
- }];
129
+ });
130
+ }
131
+ if (canRenderDatasource(ASSETS_LIST_OF_LINKS_DATASOURCE_ID)) {
132
+ quickInsertArray.push({
133
+ id: 'datasource',
134
+ title: formatMessage(messages.datasourceAssetsObjects),
135
+ description: formatMessage(messages.datasourceAssetsObjectsDescription),
136
+ keywords: ['assets'],
137
+ icon: () => /*#__PURE__*/React.createElement(IconDatasourceAssetsObjects, null),
138
+ action(insert) {
139
+ const tr = insert(undefined);
140
+ showDatasourceModal('assets')(tr);
141
+ return tr;
142
+ }
143
+ });
126
144
  }
127
- return [];
145
+ return quickInsertArray;
128
146
  }
129
147
  }
130
148
  };
@@ -1,6 +1,6 @@
1
1
  import React, { useCallback } from 'react';
2
2
  import { NodeSelection } from 'prosemirror-state';
3
- import { JIRA_LIST_OF_LINKS_DATASOURCE_ID, JiraIssuesConfigModal } from '@atlaskit/link-datasource';
3
+ import { ASSETS_LIST_OF_LINKS_DATASOURCE_ID, AssetsConfigModal, JIRA_LIST_OF_LINKS_DATASOURCE_ID, JiraIssuesConfigModal } from '@atlaskit/link-datasource';
4
4
  import { hideDatasourceModal } from '../../pm-plugins/actions';
5
5
  import { insertDatasource, updateExistingDatasource } from '../../pm-plugins/doc';
6
6
  export const DatasourceModal = ({
@@ -44,5 +44,24 @@ export const DatasourceModal = ({
44
44
  onInsert: onInsert
45
45
  }));
46
46
  }
47
+ if (modalType === 'assets') {
48
+ var _existingNode$attrs2, _tableView$properties2;
49
+ const {
50
+ id: datasourceId = ASSETS_LIST_OF_LINKS_DATASOURCE_ID,
51
+ parameters,
52
+ views = []
53
+ } = (existingNode === null || existingNode === void 0 ? void 0 : (_existingNode$attrs2 = existingNode.attrs) === null || _existingNode$attrs2 === void 0 ? void 0 : _existingNode$attrs2.datasource) || {};
54
+ const [tableView] = views;
55
+ const visibleColumnKeys = tableView === null || tableView === void 0 ? void 0 : (_tableView$properties2 = tableView.properties) === null || _tableView$properties2 === void 0 ? void 0 : _tableView$properties2.columns.map(column => column.key);
56
+ return /*#__PURE__*/React.createElement("div", {
57
+ "data-testid": "assets-config-modal"
58
+ }, /*#__PURE__*/React.createElement(AssetsConfigModal, {
59
+ datasourceId: datasourceId,
60
+ visibleColumnKeys: visibleColumnKeys,
61
+ parameters: parameters,
62
+ onCancel: onClose,
63
+ onInsert: onInsert
64
+ }));
65
+ }
47
66
  return null; // null for now until we have modal component that handles other datasources
48
67
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-card",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "sideEffects": false
5
5
  }
@@ -9,5 +9,15 @@ export var messages = defineMessages({
9
9
  id: 'fabric.editor.datasource.jiraIssue.description',
10
10
  defaultMessage: 'Insert issues from Jira Cloud with enhanced search, filtering, and configuration',
11
11
  description: 'Insert a jira datasource table'
12
+ },
13
+ datasourceAssetsObjects: {
14
+ id: 'fabric.editor.datasource.assetsObjects',
15
+ defaultMessage: 'Assets',
16
+ description: 'Text displayed when selecting the type of data to include onto the page, in this case: JSM Assets objects'
17
+ },
18
+ datasourceAssetsObjectsDescription: {
19
+ id: 'fabric.editor.datasource.assetsObjects.description',
20
+ defaultMessage: 'Insert objects from Assets in Jira Service Management with search and filtering',
21
+ description: 'Description text displayed when selecting the type of data to include onto the page, in this case: JSM Assets objects'
12
22
  }
13
23
  });
@@ -3,9 +3,9 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
3
3
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
4
  import React from 'react';
5
5
  import { blockCard, embedCard, inlineCard } from '@atlaskit/adf-schema';
6
- import { IconDatasourceJiraIssue } from '@atlaskit/editor-common/quick-insert';
6
+ import { IconDatasourceAssetsObjects, IconDatasourceJiraIssue } from '@atlaskit/editor-common/quick-insert';
7
7
  import { canRenderDatasource } from '@atlaskit/editor-common/utils';
8
- import { JIRA_LIST_OF_LINKS_DATASOURCE_ID } from '@atlaskit/link-datasource';
8
+ import { ASSETS_LIST_OF_LINKS_DATASOURCE_ID, JIRA_LIST_OF_LINKS_DATASOURCE_ID } from '@atlaskit/link-datasource';
9
9
  import { messages } from './messages';
10
10
  import { hideLinkToolbar, showDatasourceModal } from './pm-plugins/actions';
11
11
  import { changeSelectedCardToLink, queueCardsFromChangedTr, setSelectedCardAppearance } from './pm-plugins/doc';
@@ -109,8 +109,12 @@ export var cardPlugin = function cardPlugin(options, api) {
109
109
  floatingToolbar: floatingToolbar(options, featureFlags, options.platform, options.linkPicker, api),
110
110
  quickInsert: function quickInsert(_ref3) {
111
111
  var formatMessage = _ref3.formatMessage;
112
- if (options.allowDatasource && canRenderDatasource(JIRA_LIST_OF_LINKS_DATASOURCE_ID)) {
113
- return [{
112
+ var quickInsertArray = [];
113
+ if (!options.allowDatasource) {
114
+ return quickInsertArray;
115
+ }
116
+ if (canRenderDatasource(JIRA_LIST_OF_LINKS_DATASOURCE_ID)) {
117
+ quickInsertArray.push({
114
118
  id: 'datasource',
115
119
  title: formatMessage(messages.datasourceJiraIssue),
116
120
  description: formatMessage(messages.datasourceJiraIssueDescription),
@@ -123,9 +127,25 @@ export var cardPlugin = function cardPlugin(options, api) {
123
127
  showDatasourceModal('jira')(tr);
124
128
  return tr;
125
129
  }
126
- }];
130
+ });
131
+ }
132
+ if (canRenderDatasource(ASSETS_LIST_OF_LINKS_DATASOURCE_ID)) {
133
+ quickInsertArray.push({
134
+ id: 'datasource',
135
+ title: formatMessage(messages.datasourceAssetsObjects),
136
+ description: formatMessage(messages.datasourceAssetsObjectsDescription),
137
+ keywords: ['assets'],
138
+ icon: function icon() {
139
+ return /*#__PURE__*/React.createElement(IconDatasourceAssetsObjects, null);
140
+ },
141
+ action: function action(insert) {
142
+ var tr = insert(undefined);
143
+ showDatasourceModal('assets')(tr);
144
+ return tr;
145
+ }
146
+ });
127
147
  }
128
- return [];
148
+ return quickInsertArray;
129
149
  }
130
150
  }
131
151
  };
@@ -1,7 +1,7 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  import React, { useCallback } from 'react';
3
3
  import { NodeSelection } from 'prosemirror-state';
4
- import { JIRA_LIST_OF_LINKS_DATASOURCE_ID, JiraIssuesConfigModal } from '@atlaskit/link-datasource';
4
+ import { ASSETS_LIST_OF_LINKS_DATASOURCE_ID, AssetsConfigModal, JIRA_LIST_OF_LINKS_DATASOURCE_ID, JiraIssuesConfigModal } from '@atlaskit/link-datasource';
5
5
  import { hideDatasourceModal } from '../../pm-plugins/actions';
6
6
  import { insertDatasource, updateExistingDatasource } from '../../pm-plugins/doc';
7
7
  export var DatasourceModal = function DatasourceModal(_ref) {
@@ -45,5 +45,29 @@ export var DatasourceModal = function DatasourceModal(_ref) {
45
45
  onInsert: onInsert
46
46
  }));
47
47
  }
48
+ if (modalType === 'assets') {
49
+ var _existingNode$attrs2, _tableView$properties2;
50
+ var _ref5 = (existingNode === null || existingNode === void 0 ? void 0 : (_existingNode$attrs2 = existingNode.attrs) === null || _existingNode$attrs2 === void 0 ? void 0 : _existingNode$attrs2.datasource) || {},
51
+ _ref5$id = _ref5.id,
52
+ _datasourceId = _ref5$id === void 0 ? ASSETS_LIST_OF_LINKS_DATASOURCE_ID : _ref5$id,
53
+ _parameters = _ref5.parameters,
54
+ _ref5$views = _ref5.views,
55
+ _views = _ref5$views === void 0 ? [] : _ref5$views;
56
+ var _ref6 = _views,
57
+ _ref7 = _slicedToArray(_ref6, 1),
58
+ _tableView = _ref7[0];
59
+ var _visibleColumnKeys = _tableView === null || _tableView === void 0 ? void 0 : (_tableView$properties2 = _tableView.properties) === null || _tableView$properties2 === void 0 ? void 0 : _tableView$properties2.columns.map(function (column) {
60
+ return column.key;
61
+ });
62
+ return /*#__PURE__*/React.createElement("div", {
63
+ "data-testid": "assets-config-modal"
64
+ }, /*#__PURE__*/React.createElement(AssetsConfigModal, {
65
+ datasourceId: _datasourceId,
66
+ visibleColumnKeys: _visibleColumnKeys,
67
+ parameters: _parameters,
68
+ onCancel: onClose,
69
+ onInsert: onInsert
70
+ }));
71
+ }
48
72
  return null; // null for now until we have modal component that handles other datasources
49
73
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-card",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "sideEffects": false
5
5
  }
@@ -9,4 +9,14 @@ export declare const messages: {
9
9
  defaultMessage: string;
10
10
  description: string;
11
11
  };
12
+ datasourceAssetsObjects: {
13
+ id: string;
14
+ defaultMessage: string;
15
+ description: string;
16
+ };
17
+ datasourceAssetsObjectsDescription: {
18
+ id: string;
19
+ defaultMessage: string;
20
+ description: string;
21
+ };
12
22
  };
@@ -24,7 +24,7 @@ export declare const getPluginStateWithUpdatedPos: (pluginState: CardPluginState
24
24
  smartLinkEventsNext?: import("../../types").SmartLinkEventsNext | undefined;
25
25
  editorAppearance?: import("@atlaskit/editor-common/types").EditorAppearance | undefined;
26
26
  showDatasourceModal: boolean;
27
- datasourceModalType?: "jira" | undefined;
27
+ datasourceModalType?: import("@atlaskit/editor-common/types").DatasourceModalType | undefined;
28
28
  datasourceTableRef?: HTMLElement | undefined;
29
29
  layout?: import("../../ui/LayoutButton/types").DatasourceTableLayout | undefined;
30
30
  };
@@ -9,4 +9,14 @@ export declare const messages: {
9
9
  defaultMessage: string;
10
10
  description: string;
11
11
  };
12
+ datasourceAssetsObjects: {
13
+ id: string;
14
+ defaultMessage: string;
15
+ description: string;
16
+ };
17
+ datasourceAssetsObjectsDescription: {
18
+ id: string;
19
+ defaultMessage: string;
20
+ description: string;
21
+ };
12
22
  };
@@ -24,7 +24,7 @@ export declare const getPluginStateWithUpdatedPos: (pluginState: CardPluginState
24
24
  smartLinkEventsNext?: import("../../types").SmartLinkEventsNext | undefined;
25
25
  editorAppearance?: import("@atlaskit/editor-common/types").EditorAppearance | undefined;
26
26
  showDatasourceModal: boolean;
27
- datasourceModalType?: "jira" | undefined;
27
+ datasourceModalType?: import("@atlaskit/editor-common/types").DatasourceModalType | undefined;
28
28
  datasourceTableRef?: HTMLElement | undefined;
29
29
  layout?: import("../../ui/LayoutButton/types").DatasourceTableLayout | undefined;
30
30
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-card",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "Card plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",