@selfcommunity/react-ui 0.7.33-alpha.0 → 0.7.33-alpha.2

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.
@@ -24,12 +24,12 @@ export interface GroupSettingsIconButtonProps extends IconButtonProps {
24
24
  [p: string]: any;
25
25
  }
26
26
  /**
27
- * > API documentation for the Community-JS PrivateMessageSettingsIconButton component. Learn about the available props and the CSS API.
27
+ * > API documentation for the Community-JS GroupSettingsIconButton component. Learn about the available props and the CSS API.
28
28
 
29
29
  #### Import
30
30
 
31
31
  ```jsx
32
- import {PrivateMessageSettingsIconButton} from '@selfcommunity/react-ui';
32
+ import {GroupSettingsIconButton} from '@selfcommunity/react-ui';
33
33
  ```
34
34
 
35
35
  #### Component Name
@@ -34,12 +34,12 @@ const MenuRoot = (0, styles_1.styled)(material_1.Menu, {
34
34
  slot: 'MenuRoot'
35
35
  })(() => ({}));
36
36
  /**
37
- * > API documentation for the Community-JS PrivateMessageSettingsIconButton component. Learn about the available props and the CSS API.
37
+ * > API documentation for the Community-JS GroupSettingsIconButton component. Learn about the available props and the CSS API.
38
38
 
39
39
  #### Import
40
40
 
41
41
  ```jsx
42
- import {PrivateMessageSettingsIconButton} from '@selfcommunity/react-ui';
42
+ import {GroupSettingsIconButton} from '@selfcommunity/react-ui';
43
43
  ```
44
44
 
45
45
  #### Component Name
@@ -1,5 +1,5 @@
1
1
  import { IconButtonProps } from '@mui/material';
2
- import { SCUserType } from '@selfcommunity/types';
2
+ import { SCGroupType, SCUserType } from '@selfcommunity/types';
3
3
  export interface PrivateMessageSettingsIconButtonProps extends IconButtonProps {
4
4
  /**
5
5
  * Overrides or extends the styles applied to the component.
@@ -17,11 +17,15 @@ export interface PrivateMessageSettingsIconButtonProps extends IconButtonProps {
17
17
  /**
18
18
  * The deleting thread id
19
19
  */
20
- threadToDelete?: any;
20
+ threadToDelete?: number;
21
21
  /**
22
22
  * The user receiver context
23
23
  */
24
24
  user?: SCUserType;
25
+ /**
26
+ * The group
27
+ */
28
+ group?: SCGroupType;
25
29
  /**
26
30
  * Any other properties
27
31
  */
@@ -60,7 +60,7 @@ function PrivateMessageSettingsIconButton(inProps) {
60
60
  props: inProps,
61
61
  name: PREFIX
62
62
  });
63
- const { className = null, onMenuItemDeleteClick, user, onItemDeleteConfirm, threadToDelete } = props, rest = tslib_1.__rest(props, ["className", "onMenuItemDeleteClick", "user", "onItemDeleteConfirm", "threadToDelete"]);
63
+ const { className = null, onMenuItemDeleteClick, user, group, onItemDeleteConfirm, threadToDelete } = props, rest = tslib_1.__rest(props, ["className", "onMenuItemDeleteClick", "user", "group", "onItemDeleteConfirm", "threadToDelete"]);
64
64
  // STATE
65
65
  const [anchorEl, setAnchorEl] = (0, react_1.useState)(null);
66
66
  const [openConfirmDialog, setOpenConfirmDialog] = (0, react_1.useState)(false);
@@ -88,9 +88,15 @@ function PrivateMessageSettingsIconButton(inProps) {
88
88
  * Handles thread deletion
89
89
  */
90
90
  function handleDeleteThread() {
91
- api_services_1.PrivateMessageService.deleteAThread({ user: threadToDelete })
91
+ const params = group ? { group: threadToDelete } : { user: threadToDelete };
92
+ api_services_1.PrivateMessageService.deleteAThread(params)
92
93
  .then(() => {
93
- pubsub_js_1.default.publish('snippetsChannelDelete', threadToDelete);
94
+ if (group) {
95
+ pubsub_js_1.default.publish('snippetsChannelDeleteGroup', threadToDelete);
96
+ }
97
+ else {
98
+ pubsub_js_1.default.publish('snippetsChannelDelete', threadToDelete);
99
+ }
94
100
  handleCloseDialog();
95
101
  })
96
102
  .catch((error) => {
@@ -108,6 +114,10 @@ function PrivateMessageSettingsIconButton(inProps) {
108
114
  react_1.default.createElement(material_1.ListItemIcon, null,
109
115
  react_1.default.createElement(Icon_1.default, { fontSize: "small" }, "people_alt")),
110
116
  react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.privateMessageSettingsIconButton.item.profile", defaultMessage: "ui.privateMessageSettingsIconButton.item.profile" }))),
117
+ group && (react_1.default.createElement(material_1.ListItem, { className: classes.item, key: "profile", component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.GROUP_ROUTE_NAME, group) },
118
+ react_1.default.createElement(material_1.ListItemIcon, null,
119
+ react_1.default.createElement(Icon_1.default, { fontSize: "small" }, "groups")),
120
+ react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.privateMessageSettingsIconButton.item.group", defaultMessage: "ui.privateMessageSettingsIconButton.item.group" }))),
111
121
  react_1.default.createElement(material_1.ListItem, { className: classes.item, key: "delete", onClick: threadToDelete ? handleOpenDialog : onMenuItemDeleteClick },
112
122
  react_1.default.createElement(material_1.ListItemIcon, null,
113
123
  react_1.default.createElement(Icon_1.default, { fontSize: "small" }, "delete")),
@@ -120,6 +130,10 @@ function PrivateMessageSettingsIconButton(inProps) {
120
130
  react_1.default.createElement(material_1.ListItemIcon, null,
121
131
  react_1.default.createElement(Icon_1.default, { fontSize: "small" }, "people_alt")),
122
132
  react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.privateMessageSettingsIconButton.item.profile", defaultMessage: "ui.privateMessageSettingsIconButton.item.profile" }))),
133
+ group && (react_1.default.createElement(material_1.MenuItem, { className: classes.item, component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.GROUP_ROUTE_NAME, group), key: "profile", onClick: handleCloseDialog },
134
+ react_1.default.createElement(material_1.ListItemIcon, null,
135
+ react_1.default.createElement(Icon_1.default, { fontSize: "small" }, "groups")),
136
+ react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.privateMessageSettingsIconButton.item.group", defaultMessage: "ui.privateMessageSettingsIconButton.item.group" }))),
123
137
  react_1.default.createElement(material_1.MenuItem, { className: classes.item, onClick: threadToDelete ? handleOpenDialog : onMenuItemDeleteClick, key: "delete" },
124
138
  react_1.default.createElement(material_1.ListItemIcon, null,
125
139
  react_1.default.createElement(Icon_1.default, { fontSize: "small" }, "delete")),
@@ -156,12 +156,16 @@ function PrivateMessageSnippets(inProps) {
156
156
  updateSnippets(newSnippets);
157
157
  }
158
158
  }
159
- function handleSnippetsUpdate(message, forDeletion) {
159
+ function handleSnippetsUpdate(message, forDeletion, type) {
160
160
  const newSnippets = [...data.snippets];
161
- if (forDeletion) {
161
+ if (forDeletion && type === types_1.SCPrivateMessageType.USER) {
162
162
  const _snippets = newSnippets.filter((s) => messageReceiver(s, authUserId) !== message);
163
163
  updateSnippets(_snippets);
164
164
  }
165
+ else if (forDeletion && types_1.SCPrivateMessageType.GROUP) {
166
+ const _snippets = newSnippets.filter((s) => { var _a; return ((_a = s === null || s === void 0 ? void 0 : s.group) === null || _a === void 0 ? void 0 : _a.id) !== message; });
167
+ updateSnippets(_snippets);
168
+ }
165
169
  else {
166
170
  let temp = [...data.snippets];
167
171
  message.map((m) => {
@@ -210,11 +214,15 @@ function PrivateMessageSnippets(inProps) {
210
214
  handleSnippetsUpdate(data);
211
215
  });
212
216
  const snippetsSubscriber = pubsub_js_1.default.subscribe('snippetsChannelDelete', (msg, data) => {
213
- handleSnippetsUpdate(data, true);
217
+ handleSnippetsUpdate(data, true, types_1.SCPrivateMessageType.USER);
218
+ });
219
+ const snippetsGroupSubscriber = pubsub_js_1.default.subscribe('snippetsChannelDeleteGroup', (msg, data) => {
220
+ handleSnippetsUpdate(data, true, types_1.SCPrivateMessageType.GROUP);
214
221
  });
215
222
  return () => {
216
223
  pubsub_js_1.default.unsubscribe(threadSubscriber);
217
224
  pubsub_js_1.default.unsubscribe(snippetsSubscriber);
225
+ pubsub_js_1.default.unsubscribe(snippetsGroupSubscriber);
218
226
  };
219
227
  }, [data.snippets]);
220
228
  //RENDERING
@@ -240,6 +248,6 @@ function PrivateMessageSnippets(inProps) {
240
248
  } }),
241
249
  react_1.default.createElement(material_1.List, null, filteredSnippets.map((message) => (react_1.default.createElement(PrivateMessageSnippetItem_1.default, { message: message, key: message.id, onItemClick: () => handleOpenThread(message), secondaryAction: react_1.default.createElement(react_1.default.Fragment, null,
242
250
  message.thread_status === types_1.SCPrivateMessageStatusType.NEW && (react_1.default.createElement(material_1.Icon, { fontSize: "small", color: "secondary" }, "fiber_manual_record")),
243
- !isMobile && (react_1.default.createElement(PrivateMessageSettingsIconButton_1.default, { threadToDelete: messageReceiver(message, authUserId), onItemDeleteConfirm: () => handleDeleteConversation(messageReceiver(message, authUserId)), user: messageReceiver(message, authUserId, true) }))), selected: isSelected(message) })))))))));
251
+ !isMobile && (react_1.default.createElement(PrivateMessageSettingsIconButton_1.default, { threadToDelete: (message === null || message === void 0 ? void 0 : message.group) ? message.group.id : messageReceiver(message, authUserId), onItemDeleteConfirm: () => handleDeleteConversation(messageReceiver(message, authUserId)), user: messageReceiver(message, authUserId, true), group: message === null || message === void 0 ? void 0 : message.group }))), selected: isSelected(message) })))))))));
244
252
  }
245
253
  exports.default = PrivateMessageSnippets;
@@ -24,12 +24,12 @@ export interface GroupSettingsIconButtonProps extends IconButtonProps {
24
24
  [p: string]: any;
25
25
  }
26
26
  /**
27
- * > API documentation for the Community-JS PrivateMessageSettingsIconButton component. Learn about the available props and the CSS API.
27
+ * > API documentation for the Community-JS GroupSettingsIconButton component. Learn about the available props and the CSS API.
28
28
 
29
29
  #### Import
30
30
 
31
31
  ```jsx
32
- import {PrivateMessageSettingsIconButton} from '@selfcommunity/react-ui';
32
+ import {GroupSettingsIconButton} from '@selfcommunity/react-ui';
33
33
  ```
34
34
 
35
35
  #### Component Name
@@ -32,12 +32,12 @@ const MenuRoot = styled(Menu, {
32
32
  slot: 'MenuRoot'
33
33
  })(() => ({}));
34
34
  /**
35
- * > API documentation for the Community-JS PrivateMessageSettingsIconButton component. Learn about the available props and the CSS API.
35
+ * > API documentation for the Community-JS GroupSettingsIconButton component. Learn about the available props and the CSS API.
36
36
 
37
37
  #### Import
38
38
 
39
39
  ```jsx
40
- import {PrivateMessageSettingsIconButton} from '@selfcommunity/react-ui';
40
+ import {GroupSettingsIconButton} from '@selfcommunity/react-ui';
41
41
  ```
42
42
 
43
43
  #### Component Name
@@ -1,5 +1,5 @@
1
1
  import { IconButtonProps } from '@mui/material';
2
- import { SCUserType } from '@selfcommunity/types';
2
+ import { SCGroupType, SCUserType } from '@selfcommunity/types';
3
3
  export interface PrivateMessageSettingsIconButtonProps extends IconButtonProps {
4
4
  /**
5
5
  * Overrides or extends the styles applied to the component.
@@ -17,11 +17,15 @@ export interface PrivateMessageSettingsIconButtonProps extends IconButtonProps {
17
17
  /**
18
18
  * The deleting thread id
19
19
  */
20
- threadToDelete?: any;
20
+ threadToDelete?: number;
21
21
  /**
22
22
  * The user receiver context
23
23
  */
24
24
  user?: SCUserType;
25
+ /**
26
+ * The group
27
+ */
28
+ group?: SCGroupType;
25
29
  /**
26
30
  * Any other properties
27
31
  */
@@ -58,7 +58,7 @@ export default function PrivateMessageSettingsIconButton(inProps) {
58
58
  props: inProps,
59
59
  name: PREFIX
60
60
  });
61
- const { className = null, onMenuItemDeleteClick, user, onItemDeleteConfirm, threadToDelete } = props, rest = __rest(props, ["className", "onMenuItemDeleteClick", "user", "onItemDeleteConfirm", "threadToDelete"]);
61
+ const { className = null, onMenuItemDeleteClick, user, group, onItemDeleteConfirm, threadToDelete } = props, rest = __rest(props, ["className", "onMenuItemDeleteClick", "user", "group", "onItemDeleteConfirm", "threadToDelete"]);
62
62
  // STATE
63
63
  const [anchorEl, setAnchorEl] = useState(null);
64
64
  const [openConfirmDialog, setOpenConfirmDialog] = useState(false);
@@ -86,9 +86,15 @@ export default function PrivateMessageSettingsIconButton(inProps) {
86
86
  * Handles thread deletion
87
87
  */
88
88
  function handleDeleteThread() {
89
- PrivateMessageService.deleteAThread({ user: threadToDelete })
89
+ const params = group ? { group: threadToDelete } : { user: threadToDelete };
90
+ PrivateMessageService.deleteAThread(params)
90
91
  .then(() => {
91
- PubSub.publish('snippetsChannelDelete', threadToDelete);
92
+ if (group) {
93
+ PubSub.publish('snippetsChannelDeleteGroup', threadToDelete);
94
+ }
95
+ else {
96
+ PubSub.publish('snippetsChannelDelete', threadToDelete);
97
+ }
92
98
  handleCloseDialog();
93
99
  })
94
100
  .catch((error) => {
@@ -106,6 +112,10 @@ export default function PrivateMessageSettingsIconButton(inProps) {
106
112
  React.createElement(ListItemIcon, null,
107
113
  React.createElement(Icon, { fontSize: "small" }, "people_alt")),
108
114
  React.createElement(FormattedMessage, { id: "ui.privateMessageSettingsIconButton.item.profile", defaultMessage: "ui.privateMessageSettingsIconButton.item.profile" }))),
115
+ group && (React.createElement(ListItem, { className: classes.item, key: "profile", component: Link, to: scRoutingContext.url(SCRoutes.GROUP_ROUTE_NAME, group) },
116
+ React.createElement(ListItemIcon, null,
117
+ React.createElement(Icon, { fontSize: "small" }, "groups")),
118
+ React.createElement(FormattedMessage, { id: "ui.privateMessageSettingsIconButton.item.group", defaultMessage: "ui.privateMessageSettingsIconButton.item.group" }))),
109
119
  React.createElement(ListItem, { className: classes.item, key: "delete", onClick: threadToDelete ? handleOpenDialog : onMenuItemDeleteClick },
110
120
  React.createElement(ListItemIcon, null,
111
121
  React.createElement(Icon, { fontSize: "small" }, "delete")),
@@ -118,6 +128,10 @@ export default function PrivateMessageSettingsIconButton(inProps) {
118
128
  React.createElement(ListItemIcon, null,
119
129
  React.createElement(Icon, { fontSize: "small" }, "people_alt")),
120
130
  React.createElement(FormattedMessage, { id: "ui.privateMessageSettingsIconButton.item.profile", defaultMessage: "ui.privateMessageSettingsIconButton.item.profile" }))),
131
+ group && (React.createElement(MenuItem, { className: classes.item, component: Link, to: scRoutingContext.url(SCRoutes.GROUP_ROUTE_NAME, group), key: "profile", onClick: handleCloseDialog },
132
+ React.createElement(ListItemIcon, null,
133
+ React.createElement(Icon, { fontSize: "small" }, "groups")),
134
+ React.createElement(FormattedMessage, { id: "ui.privateMessageSettingsIconButton.item.group", defaultMessage: "ui.privateMessageSettingsIconButton.item.group" }))),
121
135
  React.createElement(MenuItem, { className: classes.item, onClick: threadToDelete ? handleOpenDialog : onMenuItemDeleteClick, key: "delete" },
122
136
  React.createElement(ListItemIcon, null,
123
137
  React.createElement(Icon, { fontSize: "small" }, "delete")),
@@ -154,12 +154,16 @@ export default function PrivateMessageSnippets(inProps) {
154
154
  updateSnippets(newSnippets);
155
155
  }
156
156
  }
157
- function handleSnippetsUpdate(message, forDeletion) {
157
+ function handleSnippetsUpdate(message, forDeletion, type) {
158
158
  const newSnippets = [...data.snippets];
159
- if (forDeletion) {
159
+ if (forDeletion && type === SCPrivateMessageType.USER) {
160
160
  const _snippets = newSnippets.filter((s) => messageReceiver(s, authUserId) !== message);
161
161
  updateSnippets(_snippets);
162
162
  }
163
+ else if (forDeletion && SCPrivateMessageType.GROUP) {
164
+ const _snippets = newSnippets.filter((s) => { var _a; return ((_a = s === null || s === void 0 ? void 0 : s.group) === null || _a === void 0 ? void 0 : _a.id) !== message; });
165
+ updateSnippets(_snippets);
166
+ }
163
167
  else {
164
168
  let temp = [...data.snippets];
165
169
  message.map((m) => {
@@ -208,11 +212,15 @@ export default function PrivateMessageSnippets(inProps) {
208
212
  handleSnippetsUpdate(data);
209
213
  });
210
214
  const snippetsSubscriber = PubSub.subscribe('snippetsChannelDelete', (msg, data) => {
211
- handleSnippetsUpdate(data, true);
215
+ handleSnippetsUpdate(data, true, SCPrivateMessageType.USER);
216
+ });
217
+ const snippetsGroupSubscriber = PubSub.subscribe('snippetsChannelDeleteGroup', (msg, data) => {
218
+ handleSnippetsUpdate(data, true, SCPrivateMessageType.GROUP);
212
219
  });
213
220
  return () => {
214
221
  PubSub.unsubscribe(threadSubscriber);
215
222
  PubSub.unsubscribe(snippetsSubscriber);
223
+ PubSub.unsubscribe(snippetsGroupSubscriber);
216
224
  };
217
225
  }, [data.snippets]);
218
226
  //RENDERING
@@ -238,5 +246,5 @@ export default function PrivateMessageSnippets(inProps) {
238
246
  } }),
239
247
  React.createElement(List, null, filteredSnippets.map((message) => (React.createElement(PrivateMessageSnippetItem, { message: message, key: message.id, onItemClick: () => handleOpenThread(message), secondaryAction: React.createElement(React.Fragment, null,
240
248
  message.thread_status === SCPrivateMessageStatusType.NEW && (React.createElement(Icon, { fontSize: "small", color: "secondary" }, "fiber_manual_record")),
241
- !isMobile && (React.createElement(PrivateMessageSettingsIconButton, { threadToDelete: messageReceiver(message, authUserId), onItemDeleteConfirm: () => handleDeleteConversation(messageReceiver(message, authUserId)), user: messageReceiver(message, authUserId, true) }))), selected: isSelected(message) })))))))));
249
+ !isMobile && (React.createElement(PrivateMessageSettingsIconButton, { threadToDelete: (message === null || message === void 0 ? void 0 : message.group) ? message.group.id : messageReceiver(message, authUserId), onItemDeleteConfirm: () => handleDeleteConversation(messageReceiver(message, authUserId)), user: messageReceiver(message, authUserId, true), group: message === null || message === void 0 ? void 0 : message.group }))), selected: isSelected(message) })))))))));
242
250
  }