diff --git src/bp-activity/js/blocks/latest-activities.js src/bp-activity/js/blocks/latest-activities.js
index 614751c24..158c08d57 100644
|
|
|
exports.default = void 0; |
| 128 | 128 | /** |
| 129 | 129 | * WordPress dependencies. |
| 130 | 130 | */ |
| 131 | | var _wp = wp, |
| 132 | | InspectorControls = _wp.blockEditor.InspectorControls, |
| 133 | | _wp$components = _wp.components, |
| 134 | | Disabled = _wp$components.Disabled, |
| 135 | | PanelBody = _wp$components.PanelBody, |
| 136 | | RangeControl = _wp$components.RangeControl, |
| 137 | | SelectControl = _wp$components.SelectControl, |
| 138 | | TextControl = _wp$components.TextControl, |
| 139 | | _wp$element = _wp.element, |
| 140 | | Fragment = _wp$element.Fragment, |
| 141 | | createElement = _wp$element.createElement, |
| 142 | | __ = _wp.i18n.__; |
| | 131 | const { |
| | 132 | blockEditor: { |
| | 133 | InspectorControls |
| | 134 | }, |
| | 135 | components: { |
| | 136 | Disabled, |
| | 137 | PanelBody, |
| | 138 | RangeControl, |
| | 139 | SelectControl, |
| | 140 | TextControl |
| | 141 | }, |
| | 142 | element: { |
| | 143 | Fragment, |
| | 144 | createElement |
| | 145 | }, |
| | 146 | i18n: { |
| | 147 | __ |
| | 148 | } |
| | 149 | } = wp; |
| 143 | 150 | /** |
| 144 | 151 | * BuddyPress dependencies. |
| 145 | 152 | */ |
| 146 | 153 | |
| 147 | | var _bp = bp, |
| 148 | | ServerSideRender = _bp.blockComponents.ServerSideRender, |
| 149 | | _bp$blockData = _bp.blockData, |
| 150 | | currentPostId = _bp$blockData.currentPostId, |
| 151 | | activityTypes = _bp$blockData.activityTypes; |
| 152 | | |
| 153 | | var editDynamicActivitiesBlock = function editDynamicActivitiesBlock(_ref) { |
| 154 | | var attributes = _ref.attributes, |
| 155 | | setAttributes = _ref.setAttributes; |
| 156 | | var postId = attributes.postId, |
| 157 | | maxActivities = attributes.maxActivities, |
| 158 | | type = attributes.type, |
| 159 | | title = attributes.title; |
| 160 | | var post = currentPostId(); |
| 161 | | var types = activityTypes(); |
| | 154 | const { |
| | 155 | blockComponents: { |
| | 156 | ServerSideRender |
| | 157 | }, |
| | 158 | blockData: { |
| | 159 | currentPostId, |
| | 160 | activityTypes |
| | 161 | } |
| | 162 | } = bp; |
| | 163 | |
| | 164 | const editDynamicActivitiesBlock = ({ |
| | 165 | attributes, |
| | 166 | setAttributes |
| | 167 | }) => { |
| | 168 | const { |
| | 169 | postId, |
| | 170 | maxActivities, |
| | 171 | type, |
| | 172 | title |
| | 173 | } = attributes; |
| | 174 | const post = currentPostId(); |
| | 175 | const types = activityTypes(); |
| 162 | 176 | |
| 163 | 177 | if (!postId && post) { |
| 164 | 178 | setAttributes({ |
| 165 | 179 | postId: post |
| 166 | 180 | }); |
| | 181 | |
| | 182 | if (!attributes.postId) { |
| | 183 | attributes.postId = post; |
| | 184 | } |
| 167 | 185 | } |
| 168 | 186 | |
| 169 | 187 | return createElement(Fragment, null, createElement(InspectorControls, null, createElement(PanelBody, { |
| … |
… |
var editDynamicActivitiesBlock = function editDynamicActivitiesBlock(_ref) { |
| 173 | 191 | }, createElement(TextControl, { |
| 174 | 192 | label: __('Title', 'buddypress'), |
| 175 | 193 | value: title, |
| 176 | | onChange: function onChange(text) { |
| | 194 | onChange: text => { |
| 177 | 195 | setAttributes({ |
| 178 | 196 | title: text |
| 179 | 197 | }); |
| … |
… |
var editDynamicActivitiesBlock = function editDynamicActivitiesBlock(_ref) { |
| 181 | 199 | }), createElement(RangeControl, { |
| 182 | 200 | label: __('Maximum amount to display', 'buddypress'), |
| 183 | 201 | value: maxActivities, |
| 184 | | onChange: function onChange(value) { |
| 185 | | return setAttributes({ |
| 186 | | maxActivities: value |
| 187 | | }); |
| 188 | | }, |
| | 202 | onChange: value => setAttributes({ |
| | 203 | maxActivities: value |
| | 204 | }), |
| 189 | 205 | min: 1, |
| 190 | 206 | max: 10, |
| 191 | 207 | required: true |
| … |
… |
var editDynamicActivitiesBlock = function editDynamicActivitiesBlock(_ref) { |
| 194 | 210 | label: __('Type', 'buddypress'), |
| 195 | 211 | value: type, |
| 196 | 212 | options: types, |
| 197 | | onChange: function onChange(option) { |
| | 213 | onChange: option => { |
| 198 | 214 | setAttributes({ |
| 199 | 215 | type: option |
| 200 | 216 | }); |
| … |
… |
exports.default = void 0; |
| 218 | 234 | /** |
| 219 | 235 | * WordPress dependencies. |
| 220 | 236 | */ |
| 221 | | var _wp = wp, |
| 222 | | createBlock = _wp.blocks.createBlock; |
| | 237 | const { |
| | 238 | blocks: { |
| | 239 | createBlock |
| | 240 | } |
| | 241 | } = wp; |
| 223 | 242 | /** |
| 224 | 243 | * Transforms Nouveau Activity Widget to Activity Block. |
| 225 | 244 | * |
| 226 | 245 | * @type {Object} |
| 227 | 246 | */ |
| 228 | 247 | |
| 229 | | var transforms = { |
| | 248 | const transforms = { |
| 230 | 249 | from: [{ |
| 231 | 250 | type: 'block', |
| 232 | 251 | blocks: ['core/legacy-widget'], |
| 233 | | isMatch: function isMatch(_ref) { |
| 234 | | var idBase = _ref.idBase, |
| 235 | | instance = _ref.instance; |
| 236 | | |
| | 252 | isMatch: ({ |
| | 253 | idBase, |
| | 254 | instance |
| | 255 | }) => { |
| 237 | 256 | if (!(instance !== null && instance !== void 0 && instance.raw)) { |
| 238 | 257 | return false; |
| 239 | 258 | } |
| 240 | 259 | |
| 241 | 260 | return idBase === 'bp_latest_activities'; |
| 242 | 261 | }, |
| 243 | | transform: function transform(_ref2) { |
| 244 | | var instance = _ref2.instance; |
| 245 | | var regex = /i:\d*;s:\d*:"(.*?)";/gmi; |
| 246 | | var types = []; |
| 247 | | var matches; |
| | 262 | transform: ({ |
| | 263 | instance |
| | 264 | }) => { |
| | 265 | const regex = /i:\d*;s:\d*:"(.*?)";/gmi; |
| | 266 | let types = []; |
| | 267 | let matches; |
| 248 | 268 | |
| 249 | 269 | while ((matches = regex.exec(instance.raw.type)) !== null) { |
| 250 | 270 | if (matches.index === regex.lastIndex) { |
| 251 | 271 | regex.lastIndex++; |
| 252 | 272 | } |
| 253 | 273 | |
| 254 | | matches.forEach(function (match, groupIndex) { |
| | 274 | matches.forEach((match, groupIndex) => { |
| 255 | 275 | if (1 === groupIndex) { |
| 256 | 276 | types.push(match); |
| 257 | 277 | } |
| … |
… |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de |
| 280 | 300 | /** |
| 281 | 301 | * WordPress dependencies. |
| 282 | 302 | */ |
| 283 | | var _wp = wp, |
| 284 | | registerBlockType = _wp.blocks.registerBlockType, |
| 285 | | __ = _wp.i18n.__; |
| | 303 | const { |
| | 304 | blocks: { |
| | 305 | registerBlockType |
| | 306 | }, |
| | 307 | i18n: { |
| | 308 | __ |
| | 309 | } |
| | 310 | } = wp; |
| 286 | 311 | /** |
| 287 | 312 | * Internal dependencies. |
| 288 | 313 | */ |
diff --git src/js/bp-activity/js/blocks/latest-activities/edit.js src/js/bp-activity/js/blocks/latest-activities/edit.js
index 942874abe..f5ebcaddc 100644
|
|
|
const editDynamicActivitiesBlock = ( { attributes, setAttributes } ) => { |
| 41 | 41 | |
| 42 | 42 | if ( ! postId && post ) { |
| 43 | 43 | setAttributes( { postId: post } ); |
| | 44 | if ( ! attributes.postId ) { |
| | 45 | attributes.postId = post; |
| | 46 | } |
| 44 | 47 | } |
| 45 | 48 | |
| 46 | 49 | return ( |