@atlaskit/give-kudos 1.1.3 → 2.0.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,17 @@
1
1
  # @atlassian/give-kudos
2
2
 
3
+ ## 2.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`7490bbf65f2`](https://bitbucket.org/atlassian/atlassian-frontend/commits/7490bbf65f2) - Exporting types
8
+
9
+ ## 2.0.0
10
+
11
+ ### Major Changes
12
+
13
+ - [`4ebab06438a`](https://bitbucket.org/atlassian/atlassian-frontend/commits/4ebab06438a) - [ux] Added types for the flag event listener. Added new flags for jira kudos success and failure.
14
+
3
15
  ## 1.1.3
4
16
 
5
17
  ### Patch Changes
package/dist/cjs/index.js CHANGED
@@ -4,6 +4,12 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
+ Object.defineProperty(exports, "FlagEventType", {
8
+ enumerable: true,
9
+ get: function get() {
10
+ return _types.FlagEventType;
11
+ }
12
+ });
7
13
  Object.defineProperty(exports, "GiveKudosLauncher", {
8
14
  enumerable: true,
9
15
  get: function get() {
@@ -21,6 +21,26 @@ var messages = (0, _reactIntlNext.defineMessages)({
21
21
  defaultMessage: 'Your kudos has been sent. <a>View kudos</a>',
22
22
  description: 'Description text for the kudos created flag. This includes a link to view the newly created kudos.'
23
23
  },
24
+ JiraKudosCreatedFlag: {
25
+ id: 'team-central.give-jira-kudos.created.title.flag',
26
+ defaultMessage: 'Kudos created',
27
+ description: 'Title text for kudos creation flag.'
28
+ },
29
+ JiraKudosCreatedDescriptionFlag: {
30
+ id: 'team-central.give-jira-kudos.created.description.flag',
31
+ defaultMessage: 'Our Workplace Experience team will now work their magic for the gift request. ✨',
32
+ description: 'Description text for the atlas and jira kudos created flag. This includes links to view the newly created kudos and jira kudos request.'
33
+ },
34
+ JiraKudosCreationFailedFlag: {
35
+ id: 'team-central.give-jira-kudos.creation.failed.title.flag',
36
+ defaultMessage: "We couldn't send the gift",
37
+ description: 'Title text for jira kudos creation failed flag.'
38
+ },
39
+ JiraKudosCreationFailedDescriptionFlag: {
40
+ id: 'team-central.give-jira-kudos.creation.failed.description.flag',
41
+ defaultMessage: "We sent the kudos but we couldn't send the gift due to an error. Please raise a separate ticket at <a>go/kudos</a>.",
42
+ description: 'Description text for the jira kudos creation failed flag. This includes a link to the atlas kudos and jira kudos form.'
43
+ },
24
44
  unsavedKudosWarning: {
25
45
  id: 'team-central.give-kudos.unsaved.warning',
26
46
  defaultMessage: 'Changes that you made will not be saved.',
package/dist/cjs/types.js CHANGED
@@ -3,10 +3,19 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.KudosType = void 0;
6
+ exports.KudosType = exports.FlagEventType = void 0;
7
7
  var KudosType = /*#__PURE__*/function (KudosType) {
8
8
  KudosType["INDIVIDUAL"] = "individual";
9
9
  KudosType["TEAM"] = "team";
10
10
  return KudosType;
11
11
  }({});
12
- exports.KudosType = KudosType;
12
+ exports.KudosType = KudosType;
13
+ var FlagEventType = /*#__PURE__*/function (FlagEventType) {
14
+ FlagEventType["KUDOS_CREATED"] = "kudos-created";
15
+ FlagEventType["JIRA_KUDOS_CREATED"] = "jira-kudos-created";
16
+ FlagEventType["JIRA_KUDOS_FAILED"] = "jira-kudos-failed";
17
+ FlagEventType["DIRTY"] = "dirty";
18
+ FlagEventType["CLOSE"] = "close";
19
+ return FlagEventType;
20
+ }({});
21
+ exports.FlagEventType = FlagEventType;
@@ -22,6 +22,7 @@ var _portal = _interopRequireDefault(require("@atlaskit/portal"));
22
22
  var _colors = require("@atlaskit/theme/colors");
23
23
  var _constants = require("@atlaskit/theme/constants");
24
24
  var _messages = _interopRequireDefault(require("../../messages"));
25
+ var _types = require("../../types");
25
26
  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); }
26
27
  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; }
27
28
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
@@ -31,7 +32,7 @@ var iframeStyles = (0, _react2.css)({
31
32
  });
32
33
  var sidebarDivStyles = (0, _react2.css)({
33
34
  position: 'absolute',
34
- margin: '16px 0 0 16px',
35
+ margin: "var(--ds-space-200, 16px)".concat(" 0 0 ", "var(--ds-space-200, 16px)"),
35
36
  display: 'flex',
36
37
  alignItems: 'center',
37
38
  justifyContent: 'center'
@@ -90,22 +91,21 @@ var GiveKudosLauncher = function GiveKudosLauncher(props) {
90
91
  var closeWarningModal = function closeWarningModal() {
91
92
  setIsCloseConfirmModalOpen(false);
92
93
  };
93
- var messageListener = (0, _react.useCallback)(function (event) {
94
- if (!props.isOpen) {
95
- return;
96
- }
97
- if (String(event.data).startsWith('kudos-created-')) {
98
- var uuid = String(event.data).replace(/^(kudos-created-)/, '');
94
+ var createFlagWithJsonStringifiedInput = (0, _react.useCallback)(function (flagEvent) {
95
+ if (flagEvent.eventType === _types.FlagEventType.KUDOS_CREATED) {
99
96
  closeDrawer();
100
97
  sendAnalytic('created', {});
98
+ if (!flagEvent.kudosUuid) {
99
+ return;
100
+ }
101
101
  addFlag && addFlag({
102
102
  title: (0, _react2.jsx)(_reactIntlNext.FormattedMessage, _messages.default.kudosCreatedFlag),
103
- id: "kudosCreatedFlag-".concat(uuid),
103
+ id: "kudosCreatedFlag-".concat(flagEvent.kudosUuid),
104
104
  description: (0, _react2.jsx)(_reactIntlNext.FormattedMessage, (0, _extends2.default)({}, _messages.default.kudosCreatedDescriptionFlag, {
105
105
  values: {
106
106
  a: function a(s) {
107
107
  return (0, _react2.jsx)("a", {
108
- href: "".concat(teamCentralBaseUrl, "/people/kudos/").concat(uuid)
108
+ href: "".concat(teamCentralBaseUrl, "/people/kudos/").concat(flagEvent.kudosUuid)
109
109
  }, s);
110
110
  }
111
111
  }
@@ -115,12 +115,96 @@ var GiveKudosLauncher = function GiveKudosLauncher(props) {
115
115
  primaryColor: "var(--ds-icon-success, ".concat(_colors.G300, ")")
116
116
  })
117
117
  });
118
- } else if (event.data === 'dirty') {
118
+ } else if (flagEvent.eventType === _types.FlagEventType.JIRA_KUDOS_CREATED) {
119
+ closeDrawer();
120
+ sendAnalytic('created', {});
121
+ if (!flagEvent.kudosUuid || !flagEvent.jiraKudosUrl) {
122
+ return;
123
+ }
124
+ addFlag && addFlag({
125
+ title: (0, _react2.jsx)(_reactIntlNext.FormattedMessage, _messages.default.JiraKudosCreatedFlag),
126
+ id: "kudosCreatedFlag-".concat(flagEvent.kudosUuid),
127
+ description: (0, _react2.jsx)(_reactIntlNext.FormattedMessage, _messages.default.JiraKudosCreatedDescriptionFlag),
128
+ icon: (0, _react2.jsx)(_checkCircle.default, {
129
+ label: "success",
130
+ primaryColor: "var(--ds-icon-success, ".concat(_colors.G300, ")")
131
+ }),
132
+ actions: [{
133
+ content: 'Track gift request',
134
+ href: flagEvent.jiraKudosUrl
135
+ }, {
136
+ content: 'View kudos',
137
+ href: "".concat(teamCentralBaseUrl, "/people/kudos/").concat(flagEvent.kudosUuid)
138
+ }]
139
+ });
140
+ } else if (flagEvent.eventType === _types.FlagEventType.JIRA_KUDOS_FAILED) {
141
+ closeDrawer();
142
+ sendAnalytic('created', {});
143
+ if (!flagEvent.kudosUuid || !flagEvent.jiraKudosFormUrl) {
144
+ return;
145
+ }
146
+ addFlag && addFlag({
147
+ title: (0, _react2.jsx)(_reactIntlNext.FormattedMessage, _messages.default.JiraKudosCreationFailedFlag),
148
+ id: "jiraKudosCreationFailedFlag-".concat(flagEvent.kudosUuid),
149
+ description: (0, _react2.jsx)(_reactIntlNext.FormattedMessage, (0, _extends2.default)({}, _messages.default.JiraKudosCreationFailedDescriptionFlag, {
150
+ values: {
151
+ a: function a(s) {
152
+ return (0, _react2.jsx)("a", {
153
+ href: flagEvent.jiraKudosFormUrl
154
+ }, s);
155
+ }
156
+ }
157
+ })),
158
+ type: 'warning',
159
+ actions: [{
160
+ content: 'Visit go/kudos',
161
+ href: flagEvent.jiraKudosFormUrl
162
+ }, {
163
+ content: 'View kudos',
164
+ href: "".concat(teamCentralBaseUrl, "/people/kudos/").concat(flagEvent.kudosUuid)
165
+ }]
166
+ });
167
+ } else if (flagEvent.eventType === _types.FlagEventType.DIRTY) {
119
168
  setIsDirty(true);
120
- } else if (event.data === 'close') {
169
+ } else if (flagEvent.eventType === _types.FlagEventType.CLOSE) {
121
170
  closeDrawer();
122
171
  }
123
- }, [props.isOpen, addFlag, teamCentralBaseUrl, sendAnalytic, closeDrawer]);
172
+ }, [addFlag, closeDrawer, sendAnalytic, teamCentralBaseUrl]);
173
+ var messageListener = (0, _react.useCallback)(function (event) {
174
+ if (!props.isOpen) {
175
+ return;
176
+ }
177
+ if (String(event.data).startsWith('kudos-created-') || event.data === 'dirty' || event.data === 'close') {
178
+ if (String(event.data).startsWith('kudos-created-')) {
179
+ var uuid = String(event.data).replace(/^(kudos-created-)/, '');
180
+ closeDrawer();
181
+ sendAnalytic('created', {});
182
+ addFlag && addFlag({
183
+ title: (0, _react2.jsx)(_reactIntlNext.FormattedMessage, _messages.default.kudosCreatedFlag),
184
+ id: "kudosCreatedFlag-".concat(uuid),
185
+ description: (0, _react2.jsx)(_reactIntlNext.FormattedMessage, (0, _extends2.default)({}, _messages.default.kudosCreatedDescriptionFlag, {
186
+ values: {
187
+ a: function a(s) {
188
+ return (0, _react2.jsx)("a", {
189
+ href: "".concat(teamCentralBaseUrl, "/people/kudos/").concat(uuid)
190
+ }, s);
191
+ }
192
+ }
193
+ })),
194
+ icon: (0, _react2.jsx)(_checkCircle.default, {
195
+ label: "success",
196
+ primaryColor: "var(--ds-icon-success, ".concat(_colors.G300, ")")
197
+ })
198
+ });
199
+ } else if (event.data === 'dirty') {
200
+ setIsDirty(true);
201
+ } else if (event.data === 'close') {
202
+ closeDrawer();
203
+ }
204
+ } else {
205
+ createFlagWithJsonStringifiedInput(JSON.parse(event.data));
206
+ }
207
+ }, [props.isOpen, closeDrawer, sendAnalytic, addFlag, teamCentralBaseUrl, createFlagWithJsonStringifiedInput]);
124
208
  (0, _react.useEffect)(function () {
125
209
  window.removeEventListener('message', messageListenerEventHandler.current);
126
210
  messageListenerEventHandler.current = messageListener;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/give-kudos",
3
- "version": "1.1.3",
3
+ "version": "2.0.1",
4
4
  "sideEffects": false
5
5
  }
@@ -1,4 +1,4 @@
1
- export { KudosType } from './types';
1
+ export { KudosType, FlagEventType } from './types';
2
2
  import GiveKudosLauncher from './ui/GiveKudosLauncher/main';
3
3
  export { GiveKudosLauncher };
4
4
  export { GiveKudosLauncherLazy } from './ui/GiveKudosLauncher';
@@ -15,6 +15,26 @@ const messages = defineMessages({
15
15
  defaultMessage: 'Your kudos has been sent. <a>View kudos</a>',
16
16
  description: 'Description text for the kudos created flag. This includes a link to view the newly created kudos.'
17
17
  },
18
+ JiraKudosCreatedFlag: {
19
+ id: 'team-central.give-jira-kudos.created.title.flag',
20
+ defaultMessage: 'Kudos created',
21
+ description: 'Title text for kudos creation flag.'
22
+ },
23
+ JiraKudosCreatedDescriptionFlag: {
24
+ id: 'team-central.give-jira-kudos.created.description.flag',
25
+ defaultMessage: 'Our Workplace Experience team will now work their magic for the gift request. ✨',
26
+ description: 'Description text for the atlas and jira kudos created flag. This includes links to view the newly created kudos and jira kudos request.'
27
+ },
28
+ JiraKudosCreationFailedFlag: {
29
+ id: 'team-central.give-jira-kudos.creation.failed.title.flag',
30
+ defaultMessage: "We couldn't send the gift",
31
+ description: 'Title text for jira kudos creation failed flag.'
32
+ },
33
+ JiraKudosCreationFailedDescriptionFlag: {
34
+ id: 'team-central.give-jira-kudos.creation.failed.description.flag',
35
+ defaultMessage: "We sent the kudos but we couldn't send the gift due to an error. Please raise a separate ticket at <a>go/kudos</a>.",
36
+ description: 'Description text for the jira kudos creation failed flag. This includes a link to the atlas kudos and jira kudos form.'
37
+ },
18
38
  unsavedKudosWarning: {
19
39
  id: 'team-central.give-kudos.unsaved.warning',
20
40
  defaultMessage: 'Changes that you made will not be saved.',
@@ -2,4 +2,12 @@ export let KudosType = /*#__PURE__*/function (KudosType) {
2
2
  KudosType["INDIVIDUAL"] = "individual";
3
3
  KudosType["TEAM"] = "team";
4
4
  return KudosType;
5
+ }({});
6
+ export let FlagEventType = /*#__PURE__*/function (FlagEventType) {
7
+ FlagEventType["KUDOS_CREATED"] = "kudos-created";
8
+ FlagEventType["JIRA_KUDOS_CREATED"] = "jira-kudos-created";
9
+ FlagEventType["JIRA_KUDOS_FAILED"] = "jira-kudos-failed";
10
+ FlagEventType["DIRTY"] = "dirty";
11
+ FlagEventType["CLOSE"] = "close";
12
+ return FlagEventType;
5
13
  }({});
@@ -14,12 +14,13 @@ import Portal from '@atlaskit/portal';
14
14
  import { G300 } from '@atlaskit/theme/colors';
15
15
  import { layers } from '@atlaskit/theme/constants';
16
16
  import messages from '../../messages';
17
+ import { FlagEventType } from '../../types';
17
18
  const iframeStyles = css({
18
19
  border: 0
19
20
  });
20
21
  const sidebarDivStyles = css({
21
22
  position: 'absolute',
22
- margin: '16px 0 0 16px',
23
+ margin: `${"var(--ds-space-200, 16px)"} 0 0 ${"var(--ds-space-200, 16px)"}`,
23
24
  display: 'flex',
24
25
  alignItems: 'center',
25
26
  justifyContent: 'center'
@@ -76,21 +77,20 @@ const GiveKudosLauncher = props => {
76
77
  const closeWarningModal = () => {
77
78
  setIsCloseConfirmModalOpen(false);
78
79
  };
79
- const messageListener = useCallback(event => {
80
- if (!props.isOpen) {
81
- return;
82
- }
83
- if (String(event.data).startsWith('kudos-created-')) {
84
- const uuid = String(event.data).replace(/^(kudos-created-)/, '');
80
+ const createFlagWithJsonStringifiedInput = useCallback(flagEvent => {
81
+ if (flagEvent.eventType === FlagEventType.KUDOS_CREATED) {
85
82
  closeDrawer();
86
83
  sendAnalytic('created', {});
84
+ if (!flagEvent.kudosUuid) {
85
+ return;
86
+ }
87
87
  addFlag && addFlag({
88
88
  title: jsx(FormattedMessage, messages.kudosCreatedFlag),
89
- id: `kudosCreatedFlag-${uuid}`,
89
+ id: `kudosCreatedFlag-${flagEvent.kudosUuid}`,
90
90
  description: jsx(FormattedMessage, _extends({}, messages.kudosCreatedDescriptionFlag, {
91
91
  values: {
92
92
  a: s => jsx("a", {
93
- href: `${teamCentralBaseUrl}/people/kudos/${uuid}`
93
+ href: `${teamCentralBaseUrl}/people/kudos/${flagEvent.kudosUuid}`
94
94
  }, s)
95
95
  }
96
96
  })),
@@ -99,12 +99,92 @@ const GiveKudosLauncher = props => {
99
99
  primaryColor: `var(--ds-icon-success, ${G300})`
100
100
  })
101
101
  });
102
- } else if (event.data === 'dirty') {
102
+ } else if (flagEvent.eventType === FlagEventType.JIRA_KUDOS_CREATED) {
103
+ closeDrawer();
104
+ sendAnalytic('created', {});
105
+ if (!flagEvent.kudosUuid || !flagEvent.jiraKudosUrl) {
106
+ return;
107
+ }
108
+ addFlag && addFlag({
109
+ title: jsx(FormattedMessage, messages.JiraKudosCreatedFlag),
110
+ id: `kudosCreatedFlag-${flagEvent.kudosUuid}`,
111
+ description: jsx(FormattedMessage, messages.JiraKudosCreatedDescriptionFlag),
112
+ icon: jsx(SuccessIcon, {
113
+ label: "success",
114
+ primaryColor: `var(--ds-icon-success, ${G300})`
115
+ }),
116
+ actions: [{
117
+ content: 'Track gift request',
118
+ href: flagEvent.jiraKudosUrl
119
+ }, {
120
+ content: 'View kudos',
121
+ href: `${teamCentralBaseUrl}/people/kudos/${flagEvent.kudosUuid}`
122
+ }]
123
+ });
124
+ } else if (flagEvent.eventType === FlagEventType.JIRA_KUDOS_FAILED) {
125
+ closeDrawer();
126
+ sendAnalytic('created', {});
127
+ if (!flagEvent.kudosUuid || !flagEvent.jiraKudosFormUrl) {
128
+ return;
129
+ }
130
+ addFlag && addFlag({
131
+ title: jsx(FormattedMessage, messages.JiraKudosCreationFailedFlag),
132
+ id: `jiraKudosCreationFailedFlag-${flagEvent.kudosUuid}`,
133
+ description: jsx(FormattedMessage, _extends({}, messages.JiraKudosCreationFailedDescriptionFlag, {
134
+ values: {
135
+ a: s => jsx("a", {
136
+ href: flagEvent.jiraKudosFormUrl
137
+ }, s)
138
+ }
139
+ })),
140
+ type: 'warning',
141
+ actions: [{
142
+ content: 'Visit go/kudos',
143
+ href: flagEvent.jiraKudosFormUrl
144
+ }, {
145
+ content: 'View kudos',
146
+ href: `${teamCentralBaseUrl}/people/kudos/${flagEvent.kudosUuid}`
147
+ }]
148
+ });
149
+ } else if (flagEvent.eventType === FlagEventType.DIRTY) {
103
150
  setIsDirty(true);
104
- } else if (event.data === 'close') {
151
+ } else if (flagEvent.eventType === FlagEventType.CLOSE) {
105
152
  closeDrawer();
106
153
  }
107
- }, [props.isOpen, addFlag, teamCentralBaseUrl, sendAnalytic, closeDrawer]);
154
+ }, [addFlag, closeDrawer, sendAnalytic, teamCentralBaseUrl]);
155
+ const messageListener = useCallback(event => {
156
+ if (!props.isOpen) {
157
+ return;
158
+ }
159
+ if (String(event.data).startsWith('kudos-created-') || event.data === 'dirty' || event.data === 'close') {
160
+ if (String(event.data).startsWith('kudos-created-')) {
161
+ const uuid = String(event.data).replace(/^(kudos-created-)/, '');
162
+ closeDrawer();
163
+ sendAnalytic('created', {});
164
+ addFlag && addFlag({
165
+ title: jsx(FormattedMessage, messages.kudosCreatedFlag),
166
+ id: `kudosCreatedFlag-${uuid}`,
167
+ description: jsx(FormattedMessage, _extends({}, messages.kudosCreatedDescriptionFlag, {
168
+ values: {
169
+ a: s => jsx("a", {
170
+ href: `${teamCentralBaseUrl}/people/kudos/${uuid}`
171
+ }, s)
172
+ }
173
+ })),
174
+ icon: jsx(SuccessIcon, {
175
+ label: "success",
176
+ primaryColor: `var(--ds-icon-success, ${G300})`
177
+ })
178
+ });
179
+ } else if (event.data === 'dirty') {
180
+ setIsDirty(true);
181
+ } else if (event.data === 'close') {
182
+ closeDrawer();
183
+ }
184
+ } else {
185
+ createFlagWithJsonStringifiedInput(JSON.parse(event.data));
186
+ }
187
+ }, [props.isOpen, closeDrawer, sendAnalytic, addFlag, teamCentralBaseUrl, createFlagWithJsonStringifiedInput]);
108
188
  useEffect(() => {
109
189
  window.removeEventListener('message', messageListenerEventHandler.current);
110
190
  messageListenerEventHandler.current = messageListener;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/give-kudos",
3
- "version": "1.1.3",
3
+ "version": "2.0.1",
4
4
  "sideEffects": false
5
5
  }
package/dist/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { KudosType } from './types';
1
+ export { KudosType, FlagEventType } from './types';
2
2
  import GiveKudosLauncher from './ui/GiveKudosLauncher/main';
3
3
  export { GiveKudosLauncher };
4
4
  export { GiveKudosLauncherLazy } from './ui/GiveKudosLauncher';
@@ -15,6 +15,26 @@ var messages = defineMessages({
15
15
  defaultMessage: 'Your kudos has been sent. <a>View kudos</a>',
16
16
  description: 'Description text for the kudos created flag. This includes a link to view the newly created kudos.'
17
17
  },
18
+ JiraKudosCreatedFlag: {
19
+ id: 'team-central.give-jira-kudos.created.title.flag',
20
+ defaultMessage: 'Kudos created',
21
+ description: 'Title text for kudos creation flag.'
22
+ },
23
+ JiraKudosCreatedDescriptionFlag: {
24
+ id: 'team-central.give-jira-kudos.created.description.flag',
25
+ defaultMessage: 'Our Workplace Experience team will now work their magic for the gift request. ✨',
26
+ description: 'Description text for the atlas and jira kudos created flag. This includes links to view the newly created kudos and jira kudos request.'
27
+ },
28
+ JiraKudosCreationFailedFlag: {
29
+ id: 'team-central.give-jira-kudos.creation.failed.title.flag',
30
+ defaultMessage: "We couldn't send the gift",
31
+ description: 'Title text for jira kudos creation failed flag.'
32
+ },
33
+ JiraKudosCreationFailedDescriptionFlag: {
34
+ id: 'team-central.give-jira-kudos.creation.failed.description.flag',
35
+ defaultMessage: "We sent the kudos but we couldn't send the gift due to an error. Please raise a separate ticket at <a>go/kudos</a>.",
36
+ description: 'Description text for the jira kudos creation failed flag. This includes a link to the atlas kudos and jira kudos form.'
37
+ },
18
38
  unsavedKudosWarning: {
19
39
  id: 'team-central.give-kudos.unsaved.warning',
20
40
  defaultMessage: 'Changes that you made will not be saved.',
package/dist/esm/types.js CHANGED
@@ -2,4 +2,12 @@ export var KudosType = /*#__PURE__*/function (KudosType) {
2
2
  KudosType["INDIVIDUAL"] = "individual";
3
3
  KudosType["TEAM"] = "team";
4
4
  return KudosType;
5
+ }({});
6
+ export var FlagEventType = /*#__PURE__*/function (FlagEventType) {
7
+ FlagEventType["KUDOS_CREATED"] = "kudos-created";
8
+ FlagEventType["JIRA_KUDOS_CREATED"] = "jira-kudos-created";
9
+ FlagEventType["JIRA_KUDOS_FAILED"] = "jira-kudos-failed";
10
+ FlagEventType["DIRTY"] = "dirty";
11
+ FlagEventType["CLOSE"] = "close";
12
+ return FlagEventType;
5
13
  }({});
@@ -18,12 +18,13 @@ import Portal from '@atlaskit/portal';
18
18
  import { G300 } from '@atlaskit/theme/colors';
19
19
  import { layers } from '@atlaskit/theme/constants';
20
20
  import messages from '../../messages';
21
+ import { FlagEventType } from '../../types';
21
22
  var iframeStyles = css({
22
23
  border: 0
23
24
  });
24
25
  var sidebarDivStyles = css({
25
26
  position: 'absolute',
26
- margin: '16px 0 0 16px',
27
+ margin: "var(--ds-space-200, 16px)".concat(" 0 0 ", "var(--ds-space-200, 16px)"),
27
28
  display: 'flex',
28
29
  alignItems: 'center',
29
30
  justifyContent: 'center'
@@ -82,22 +83,21 @@ var GiveKudosLauncher = function GiveKudosLauncher(props) {
82
83
  var closeWarningModal = function closeWarningModal() {
83
84
  setIsCloseConfirmModalOpen(false);
84
85
  };
85
- var messageListener = useCallback(function (event) {
86
- if (!props.isOpen) {
87
- return;
88
- }
89
- if (String(event.data).startsWith('kudos-created-')) {
90
- var uuid = String(event.data).replace(/^(kudos-created-)/, '');
86
+ var createFlagWithJsonStringifiedInput = useCallback(function (flagEvent) {
87
+ if (flagEvent.eventType === FlagEventType.KUDOS_CREATED) {
91
88
  closeDrawer();
92
89
  sendAnalytic('created', {});
90
+ if (!flagEvent.kudosUuid) {
91
+ return;
92
+ }
93
93
  addFlag && addFlag({
94
94
  title: jsx(FormattedMessage, messages.kudosCreatedFlag),
95
- id: "kudosCreatedFlag-".concat(uuid),
95
+ id: "kudosCreatedFlag-".concat(flagEvent.kudosUuid),
96
96
  description: jsx(FormattedMessage, _extends({}, messages.kudosCreatedDescriptionFlag, {
97
97
  values: {
98
98
  a: function a(s) {
99
99
  return jsx("a", {
100
- href: "".concat(teamCentralBaseUrl, "/people/kudos/").concat(uuid)
100
+ href: "".concat(teamCentralBaseUrl, "/people/kudos/").concat(flagEvent.kudosUuid)
101
101
  }, s);
102
102
  }
103
103
  }
@@ -107,12 +107,96 @@ var GiveKudosLauncher = function GiveKudosLauncher(props) {
107
107
  primaryColor: "var(--ds-icon-success, ".concat(G300, ")")
108
108
  })
109
109
  });
110
- } else if (event.data === 'dirty') {
110
+ } else if (flagEvent.eventType === FlagEventType.JIRA_KUDOS_CREATED) {
111
+ closeDrawer();
112
+ sendAnalytic('created', {});
113
+ if (!flagEvent.kudosUuid || !flagEvent.jiraKudosUrl) {
114
+ return;
115
+ }
116
+ addFlag && addFlag({
117
+ title: jsx(FormattedMessage, messages.JiraKudosCreatedFlag),
118
+ id: "kudosCreatedFlag-".concat(flagEvent.kudosUuid),
119
+ description: jsx(FormattedMessage, messages.JiraKudosCreatedDescriptionFlag),
120
+ icon: jsx(SuccessIcon, {
121
+ label: "success",
122
+ primaryColor: "var(--ds-icon-success, ".concat(G300, ")")
123
+ }),
124
+ actions: [{
125
+ content: 'Track gift request',
126
+ href: flagEvent.jiraKudosUrl
127
+ }, {
128
+ content: 'View kudos',
129
+ href: "".concat(teamCentralBaseUrl, "/people/kudos/").concat(flagEvent.kudosUuid)
130
+ }]
131
+ });
132
+ } else if (flagEvent.eventType === FlagEventType.JIRA_KUDOS_FAILED) {
133
+ closeDrawer();
134
+ sendAnalytic('created', {});
135
+ if (!flagEvent.kudosUuid || !flagEvent.jiraKudosFormUrl) {
136
+ return;
137
+ }
138
+ addFlag && addFlag({
139
+ title: jsx(FormattedMessage, messages.JiraKudosCreationFailedFlag),
140
+ id: "jiraKudosCreationFailedFlag-".concat(flagEvent.kudosUuid),
141
+ description: jsx(FormattedMessage, _extends({}, messages.JiraKudosCreationFailedDescriptionFlag, {
142
+ values: {
143
+ a: function a(s) {
144
+ return jsx("a", {
145
+ href: flagEvent.jiraKudosFormUrl
146
+ }, s);
147
+ }
148
+ }
149
+ })),
150
+ type: 'warning',
151
+ actions: [{
152
+ content: 'Visit go/kudos',
153
+ href: flagEvent.jiraKudosFormUrl
154
+ }, {
155
+ content: 'View kudos',
156
+ href: "".concat(teamCentralBaseUrl, "/people/kudos/").concat(flagEvent.kudosUuid)
157
+ }]
158
+ });
159
+ } else if (flagEvent.eventType === FlagEventType.DIRTY) {
111
160
  setIsDirty(true);
112
- } else if (event.data === 'close') {
161
+ } else if (flagEvent.eventType === FlagEventType.CLOSE) {
113
162
  closeDrawer();
114
163
  }
115
- }, [props.isOpen, addFlag, teamCentralBaseUrl, sendAnalytic, closeDrawer]);
164
+ }, [addFlag, closeDrawer, sendAnalytic, teamCentralBaseUrl]);
165
+ var messageListener = useCallback(function (event) {
166
+ if (!props.isOpen) {
167
+ return;
168
+ }
169
+ if (String(event.data).startsWith('kudos-created-') || event.data === 'dirty' || event.data === 'close') {
170
+ if (String(event.data).startsWith('kudos-created-')) {
171
+ var uuid = String(event.data).replace(/^(kudos-created-)/, '');
172
+ closeDrawer();
173
+ sendAnalytic('created', {});
174
+ addFlag && addFlag({
175
+ title: jsx(FormattedMessage, messages.kudosCreatedFlag),
176
+ id: "kudosCreatedFlag-".concat(uuid),
177
+ description: jsx(FormattedMessage, _extends({}, messages.kudosCreatedDescriptionFlag, {
178
+ values: {
179
+ a: function a(s) {
180
+ return jsx("a", {
181
+ href: "".concat(teamCentralBaseUrl, "/people/kudos/").concat(uuid)
182
+ }, s);
183
+ }
184
+ }
185
+ })),
186
+ icon: jsx(SuccessIcon, {
187
+ label: "success",
188
+ primaryColor: "var(--ds-icon-success, ".concat(G300, ")")
189
+ })
190
+ });
191
+ } else if (event.data === 'dirty') {
192
+ setIsDirty(true);
193
+ } else if (event.data === 'close') {
194
+ closeDrawer();
195
+ }
196
+ } else {
197
+ createFlagWithJsonStringifiedInput(JSON.parse(event.data));
198
+ }
199
+ }, [props.isOpen, closeDrawer, sendAnalytic, addFlag, teamCentralBaseUrl, createFlagWithJsonStringifiedInput]);
116
200
  useEffect(function () {
117
201
  window.removeEventListener('message', messageListenerEventHandler.current);
118
202
  messageListenerEventHandler.current = messageListener;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/give-kudos",
3
- "version": "1.1.3",
3
+ "version": "2.0.1",
4
4
  "sideEffects": false
5
5
  }
@@ -1,5 +1,5 @@
1
- export type { KudosRecipient, GiveKudosDrawerProps } from './types';
2
- export { KudosType } from './types';
1
+ export type { KudosRecipient, GiveKudosDrawerProps, FlagEvent } from './types';
2
+ export { KudosType, FlagEventType } from './types';
3
3
  import GiveKudosLauncher from './ui/GiveKudosLauncher/main';
4
4
  export { GiveKudosLauncher };
5
5
  export { GiveKudosLauncherLazy } from './ui/GiveKudosLauncher';
@@ -14,6 +14,26 @@ declare const messages: {
14
14
  defaultMessage: string;
15
15
  description: string;
16
16
  };
17
+ JiraKudosCreatedFlag: {
18
+ id: string;
19
+ defaultMessage: string;
20
+ description: string;
21
+ };
22
+ JiraKudosCreatedDescriptionFlag: {
23
+ id: string;
24
+ defaultMessage: string;
25
+ description: string;
26
+ };
27
+ JiraKudosCreationFailedFlag: {
28
+ id: string;
29
+ defaultMessage: string;
30
+ description: string;
31
+ };
32
+ JiraKudosCreationFailedDescriptionFlag: {
33
+ id: string;
34
+ defaultMessage: string;
35
+ description: string;
36
+ };
17
37
  unsavedKudosWarning: {
18
38
  id: string;
19
39
  defaultMessage: string;
@@ -2,10 +2,23 @@ export declare enum KudosType {
2
2
  INDIVIDUAL = "individual",
3
3
  TEAM = "team"
4
4
  }
5
+ export declare enum FlagEventType {
6
+ KUDOS_CREATED = "kudos-created",
7
+ JIRA_KUDOS_CREATED = "jira-kudos-created",
8
+ JIRA_KUDOS_FAILED = "jira-kudos-failed",
9
+ DIRTY = "dirty",
10
+ CLOSE = "close"
11
+ }
5
12
  export interface KudosRecipient {
6
13
  type: KudosType;
7
14
  recipientId: string;
8
15
  }
16
+ export interface FlagEvent {
17
+ eventType: FlagEventType;
18
+ kudosUuid?: string;
19
+ jiraKudosUrl?: string;
20
+ jiraKudosFormUrl?: string;
21
+ }
9
22
  export interface GiveKudosDrawerProps {
10
23
  testId?: string;
11
24
  isOpen: boolean;
@@ -1,5 +1,5 @@
1
- export type { KudosRecipient, GiveKudosDrawerProps } from './types';
2
- export { KudosType } from './types';
1
+ export type { KudosRecipient, GiveKudosDrawerProps, FlagEvent } from './types';
2
+ export { KudosType, FlagEventType } from './types';
3
3
  import GiveKudosLauncher from './ui/GiveKudosLauncher/main';
4
4
  export { GiveKudosLauncher };
5
5
  export { GiveKudosLauncherLazy } from './ui/GiveKudosLauncher';
@@ -14,6 +14,26 @@ declare const messages: {
14
14
  defaultMessage: string;
15
15
  description: string;
16
16
  };
17
+ JiraKudosCreatedFlag: {
18
+ id: string;
19
+ defaultMessage: string;
20
+ description: string;
21
+ };
22
+ JiraKudosCreatedDescriptionFlag: {
23
+ id: string;
24
+ defaultMessage: string;
25
+ description: string;
26
+ };
27
+ JiraKudosCreationFailedFlag: {
28
+ id: string;
29
+ defaultMessage: string;
30
+ description: string;
31
+ };
32
+ JiraKudosCreationFailedDescriptionFlag: {
33
+ id: string;
34
+ defaultMessage: string;
35
+ description: string;
36
+ };
17
37
  unsavedKudosWarning: {
18
38
  id: string;
19
39
  defaultMessage: string;
@@ -2,10 +2,23 @@ export declare enum KudosType {
2
2
  INDIVIDUAL = "individual",
3
3
  TEAM = "team"
4
4
  }
5
+ export declare enum FlagEventType {
6
+ KUDOS_CREATED = "kudos-created",
7
+ JIRA_KUDOS_CREATED = "jira-kudos-created",
8
+ JIRA_KUDOS_FAILED = "jira-kudos-failed",
9
+ DIRTY = "dirty",
10
+ CLOSE = "close"
11
+ }
5
12
  export interface KudosRecipient {
6
13
  type: KudosType;
7
14
  recipientId: string;
8
15
  }
16
+ export interface FlagEvent {
17
+ eventType: FlagEventType;
18
+ kudosUuid?: string;
19
+ jiraKudosUrl?: string;
20
+ jiraKudosFormUrl?: string;
21
+ }
9
22
  export interface GiveKudosDrawerProps {
10
23
  testId?: string;
11
24
  isOpen: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/give-kudos",
3
- "version": "1.1.3",
3
+ "version": "2.0.1",
4
4
  "description": "Give Kudos experience ",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -40,13 +40,13 @@
40
40
  },
41
41
  "dependencies": {
42
42
  "@atlaskit/analytics-next": "^9.1.0",
43
- "@atlaskit/button": "^16.7.0",
43
+ "@atlaskit/button": "^16.8.0",
44
44
  "@atlaskit/drawer": "^7.5.0",
45
45
  "@atlaskit/icon": "^21.12.0",
46
- "@atlaskit/modal-dialog": "^12.5.0",
46
+ "@atlaskit/modal-dialog": "^12.6.0",
47
47
  "@atlaskit/portal": "^4.3.0",
48
48
  "@atlaskit/theme": "^12.5.0",
49
- "@atlaskit/tokens": "^1.5.0",
49
+ "@atlaskit/tokens": "^1.14.0",
50
50
  "@babel/runtime": "^7.0.0",
51
51
  "@emotion/react": "^11.7.1",
52
52
  "react-intl-next": "npm:react-intl@^5.18.1"
@@ -55,10 +55,8 @@
55
55
  "react": "^16.8.0"
56
56
  },
57
57
  "devDependencies": {
58
- "@atlaskit/docs": "*",
59
- "@atlaskit/flag": "^15.2.0",
60
58
  "@atlaskit/ssr": "*",
61
- "@atlaskit/tokens": "^1.5.0",
59
+ "@atlaskit/tokens": "^1.14.0",
62
60
  "@atlaskit/webdriver-runner": "*",
63
61
  "@atlassian/atlassian-frontend-prettier-config-1.0.0": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.0",
64
62
  "@testing-library/react": "^12.1.5",
@@ -96,6 +94,9 @@
96
94
  "styling": [
97
95
  "emotion",
98
96
  "static"
97
+ ],
98
+ "imports": [
99
+ "import-no-extraneous-disable-for-examples-and-docs"
99
100
  ]
100
101
  }
101
102
  },
package/report.api.md CHANGED
@@ -20,6 +20,32 @@
20
20
  import { jsx } from '@emotion/react';
21
21
  import { LazyExoticComponent } from 'react';
22
22
 
23
+ // @public (undocumented)
24
+ export interface FlagEvent {
25
+ // (undocumented)
26
+ eventType: FlagEventType;
27
+ // (undocumented)
28
+ jiraKudosFormUrl?: string;
29
+ // (undocumented)
30
+ jiraKudosUrl?: string;
31
+ // (undocumented)
32
+ kudosUuid?: string;
33
+ }
34
+
35
+ // @public (undocumented)
36
+ export enum FlagEventType {
37
+ // (undocumented)
38
+ CLOSE = 'close',
39
+ // (undocumented)
40
+ DIRTY = 'dirty',
41
+ // (undocumented)
42
+ JIRA_KUDOS_CREATED = 'jira-kudos-created',
43
+ // (undocumented)
44
+ JIRA_KUDOS_FAILED = 'jira-kudos-failed',
45
+ // (undocumented)
46
+ KUDOS_CREATED = 'kudos-created',
47
+ }
48
+
23
49
  // @public (undocumented)
24
50
  export interface GiveKudosDrawerProps {
25
51
  // (undocumented)
@@ -9,6 +9,32 @@
9
9
  import { jsx } from '@emotion/react';
10
10
  import { LazyExoticComponent } from 'react';
11
11
 
12
+ // @public (undocumented)
13
+ export interface FlagEvent {
14
+ // (undocumented)
15
+ eventType: FlagEventType;
16
+ // (undocumented)
17
+ jiraKudosFormUrl?: string;
18
+ // (undocumented)
19
+ jiraKudosUrl?: string;
20
+ // (undocumented)
21
+ kudosUuid?: string;
22
+ }
23
+
24
+ // @public (undocumented)
25
+ export enum FlagEventType {
26
+ // (undocumented)
27
+ CLOSE = "close",
28
+ // (undocumented)
29
+ DIRTY = "dirty",
30
+ // (undocumented)
31
+ JIRA_KUDOS_CREATED = "jira-kudos-created",
32
+ // (undocumented)
33
+ JIRA_KUDOS_FAILED = "jira-kudos-failed",
34
+ // (undocumented)
35
+ KUDOS_CREATED = "kudos-created"
36
+ }
37
+
12
38
  // @public (undocumented)
13
39
  export interface GiveKudosDrawerProps {
14
40
  // (undocumented)