@selfcommunity/react-ui 0.11.0-alpha.73 → 0.11.0-alpha.74

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.
@@ -29,6 +29,7 @@ function Settings(props) {
29
29
  const [_settings, setSetting] = (0, react_1.useState)(null);
30
30
  // HOOKS
31
31
  const { enqueueSnackbar } = (0, notistack_1.useSnackbar)();
32
+ const privateMessagingEnabled = (0, react_core_1.useSCPreferenceEnabled)(react_core_1.SCPreferences.ADDONS_PRIVATE_MESSAGES_ENABLED);
32
33
  // EFFECTS
33
34
  (0, react_1.useEffect)(() => {
34
35
  if (scUserContext.user) {
@@ -69,6 +70,8 @@ function Settings(props) {
69
70
  case types_1.SCUserProfileSettings.INTERACTION:
70
71
  return ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ gutterBottom: true, variant: "body1" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.userProfileEditSettings.interaction.title", defaultMessage: "ui.userProfileEditSettings.interaction.title" }) })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.control }, { children: (0, jsx_runtime_1.jsxs)(material_1.FormControl, { children: [(0, jsx_runtime_1.jsx)(material_1.FormLabel, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.userProfileEditSettings.interaction.label", defaultMessage: "ui.userProfileEditSettings.interaction.label" }) }), (0, jsx_runtime_1.jsxs)(material_1.RadioGroup, Object.assign({ "aria-labelledby": "email notification settings", value: _settings.qa_frequency, name: react_core_1.SCNotification.NOTIFICATIONS_SETTINGS_QA_FREQUENCY, onChange: handleChange }, { children: [(0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { value: -1, control: (0, jsx_runtime_1.jsx)(material_1.Radio, { size: "small" }), label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.userProfileEditSettings.interaction.immediatly", defaultMessage: "ui.userProfileEditSettings.interaction.immediatly" }) }), (0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { value: 1, control: (0, jsx_runtime_1.jsx)(material_1.Radio, { size: "small" }), label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.userProfileEditSettings.interaction.daily", defaultMessage: "ui.userProfileEditSettings.interaction.daily" }) }), (0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { value: 0, control: (0, jsx_runtime_1.jsx)(material_1.Radio, { size: "small" }), label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.userProfileEditSettings.interaction.never", defaultMessage: "ui.userProfileEditSettings.interaction.never" }) })] }))] }) }))] }, setting));
71
72
  case types_1.SCUserProfileSettings.PRIVATE_MESSAGE:
73
+ if (!privateMessagingEnabled)
74
+ return null;
72
75
  return ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ gutterBottom: true, variant: "body1" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.userProfileEditSettings.privateMessage.title", defaultMessage: "ui.userProfileEditSettings.privateMessage.title" }) })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.control }, { children: (0, jsx_runtime_1.jsxs)(material_1.FormControl, { children: [(0, jsx_runtime_1.jsx)(material_1.FormLabel, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.userProfileEditSettings.privateMessage.label", defaultMessage: "ui.userProfileEditSettings.privateMessage.label" }) }), (0, jsx_runtime_1.jsxs)(material_1.RadioGroup, Object.assign({ "aria-labelledby": "email notification settings", value: _settings.email_notification_not_qa, name: react_core_1.SCNotification.NOTIFICATIONS_SETTINGS_EMAIL_NOT_QA, onChange: handleChange }, { children: [(0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { value: 1, control: (0, jsx_runtime_1.jsx)(material_1.Radio, { size: "small" }), label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.userProfileEditSettings.privateMessage.email", defaultMessage: "ui.userProfileEditSettings.privateMessage.email" }) }), (0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { value: 0, control: (0, jsx_runtime_1.jsx)(material_1.Radio, { size: "small" }), label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.userProfileEditSettings.privateMessage.frontend", defaultMessage: "ui.userProfileEditSettings.privateMessage.frontend" }) })] }))] }) }))] }, setting));
73
76
  default:
74
77
  return null;
@@ -3,7 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import React, { useEffect, useState } from 'react';
4
4
  import { Box, FormControl, FormControlLabel, FormLabel, Radio, RadioGroup, Typography, styled } from '@mui/material';
5
5
  import { FormattedMessage } from 'react-intl';
6
- import { SCNotification, useSCUser } from '@selfcommunity/react-core';
6
+ import { SCNotification, SCPreferences, useSCPreferenceEnabled, useSCUser } from '@selfcommunity/react-core';
7
7
  import classNames from 'classnames';
8
8
  import SettingsSkeleton from './SettingsSkeleton';
9
9
  import { useSnackbar } from 'notistack';
@@ -27,6 +27,7 @@ export default function Settings(props) {
27
27
  const [_settings, setSetting] = useState(null);
28
28
  // HOOKS
29
29
  const { enqueueSnackbar } = useSnackbar();
30
+ const privateMessagingEnabled = useSCPreferenceEnabled(SCPreferences.ADDONS_PRIVATE_MESSAGES_ENABLED);
30
31
  // EFFECTS
31
32
  useEffect(() => {
32
33
  if (scUserContext.user) {
@@ -67,6 +68,8 @@ export default function Settings(props) {
67
68
  case SCUserProfileSettings.INTERACTION:
68
69
  return (_jsxs(React.Fragment, { children: [_jsx(Typography, Object.assign({ gutterBottom: true, variant: "body1" }, { children: _jsx(FormattedMessage, { id: "ui.userProfileEditSettings.interaction.title", defaultMessage: "ui.userProfileEditSettings.interaction.title" }) })), _jsx(Box, Object.assign({ className: classes.control }, { children: _jsxs(FormControl, { children: [_jsx(FormLabel, { children: _jsx(FormattedMessage, { id: "ui.userProfileEditSettings.interaction.label", defaultMessage: "ui.userProfileEditSettings.interaction.label" }) }), _jsxs(RadioGroup, Object.assign({ "aria-labelledby": "email notification settings", value: _settings.qa_frequency, name: SCNotification.NOTIFICATIONS_SETTINGS_QA_FREQUENCY, onChange: handleChange }, { children: [_jsx(FormControlLabel, { value: -1, control: _jsx(Radio, { size: "small" }), label: _jsx(FormattedMessage, { id: "ui.userProfileEditSettings.interaction.immediatly", defaultMessage: "ui.userProfileEditSettings.interaction.immediatly" }) }), _jsx(FormControlLabel, { value: 1, control: _jsx(Radio, { size: "small" }), label: _jsx(FormattedMessage, { id: "ui.userProfileEditSettings.interaction.daily", defaultMessage: "ui.userProfileEditSettings.interaction.daily" }) }), _jsx(FormControlLabel, { value: 0, control: _jsx(Radio, { size: "small" }), label: _jsx(FormattedMessage, { id: "ui.userProfileEditSettings.interaction.never", defaultMessage: "ui.userProfileEditSettings.interaction.never" }) })] }))] }) }))] }, setting));
69
70
  case SCUserProfileSettings.PRIVATE_MESSAGE:
71
+ if (!privateMessagingEnabled)
72
+ return null;
70
73
  return (_jsxs(React.Fragment, { children: [_jsx(Typography, Object.assign({ gutterBottom: true, variant: "body1" }, { children: _jsx(FormattedMessage, { id: "ui.userProfileEditSettings.privateMessage.title", defaultMessage: "ui.userProfileEditSettings.privateMessage.title" }) })), _jsx(Box, Object.assign({ className: classes.control }, { children: _jsxs(FormControl, { children: [_jsx(FormLabel, { children: _jsx(FormattedMessage, { id: "ui.userProfileEditSettings.privateMessage.label", defaultMessage: "ui.userProfileEditSettings.privateMessage.label" }) }), _jsxs(RadioGroup, Object.assign({ "aria-labelledby": "email notification settings", value: _settings.email_notification_not_qa, name: SCNotification.NOTIFICATIONS_SETTINGS_EMAIL_NOT_QA, onChange: handleChange }, { children: [_jsx(FormControlLabel, { value: 1, control: _jsx(Radio, { size: "small" }), label: _jsx(FormattedMessage, { id: "ui.userProfileEditSettings.privateMessage.email", defaultMessage: "ui.userProfileEditSettings.privateMessage.email" }) }), _jsx(FormControlLabel, { value: 0, control: _jsx(Radio, { size: "small" }), label: _jsx(FormattedMessage, { id: "ui.userProfileEditSettings.privateMessage.frontend", defaultMessage: "ui.userProfileEditSettings.privateMessage.frontend" }) })] }))] }) }))] }, setting));
71
74
  default:
72
75
  return null;