@selfcommunity/react-ui 0.11.0-alpha.101 → 0.11.0-alpha.102
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/lib/cjs/components/Composer/Composer.js +15 -11
- package/lib/cjs/components/Composer/Layer/AudienceLayer/AudienceLayer.js +4 -15
- package/lib/cjs/components/UserAutocomplete/UserAutocomplete.js +1 -1
- package/lib/esm/components/Composer/Composer.js +15 -11
- package/lib/esm/components/Composer/Layer/AudienceLayer/AudienceLayer.js +4 -15
- package/lib/esm/components/UserAutocomplete/UserAutocomplete.js +1 -1
- package/lib/umd/react-ui.js +1 -1
- package/package.json +4 -4
|
@@ -377,13 +377,13 @@ function Composer(inProps) {
|
|
|
377
377
|
else if (event || (value && Object.prototype.hasOwnProperty.call(value, 'recurring'))) {
|
|
378
378
|
dispatch({ type: 'event', value });
|
|
379
379
|
}
|
|
380
|
-
else if ((Array.isArray(value) &&
|
|
381
|
-
value
|
|
382
|
-
(Array.isArray(recipients) && recipients.length > 0)) {
|
|
380
|
+
else if ((value && Array.isArray(value) && value.some((item) => typeof item === 'object' && !('color' in item))) ||
|
|
381
|
+
(value === null && Array.isArray(recipients) && recipients.length > 0)) {
|
|
383
382
|
dispatch({
|
|
384
383
|
type: 'multiple',
|
|
385
384
|
value: {
|
|
386
385
|
recipients: value,
|
|
386
|
+
addressing: [],
|
|
387
387
|
addressingError: addressingRequiredEnabled && !value ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.composer.addressing.error.missing", defaultMessage: "ui.composer.addressing.error.missing" })) : null
|
|
388
388
|
}
|
|
389
389
|
});
|
|
@@ -393,6 +393,7 @@ function Composer(inProps) {
|
|
|
393
393
|
type: 'multiple',
|
|
394
394
|
value: {
|
|
395
395
|
addressing: value,
|
|
396
|
+
recipients: [],
|
|
396
397
|
addressingError: addressingRequiredEnabled && !value ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.composer.addressing.error.missing", defaultMessage: "ui.composer.addressing.error.missing" })) : null
|
|
397
398
|
}
|
|
398
399
|
});
|
|
@@ -400,19 +401,20 @@ function Composer(inProps) {
|
|
|
400
401
|
setLayer(null);
|
|
401
402
|
}, [group, event, recipients]);
|
|
402
403
|
const handleAddAudienceLayer = (0, react_1.useCallback)(() => {
|
|
404
|
+
const defaultValue = group || (addressing && Object.prototype.hasOwnProperty.call(addressing, 'emotional_image_position'))
|
|
405
|
+
? group
|
|
406
|
+
: event || (addressing && Object.prototype.hasOwnProperty.call(addressing, 'recurring'))
|
|
407
|
+
? event
|
|
408
|
+
: Array.isArray(recipients) && recipients.some((item) => typeof item === 'object' && item !== null && !('color' in item))
|
|
409
|
+
? recipients
|
|
410
|
+
: addressing;
|
|
403
411
|
handleAddLayer({
|
|
404
412
|
name: 'audience',
|
|
405
413
|
Component: AudienceLayer_1.default,
|
|
406
414
|
ComponentProps: {
|
|
407
415
|
onClose: handleRemoveLayer,
|
|
408
416
|
onSave: handleChangeAudience,
|
|
409
|
-
defaultValue:
|
|
410
|
-
? group
|
|
411
|
-
: event || (addressing && Object.prototype.hasOwnProperty.call(addressing, 'recurring'))
|
|
412
|
-
? event
|
|
413
|
-
: (recipients === null || recipients === void 0 ? void 0 : recipients.length) !== 0 || ((recipients === null || recipients === void 0 ? void 0 : recipients.length) !== 0 && !recipients.some((r) => 'color' in r))
|
|
414
|
-
? recipients
|
|
415
|
-
: addressing
|
|
417
|
+
defaultValue: defaultValue
|
|
416
418
|
}
|
|
417
419
|
});
|
|
418
420
|
}, [handleAddLayer, handleRemoveLayer, handleChangeAudience, addressing, event, group, recipients]);
|
|
@@ -705,6 +707,8 @@ function Composer(inProps) {
|
|
|
705
707
|
.map((mediaObjectType) => {
|
|
706
708
|
const props = mediaObjectType.layerComponent ? { onClick: handleMediaTriggerClick(mediaObjectType) } : { onAdd: handleAddMedia };
|
|
707
709
|
return ((0, jsx_runtime_1.jsx)(mediaObjectType.triggerButton, Object.assign({ disabled: isSubmitting || hasMediaShare, color: medias.filter(mediaObjectType.filter).length > 0 ? 'primary' : 'default' }, props), mediaObjectType.name));
|
|
708
|
-
}), (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ disabled: isSubmitting, onClick: handleAddCategoryLayer, color: (categories === null || categories === void 0 ? void 0 : categories.length) !== 0 ? 'primary' : 'default' }, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "category" }) })), (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ color: group || event || (addressing !== null && (addressing === null || addressing === void 0 ? void 0 : addressing.length) > 0)
|
|
710
|
+
}), (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ disabled: isSubmitting, onClick: handleAddCategoryLayer, color: (categories === null || categories === void 0 ? void 0 : categories.length) !== 0 ? 'primary' : 'default' }, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "category" }) })), (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ color: group || event || (addressing !== null && (addressing === null || addressing === void 0 ? void 0 : addressing.length) > 0) || (recipients !== null && (recipients === null || recipients === void 0 ? void 0 : recipients.length) > 0)
|
|
711
|
+
? 'primary'
|
|
712
|
+
: 'default', disabled: isSubmitting || !features.includes(types_1.SCFeatureName.TAGGING) || Boolean(feedObject === null || feedObject === void 0 ? void 0 : feedObject.group) || Boolean(feedObject === null || feedObject === void 0 ? void 0 : feedObject.event), onClick: handleAddAudienceLayer }, { children: group ? ((0, jsx_runtime_1.jsx)(material_1.Icon, { children: "groups" })) : event ? ((0, jsx_runtime_1.jsx)(material_1.Icon, { children: "CalendarIcon" })) : addressing === null || (addressing === null || addressing === void 0 ? void 0 : addressing.length) === 0 ? (addressingRequiredEnabled ? ((0, jsx_runtime_1.jsx)(material_1.Icon, { children: "label" })) : ((0, jsx_runtime_1.jsx)(material_1.Icon, { children: "public" }))) : ((0, jsx_runtime_1.jsx)(material_1.Icon, { children: "label" })) })), preferences[react_core_1.SCPreferences.ADDONS_POST_GEOLOCATION_ENABLED].value && ((0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ disabled: isSubmitting, onClick: handleAddLocationLayer, color: location !== null ? 'primary' : 'default' }, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "add_location_alt" }) }))), preferences[react_core_1.SCPreferences.CONFIGURATIONS_SCHEDULED_POSTS_ENABLED].value && ((0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ disabled: isSubmitting || (Boolean(feedObject === null || feedObject === void 0 ? void 0 : feedObject.scheduled_at) && Boolean(!(feedObject === null || feedObject === void 0 ? void 0 : feedObject.draft))), onClick: handleAddScheduledLayer, color: scheduled_at !== null ? 'primary' : 'default' }, { children: (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.selectedAction }, { children: [(0, jsx_runtime_1.jsx)(material_1.Icon, { children: "access_time" }), scheduled_at !== null && ((0, jsx_runtime_1.jsx)(material_1.Icon, Object.assign({ color: "primary", className: classes.actionSelectedIcon }, { children: "fiber_manual_record" })))] })) })))] }))] })), layer && ((0, jsx_runtime_1.jsx)(LayerTransitionRoot, Object.assign({ className: classes.layerTransitionRoot, in: true, container: dialogRef.current, direction: "left" }, { children: (0, jsx_runtime_1.jsx)(layer.Component, Object.assign({}, layer.ComponentProps)) })))] })));
|
|
709
713
|
}
|
|
710
714
|
exports.default = Composer;
|
|
@@ -83,12 +83,7 @@ const AudienceLayer = react_1.default.forwardRef((props, ref) => {
|
|
|
83
83
|
? AudienceTypes.AUDIENCE_EVENT
|
|
84
84
|
: Object.prototype.hasOwnProperty.call(defaultValue, 'managed_by')
|
|
85
85
|
? AudienceTypes.AUDIENCE_GROUP
|
|
86
|
-
: Array.isArray(defaultValue) &&
|
|
87
|
-
defaultValue.length > 0 &&
|
|
88
|
-
// case: array of user objects
|
|
89
|
-
(((_a = defaultValue[0]) === null || _a === void 0 ? void 0 : _a.username) !== undefined ||
|
|
90
|
-
// case: array of strings
|
|
91
|
-
typeof defaultValue[0] === 'string')
|
|
86
|
+
: Array.isArray(defaultValue) && defaultValue.length > 0 && ((_a = defaultValue[0]) === null || _a === void 0 ? void 0 : _a.username) !== undefined
|
|
92
87
|
? AudienceTypes.AUDIENCE_USERS
|
|
93
88
|
: AudienceTypes.AUDIENCE_TAG);
|
|
94
89
|
// HANDLERS
|
|
@@ -112,16 +107,10 @@ const AudienceLayer = react_1.default.forwardRef((props, ref) => {
|
|
|
112
107
|
(Boolean((value === null || value === void 0 ? void 0 : value.length) === 0) && audience === AudienceTypes.AUDIENCE_ALL && Boolean((defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.length) !== 0)), value: AudienceTypes.AUDIENCE_EVENT, icon: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "CalendarIcon" }), label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.composer.layer.audience.event", defaultMessage: "ui.composer.layer.audience.event" }) })), groupsEnabled && ((0, jsx_runtime_1.jsx)(material_1.Tab, { disabled: (Boolean(value === null || value === void 0 ? void 0 : value.length) && !Object.prototype.hasOwnProperty.call(value, 'managed_by')) ||
|
|
113
108
|
(value !== undefined && Boolean(!(value === null || value === void 0 ? void 0 : value.length)) && audience !== AudienceTypes.AUDIENCE_ALL) ||
|
|
114
109
|
(Boolean((value === null || value === void 0 ? void 0 : value.length) === 0) && audience === AudienceTypes.AUDIENCE_ALL && Boolean((defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.length) !== 0)), value: AudienceTypes.AUDIENCE_GROUP, icon: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "groups" }), label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.composer.layer.audience.group", defaultMessage: "ui.composer.layer.audience.group" }) })), (0, jsx_runtime_1.jsx)(material_1.Tab, { disabled: value &&
|
|
115
|
-
((Array.isArray(value) &&
|
|
116
|
-
(value.some((v) => v === null || v === void 0 ? void 0 : v.username) || // user tagging
|
|
117
|
-
value.some((v) => typeof v === 'string'))) ||
|
|
110
|
+
((Array.isArray(value) && (value.some((v) => v === null || v === void 0 ? void 0 : v.username) || value.some((v) => typeof v === 'string'))) ||
|
|
118
111
|
(!Array.isArray(value) && Object.prototype.hasOwnProperty.call(value, 'managed_by'))) // group object
|
|
119
112
|
, value: AudienceTypes.AUDIENCE_TAG, icon: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "label" }), label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.composer.layer.audience.tag", defaultMessage: "ui.composer.layer.audience.tag" }) }), usersTaggingEnabled && ((0, jsx_runtime_1.jsx)(material_1.Tab, { disabled: value &&
|
|
120
|
-
((Array.isArray(value) &&
|
|
121
|
-
value.length > 0 &&
|
|
122
|
-
// disable only if NOT user objects and NOT strings
|
|
123
|
-
!value.some((v) => v === null || v === void 0 ? void 0 : v.username) &&
|
|
124
|
-
!value.every((v) => typeof v === 'string')) ||
|
|
113
|
+
((Array.isArray(value) && value.length > 0 && !value.some((v) => v === null || v === void 0 ? void 0 : v.username) && !value.every((v) => typeof v === 'string')) ||
|
|
125
114
|
(!Array.isArray(value) &&
|
|
126
115
|
Object.keys(value).length > 0 &&
|
|
127
116
|
(Object.prototype.hasOwnProperty.call(value, 'managed_by') || Object.prototype.hasOwnProperty.call(value, 'recurring')))), value: AudienceTypes.AUDIENCE_USERS, icon: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "people_alt" }), label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.composer.layer.audience.users", defaultMessage: "ui.composer.layer.audience.users" }) }))] })), (0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ className: classes.message }, { children: [audience === AudienceTypes.AUDIENCE_ALL && !taggingRequiredEnabled && ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.composer.layer.audience.all.message", defaultMessage: "ui.composer.layer.audience.all.message" })), audience === AudienceTypes.AUDIENCE_EVENT && ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.composer.layer.audience.event.message", defaultMessage: "ui.composer.layer.audience.event.message" })), audience === AudienceTypes.AUDIENCE_GROUP && ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.composer.layer.audience.group.message", defaultMessage: "ui.composer.layer.audience.group.message" })), audience === AudienceTypes.AUDIENCE_TAG && ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.composer.layer.audience.tag.message", defaultMessage: "ui.composer.layer.audience.tag.message" })), audience === AudienceTypes.AUDIENCE_USERS && ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.composer.layer.audience.users.message", defaultMessage: "ui.composer.layer.audience.users.message" }))] })), audience === AudienceTypes.AUDIENCE_TAG && ((0, jsx_runtime_1.jsx)(material_1.Autocomplete, { className: classes.autocomplete, open: autocompleteOpen, onOpen: handleAutocompleteOpen, onClose: handleAutocompleteClose, multiple: true, options: scAddressingTags || [], getOptionLabel: (option) => option.name || '', value: value, selectOnFocus: true, clearOnBlur: true, handleHomeEndKeys: true, clearIcon: null, noOptionsText: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.composer.layer.audience.tags.empty", defaultMessage: "ui.composer.layer.audience.tags.empty" }), onChange: handleChange, isOptionEqualToValue: (option, value) => value.id === option.id, renderTags: (value, getTagProps) => {
|
|
@@ -132,6 +121,6 @@ const AudienceLayer = react_1.default.forwardRef((props, ref) => {
|
|
|
132
121
|
return ((0, jsx_runtime_1.jsx)("li", Object.assign({}, props, { children: (0, jsx_runtime_1.jsx)(TagChip_1.default, { disposable: false, tag: option, label: (0, jsx_runtime_1.jsx)(react_1.default.Fragment, { children: parts.map((part, index) => ((0, jsx_runtime_1.jsx)("span", Object.assign({ style: { fontWeight: part.highlight ? 700 : 400 } }, { children: part.text }), index))) }) }, option.id) })));
|
|
133
122
|
}, renderInput: (params) => {
|
|
134
123
|
return ((0, jsx_runtime_1.jsx)(material_1.TextField, Object.assign({}, params, TextFieldProps, { InputProps: Object.assign(Object.assign({}, params.InputProps), { autoComplete: 'addressing', endAdornment: (0, jsx_runtime_1.jsx)(react_1.default.Fragment, { children: params.InputProps.endAdornment }) }) })));
|
|
135
|
-
} })), audience === AudienceTypes.AUDIENCE_USERS && (0, jsx_runtime_1.jsx)(UserAutocomplete_1.default, { onChange: handleUsersChange, defaultValue:
|
|
124
|
+
} })), audience === AudienceTypes.AUDIENCE_USERS && (0, jsx_runtime_1.jsx)(UserAutocomplete_1.default, { onChange: handleUsersChange, defaultValue: value }), audience === AudienceTypes.AUDIENCE_GROUP && (0, jsx_runtime_1.jsx)(GroupAutocomplete_1.default, { onChange: handleGroupChange, defaultValue: value }), audience === AudienceTypes.AUDIENCE_EVENT && (0, jsx_runtime_1.jsx)(EventAutocomplete_1.default, { onChange: handleEventChange, defaultValue: value })] }))] })));
|
|
136
125
|
});
|
|
137
126
|
exports.default = AudienceLayer;
|
|
@@ -70,7 +70,7 @@ const UserAutocomplete = (inProps) => {
|
|
|
70
70
|
let resolvedUsers = [];
|
|
71
71
|
try {
|
|
72
72
|
if (names.length > 0) {
|
|
73
|
-
const resp = yield api_services_1.UserService.matchUsernames(names
|
|
73
|
+
const resp = yield api_services_1.UserService.matchUsernames(names);
|
|
74
74
|
const matchedMap = new Map(resp.map((u) => [u.username, u]));
|
|
75
75
|
resolvedUsers = names.map((name) => matchedMap.get(name) || name);
|
|
76
76
|
}
|
|
@@ -375,13 +375,13 @@ export default function Composer(inProps) {
|
|
|
375
375
|
else if (event || (value && Object.prototype.hasOwnProperty.call(value, 'recurring'))) {
|
|
376
376
|
dispatch({ type: 'event', value });
|
|
377
377
|
}
|
|
378
|
-
else if ((Array.isArray(value) &&
|
|
379
|
-
value
|
|
380
|
-
(Array.isArray(recipients) && recipients.length > 0)) {
|
|
378
|
+
else if ((value && Array.isArray(value) && value.some((item) => typeof item === 'object' && !('color' in item))) ||
|
|
379
|
+
(value === null && Array.isArray(recipients) && recipients.length > 0)) {
|
|
381
380
|
dispatch({
|
|
382
381
|
type: 'multiple',
|
|
383
382
|
value: {
|
|
384
383
|
recipients: value,
|
|
384
|
+
addressing: [],
|
|
385
385
|
addressingError: addressingRequiredEnabled && !value ? (_jsx(FormattedMessage, { id: "ui.composer.addressing.error.missing", defaultMessage: "ui.composer.addressing.error.missing" })) : null
|
|
386
386
|
}
|
|
387
387
|
});
|
|
@@ -391,6 +391,7 @@ export default function Composer(inProps) {
|
|
|
391
391
|
type: 'multiple',
|
|
392
392
|
value: {
|
|
393
393
|
addressing: value,
|
|
394
|
+
recipients: [],
|
|
394
395
|
addressingError: addressingRequiredEnabled && !value ? (_jsx(FormattedMessage, { id: "ui.composer.addressing.error.missing", defaultMessage: "ui.composer.addressing.error.missing" })) : null
|
|
395
396
|
}
|
|
396
397
|
});
|
|
@@ -398,19 +399,20 @@ export default function Composer(inProps) {
|
|
|
398
399
|
setLayer(null);
|
|
399
400
|
}, [group, event, recipients]);
|
|
400
401
|
const handleAddAudienceLayer = useCallback(() => {
|
|
402
|
+
const defaultValue = group || (addressing && Object.prototype.hasOwnProperty.call(addressing, 'emotional_image_position'))
|
|
403
|
+
? group
|
|
404
|
+
: event || (addressing && Object.prototype.hasOwnProperty.call(addressing, 'recurring'))
|
|
405
|
+
? event
|
|
406
|
+
: Array.isArray(recipients) && recipients.some((item) => typeof item === 'object' && item !== null && !('color' in item))
|
|
407
|
+
? recipients
|
|
408
|
+
: addressing;
|
|
401
409
|
handleAddLayer({
|
|
402
410
|
name: 'audience',
|
|
403
411
|
Component: AudienceLayer,
|
|
404
412
|
ComponentProps: {
|
|
405
413
|
onClose: handleRemoveLayer,
|
|
406
414
|
onSave: handleChangeAudience,
|
|
407
|
-
defaultValue:
|
|
408
|
-
? group
|
|
409
|
-
: event || (addressing && Object.prototype.hasOwnProperty.call(addressing, 'recurring'))
|
|
410
|
-
? event
|
|
411
|
-
: (recipients === null || recipients === void 0 ? void 0 : recipients.length) !== 0 || ((recipients === null || recipients === void 0 ? void 0 : recipients.length) !== 0 && !recipients.some((r) => 'color' in r))
|
|
412
|
-
? recipients
|
|
413
|
-
: addressing
|
|
415
|
+
defaultValue: defaultValue
|
|
414
416
|
}
|
|
415
417
|
});
|
|
416
418
|
}, [handleAddLayer, handleRemoveLayer, handleChangeAudience, addressing, event, group, recipients]);
|
|
@@ -703,5 +705,7 @@ export default function Composer(inProps) {
|
|
|
703
705
|
.map((mediaObjectType) => {
|
|
704
706
|
const props = mediaObjectType.layerComponent ? { onClick: handleMediaTriggerClick(mediaObjectType) } : { onAdd: handleAddMedia };
|
|
705
707
|
return (_jsx(mediaObjectType.triggerButton, Object.assign({ disabled: isSubmitting || hasMediaShare, color: medias.filter(mediaObjectType.filter).length > 0 ? 'primary' : 'default' }, props), mediaObjectType.name));
|
|
706
|
-
}), _jsx(IconButton, Object.assign({ disabled: isSubmitting, onClick: handleAddCategoryLayer, color: (categories === null || categories === void 0 ? void 0 : categories.length) !== 0 ? 'primary' : 'default' }, { children: _jsx(Icon, { children: "category" }) })), _jsx(IconButton, Object.assign({ color: group || event || (addressing !== null && (addressing === null || addressing === void 0 ? void 0 : addressing.length) > 0)
|
|
708
|
+
}), _jsx(IconButton, Object.assign({ disabled: isSubmitting, onClick: handleAddCategoryLayer, color: (categories === null || categories === void 0 ? void 0 : categories.length) !== 0 ? 'primary' : 'default' }, { children: _jsx(Icon, { children: "category" }) })), _jsx(IconButton, Object.assign({ color: group || event || (addressing !== null && (addressing === null || addressing === void 0 ? void 0 : addressing.length) > 0) || (recipients !== null && (recipients === null || recipients === void 0 ? void 0 : recipients.length) > 0)
|
|
709
|
+
? 'primary'
|
|
710
|
+
: 'default', disabled: isSubmitting || !features.includes(SCFeatureName.TAGGING) || Boolean(feedObject === null || feedObject === void 0 ? void 0 : feedObject.group) || Boolean(feedObject === null || feedObject === void 0 ? void 0 : feedObject.event), onClick: handleAddAudienceLayer }, { children: group ? (_jsx(Icon, { children: "groups" })) : event ? (_jsx(Icon, { children: "CalendarIcon" })) : addressing === null || (addressing === null || addressing === void 0 ? void 0 : addressing.length) === 0 ? (addressingRequiredEnabled ? (_jsx(Icon, { children: "label" })) : (_jsx(Icon, { children: "public" }))) : (_jsx(Icon, { children: "label" })) })), preferences[SCPreferences.ADDONS_POST_GEOLOCATION_ENABLED].value && (_jsx(IconButton, Object.assign({ disabled: isSubmitting, onClick: handleAddLocationLayer, color: location !== null ? 'primary' : 'default' }, { children: _jsx(Icon, { children: "add_location_alt" }) }))), preferences[SCPreferences.CONFIGURATIONS_SCHEDULED_POSTS_ENABLED].value && (_jsx(IconButton, Object.assign({ disabled: isSubmitting || (Boolean(feedObject === null || feedObject === void 0 ? void 0 : feedObject.scheduled_at) && Boolean(!(feedObject === null || feedObject === void 0 ? void 0 : feedObject.draft))), onClick: handleAddScheduledLayer, color: scheduled_at !== null ? 'primary' : 'default' }, { children: _jsxs(Box, Object.assign({ className: classes.selectedAction }, { children: [_jsx(Icon, { children: "access_time" }), scheduled_at !== null && (_jsx(Icon, Object.assign({ color: "primary", className: classes.actionSelectedIcon }, { children: "fiber_manual_record" })))] })) })))] }))] })), layer && (_jsx(LayerTransitionRoot, Object.assign({ className: classes.layerTransitionRoot, in: true, container: dialogRef.current, direction: "left" }, { children: _jsx(layer.Component, Object.assign({}, layer.ComponentProps)) })))] })));
|
|
707
711
|
}
|
|
@@ -80,12 +80,7 @@ const AudienceLayer = React.forwardRef((props, ref) => {
|
|
|
80
80
|
? AudienceTypes.AUDIENCE_EVENT
|
|
81
81
|
: Object.prototype.hasOwnProperty.call(defaultValue, 'managed_by')
|
|
82
82
|
? AudienceTypes.AUDIENCE_GROUP
|
|
83
|
-
: Array.isArray(defaultValue) &&
|
|
84
|
-
defaultValue.length > 0 &&
|
|
85
|
-
// case: array of user objects
|
|
86
|
-
(((_a = defaultValue[0]) === null || _a === void 0 ? void 0 : _a.username) !== undefined ||
|
|
87
|
-
// case: array of strings
|
|
88
|
-
typeof defaultValue[0] === 'string')
|
|
83
|
+
: Array.isArray(defaultValue) && defaultValue.length > 0 && ((_a = defaultValue[0]) === null || _a === void 0 ? void 0 : _a.username) !== undefined
|
|
89
84
|
? AudienceTypes.AUDIENCE_USERS
|
|
90
85
|
: AudienceTypes.AUDIENCE_TAG);
|
|
91
86
|
// HANDLERS
|
|
@@ -109,16 +104,10 @@ const AudienceLayer = React.forwardRef((props, ref) => {
|
|
|
109
104
|
(Boolean((value === null || value === void 0 ? void 0 : value.length) === 0) && audience === AudienceTypes.AUDIENCE_ALL && Boolean((defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.length) !== 0)), value: AudienceTypes.AUDIENCE_EVENT, icon: _jsx(Icon, { children: "CalendarIcon" }), label: _jsx(FormattedMessage, { id: "ui.composer.layer.audience.event", defaultMessage: "ui.composer.layer.audience.event" }) })), groupsEnabled && (_jsx(Tab, { disabled: (Boolean(value === null || value === void 0 ? void 0 : value.length) && !Object.prototype.hasOwnProperty.call(value, 'managed_by')) ||
|
|
110
105
|
(value !== undefined && Boolean(!(value === null || value === void 0 ? void 0 : value.length)) && audience !== AudienceTypes.AUDIENCE_ALL) ||
|
|
111
106
|
(Boolean((value === null || value === void 0 ? void 0 : value.length) === 0) && audience === AudienceTypes.AUDIENCE_ALL && Boolean((defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.length) !== 0)), value: AudienceTypes.AUDIENCE_GROUP, icon: _jsx(Icon, { children: "groups" }), label: _jsx(FormattedMessage, { id: "ui.composer.layer.audience.group", defaultMessage: "ui.composer.layer.audience.group" }) })), _jsx(Tab, { disabled: value &&
|
|
112
|
-
((Array.isArray(value) &&
|
|
113
|
-
(value.some((v) => v === null || v === void 0 ? void 0 : v.username) || // user tagging
|
|
114
|
-
value.some((v) => typeof v === 'string'))) ||
|
|
107
|
+
((Array.isArray(value) && (value.some((v) => v === null || v === void 0 ? void 0 : v.username) || value.some((v) => typeof v === 'string'))) ||
|
|
115
108
|
(!Array.isArray(value) && Object.prototype.hasOwnProperty.call(value, 'managed_by'))) // group object
|
|
116
109
|
, value: AudienceTypes.AUDIENCE_TAG, icon: _jsx(Icon, { children: "label" }), label: _jsx(FormattedMessage, { id: "ui.composer.layer.audience.tag", defaultMessage: "ui.composer.layer.audience.tag" }) }), usersTaggingEnabled && (_jsx(Tab, { disabled: value &&
|
|
117
|
-
((Array.isArray(value) &&
|
|
118
|
-
value.length > 0 &&
|
|
119
|
-
// disable only if NOT user objects and NOT strings
|
|
120
|
-
!value.some((v) => v === null || v === void 0 ? void 0 : v.username) &&
|
|
121
|
-
!value.every((v) => typeof v === 'string')) ||
|
|
110
|
+
((Array.isArray(value) && value.length > 0 && !value.some((v) => v === null || v === void 0 ? void 0 : v.username) && !value.every((v) => typeof v === 'string')) ||
|
|
122
111
|
(!Array.isArray(value) &&
|
|
123
112
|
Object.keys(value).length > 0 &&
|
|
124
113
|
(Object.prototype.hasOwnProperty.call(value, 'managed_by') || Object.prototype.hasOwnProperty.call(value, 'recurring')))), value: AudienceTypes.AUDIENCE_USERS, icon: _jsx(Icon, { children: "people_alt" }), label: _jsx(FormattedMessage, { id: "ui.composer.layer.audience.users", defaultMessage: "ui.composer.layer.audience.users" }) }))] })), _jsxs(Typography, Object.assign({ className: classes.message }, { children: [audience === AudienceTypes.AUDIENCE_ALL && !taggingRequiredEnabled && (_jsx(FormattedMessage, { id: "ui.composer.layer.audience.all.message", defaultMessage: "ui.composer.layer.audience.all.message" })), audience === AudienceTypes.AUDIENCE_EVENT && (_jsx(FormattedMessage, { id: "ui.composer.layer.audience.event.message", defaultMessage: "ui.composer.layer.audience.event.message" })), audience === AudienceTypes.AUDIENCE_GROUP && (_jsx(FormattedMessage, { id: "ui.composer.layer.audience.group.message", defaultMessage: "ui.composer.layer.audience.group.message" })), audience === AudienceTypes.AUDIENCE_TAG && (_jsx(FormattedMessage, { id: "ui.composer.layer.audience.tag.message", defaultMessage: "ui.composer.layer.audience.tag.message" })), audience === AudienceTypes.AUDIENCE_USERS && (_jsx(FormattedMessage, { id: "ui.composer.layer.audience.users.message", defaultMessage: "ui.composer.layer.audience.users.message" }))] })), audience === AudienceTypes.AUDIENCE_TAG && (_jsx(Autocomplete, { className: classes.autocomplete, open: autocompleteOpen, onOpen: handleAutocompleteOpen, onClose: handleAutocompleteClose, multiple: true, options: scAddressingTags || [], getOptionLabel: (option) => option.name || '', value: value, selectOnFocus: true, clearOnBlur: true, handleHomeEndKeys: true, clearIcon: null, noOptionsText: _jsx(FormattedMessage, { id: "ui.composer.layer.audience.tags.empty", defaultMessage: "ui.composer.layer.audience.tags.empty" }), onChange: handleChange, isOptionEqualToValue: (option, value) => value.id === option.id, renderTags: (value, getTagProps) => {
|
|
@@ -129,6 +118,6 @@ const AudienceLayer = React.forwardRef((props, ref) => {
|
|
|
129
118
|
return (_jsx("li", Object.assign({}, props, { children: _jsx(TagChip, { disposable: false, tag: option, label: _jsx(React.Fragment, { children: parts.map((part, index) => (_jsx("span", Object.assign({ style: { fontWeight: part.highlight ? 700 : 400 } }, { children: part.text }), index))) }) }, option.id) })));
|
|
130
119
|
}, renderInput: (params) => {
|
|
131
120
|
return (_jsx(TextField, Object.assign({}, params, TextFieldProps, { InputProps: Object.assign(Object.assign({}, params.InputProps), { autoComplete: 'addressing', endAdornment: _jsx(React.Fragment, { children: params.InputProps.endAdornment }) }) })));
|
|
132
|
-
} })), audience === AudienceTypes.AUDIENCE_USERS && _jsx(UserAutocomplete, { onChange: handleUsersChange, defaultValue:
|
|
121
|
+
} })), audience === AudienceTypes.AUDIENCE_USERS && _jsx(UserAutocomplete, { onChange: handleUsersChange, defaultValue: value }), audience === AudienceTypes.AUDIENCE_GROUP && _jsx(GroupAutocomplete, { onChange: handleGroupChange, defaultValue: value }), audience === AudienceTypes.AUDIENCE_EVENT && _jsx(EventAutocomplete, { onChange: handleEventChange, defaultValue: value })] }))] })));
|
|
133
122
|
});
|
|
134
123
|
export default AudienceLayer;
|
|
@@ -68,7 +68,7 @@ const UserAutocomplete = (inProps) => {
|
|
|
68
68
|
let resolvedUsers = [];
|
|
69
69
|
try {
|
|
70
70
|
if (names.length > 0) {
|
|
71
|
-
const resp = yield UserService.matchUsernames(names
|
|
71
|
+
const resp = yield UserService.matchUsernames(names);
|
|
72
72
|
const matchedMap = new Map(resp.map((u) => [u.username, u]));
|
|
73
73
|
resolvedUsers = names.map((name) => matchedMap.get(name) || name);
|
|
74
74
|
}
|