2018-09-21 23:44:04 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* WooCommerce Admin (Dashboard) Notes.
|
|
|
|
*
|
|
|
|
* The WooCommerce admin notes class gets admin notes data from storage and checks validity.
|
|
|
|
*
|
2018-09-26 23:35:01 +00:00
|
|
|
* @package WooCommerce Admin/Classes
|
2018-09-21 23:44:04 +00:00
|
|
|
*/
|
2018-09-26 23:35:01 +00:00
|
|
|
|
2019-07-31 19:47:32 +00:00
|
|
|
namespace Automattic\WooCommerce\Admin\Notes;
|
|
|
|
|
2018-09-21 23:44:04 +00:00
|
|
|
defined( 'ABSPATH' ) || exit;
|
|
|
|
|
2018-09-26 23:35:01 +00:00
|
|
|
/**
|
|
|
|
* WC_Admin_Note class.
|
|
|
|
*/
|
2019-07-31 19:47:32 +00:00
|
|
|
class WC_Admin_Note extends \WC_Data {
|
2018-09-21 23:44:04 +00:00
|
|
|
|
2018-09-26 23:35:01 +00:00
|
|
|
// Note types.
|
2020-05-22 13:48:40 +00:00
|
|
|
const E_WC_ADMIN_NOTE_ERROR = 'error'; // used for presenting error conditions.
|
|
|
|
const E_WC_ADMIN_NOTE_WARNING = 'warning'; // used for presenting warning conditions.
|
|
|
|
const E_WC_ADMIN_NOTE_UPDATE = 'update'; // i.e. used when a new version is available.
|
|
|
|
const E_WC_ADMIN_NOTE_INFORMATIONAL = 'info'; // used for presenting informational messages.
|
|
|
|
const E_WC_ADMIN_NOTE_MARKETING = 'marketing'; // used for adding marketing messages.
|
2018-09-21 23:44:04 +00:00
|
|
|
|
2018-09-26 23:35:01 +00:00
|
|
|
// Note status codes.
|
2020-06-15 23:42:35 +00:00
|
|
|
const E_WC_ADMIN_NOTE_PENDING = 'pending'; // the note is pending - hidden but not actioned.
|
2018-09-26 23:38:50 +00:00
|
|
|
const E_WC_ADMIN_NOTE_UNACTIONED = 'unactioned'; // the note has not yet been actioned by a user.
|
|
|
|
const E_WC_ADMIN_NOTE_ACTIONED = 'actioned'; // the note has had its action completed by a user.
|
2019-03-18 20:41:35 +00:00
|
|
|
const E_WC_ADMIN_NOTE_SNOOZED = 'snoozed'; // the note has been snoozed by a user.
|
2018-09-25 00:09:39 +00:00
|
|
|
|
2018-09-21 23:44:04 +00:00
|
|
|
/**
|
|
|
|
* This is the name of this object type.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $object_type = 'admin-note';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Cache group.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $cache_group = 'admin-note';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Note constructor. Loads note data.
|
|
|
|
*
|
|
|
|
* @param mixed $data Note data, object, or ID.
|
|
|
|
*/
|
|
|
|
public function __construct( $data = '' ) {
|
2019-03-20 22:03:14 +00:00
|
|
|
// Set default data here to allow `content_data` to be an object.
|
|
|
|
$this->data = array(
|
|
|
|
'name' => '-',
|
|
|
|
'type' => self::E_WC_ADMIN_NOTE_INFORMATIONAL,
|
|
|
|
'locale' => 'en_US',
|
|
|
|
'title' => '-',
|
|
|
|
'content' => '-',
|
2019-07-31 19:47:32 +00:00
|
|
|
'content_data' => new \stdClass(),
|
2019-03-20 22:03:14 +00:00
|
|
|
'status' => self::E_WC_ADMIN_NOTE_UNACTIONED,
|
|
|
|
'source' => 'woocommerce',
|
|
|
|
'date_created' => '0000-00-00 00:00:00',
|
|
|
|
'date_reminder' => '',
|
|
|
|
'is_snoozable' => false,
|
|
|
|
'actions' => array(),
|
Inbox notification: layout changes (https://github.com/woocommerce/woocommerce-admin/pull/4218)
* Inbox notification: Added layout changes (https://github.com/woocommerce/woocommerce-admin/pull/4256)
* Added notes layout and image to the API
Added note layout and note image to the API and the DB
* Unit test modified
Unit test where modified to adapt them to the new elements
* Changed the frontend following the new designs.
The fronted was changed to follow the new inbox messages design.
* Changed default layout type in DB
* Added all the requested visual element
Changed the cards' js, css and actions to achieve the visual requirements
* Added "layout" and "image" to inboxQuery
* Modal confirmation buttons repaired
* Added "layout" and "image" to docs examples.
* Removed "updateNote" from action.js
Removed "updateNote" from action.js, I left it by mistake.
* Spelling error corrected
The button text "Dismiss all message" was corrected
* noteName removed and icon added to make code reviewing easier
This commit removes the "noteName" from card.js and adds the icon to make code reviewing easier
* Dismiss action button refactor
Refactor of the dismiss action button in the InboxNoteCard class
* Removed unnecessary control
* Destructured all the note properties
* Colors replaced by existing variable
* Removed setting of layout and image in the creation of the notes
* Removed blank lines added by mistake
* Close dismiss dropdown when clicking away from the popover.
* Prevented the closing of the inbox panel with an action in the modal
* Added small design changes
* Removed unused "Gridicon" import
* Prevent showing the image tag when the layout is blank
* The method name getDismissButton was changed to getDismissConfirmationButton
* Removed unnecessary vendor-prefixed properties
* Improved note filtering in unreadNotes method
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Inbox notification: Remove icons (https://github.com/woocommerce/woocommerce-admin/pull/4258)
* Info icon removed from inbox notifications
The info icon was removed from inbox notifications
# Conflicts:
# src/Notes/DataStore.php
* Removed "icon" from inboxQuery
* Tests repeared
Some problems with the unit tests were repaired in this commit
# Conflicts:
# docs/examples/activity-panel-inbox.md
# Conflicts:
# tests/api/admin-notes.php
* Removed icon from card.js
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
* Inbox notification: Add dismiss functionality (https://github.com/woocommerce/woocommerce-admin/pull/4262)
* Added is_deleted param to soft delete
# Conflicts:
# src/API/Notes.php
# src/Install.php
# src/Notes/DataStore.php
# src/Notes/WC_Admin_Note.php
# src/Notes/WC_Admin_Notes.php
# tests/api/admin-notes.php
* Added the Dismiss functionality
# Conflicts:
# client/header/activity-panel/panels/inbox/action.js
* Where clause repeared
* Added Snackbar after action.
* API modified to dismiss notes
* Small refactor in "get_item" method
This commit adds a small refactor in "get_item" method to use "prepare_note_data_for_response"
* Added missing logic to Dismiss note
This commit adds missing client logic to Dismiss note.
# Conflicts:
# client/header/activity-panel/panels/inbox/action.js
# client/header/activity-panel/panels/inbox/card.js
* Moved the delete action to WC_Admin_Notes.php
The delete action was moved to WC_Admin_Notes.php to follow the pattern.
* Added changes to dismiss messages
This commit addeds changes to the messages soft delete.
* DataStore.php repaired
This commits adds some code that was deleted by mistake and the param "is_deleted" has been escaped.
* Spelling error corrected
The button text "Dismiss all message" was corrected
* Repaired "get_notes_where_clauses" method
A problem with the deleted notes was repaired
* Added a comment to DataStore.php
* Stopped sending the "dismissType" to action.js
The "dismissType" is not sent to action.js anymore.
* Bugfix: now the method get_notes_with_name also returns deleted notes
* Bugfix: repaired empty notification list
This commit repairs a bug that happens when there isn't anything in the inbox notification list
* Small refactor to not use "some" Lodash method anymore
* Small refactor in rednderNotes method
* Added check to set_layout
* Added small refactor to delete_all_notes method
* Fixed code comment error
* Bugfix: repaired the "delete_note" call
* Inbox notification: Added layout changes (https://github.com/woocommerce/woocommerce-admin/pull/4256)
* Added notes layout and image to the API
Added note layout and note image to the API and the DB
* Unit test modified
Unit test where modified to adapt them to the new elements
* Changed the frontend following the new designs.
The fronted was changed to follow the new inbox messages design.
* Changed default layout type in DB
* Added all the requested visual element
Changed the cards' js, css and actions to achieve the visual requirements
* Added "layout" and "image" to inboxQuery
* Modal confirmation buttons repaired
* Added "layout" and "image" to docs examples.
* Removed "updateNote" from action.js
Removed "updateNote" from action.js, I left it by mistake.
* Spelling error corrected
The button text "Dismiss all message" was corrected
* noteName removed and icon added to make code reviewing easier
This commit removes the "noteName" from card.js and adds the icon to make code reviewing easier
* Dismiss action button refactor
Refactor of the dismiss action button in the InboxNoteCard class
* Removed unnecessary control
* Destructured all the note properties
* Colors replaced by existing variable
* Removed setting of layout and image in the creation of the notes
* Removed blank lines added by mistake
* Close dismiss dropdown when clicking away from the popover.
* Prevented the closing of the inbox panel with an action in the modal
* Added small design changes
* Removed unused "Gridicon" import
* Prevent showing the image tag when the layout is blank
* The method name getDismissButton was changed to getDismissConfirmationButton
* Removed unnecessary vendor-prefixed properties
* Improved note filtering in unreadNotes method
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Inbox notification: Remove icons (https://github.com/woocommerce/woocommerce-admin/pull/4258)
* Info icon removed from inbox notifications
The info icon was removed from inbox notifications
# Conflicts:
# src/Notes/DataStore.php
* Removed "icon" from inboxQuery
* Tests repeared
Some problems with the unit tests were repaired in this commit
# Conflicts:
# docs/examples/activity-panel-inbox.md
# Conflicts:
# tests/api/admin-notes.php
* Removed icon from card.js
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
* Improved error handling for the set_layout method
* Bugfix: fixed error handling clicks inside dropdowns
* Bugfix: repaired dropdown onBlur handler
This commit repairs a weird behavior that the dropdown onBlur handler method had sometimes.
* Text error changed
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Inbox notification: Add undo snackbar button after deletion (https://github.com/woocommerce/woocommerce-admin/pull/4281)
* Added undo snakbar button for a single note
# Conflicts:
# client/wc-api/notes/mutations.js
# src/Notes/DataStore.php
# src/Notes/WC_Admin_Notes.php
* Added a button to undo the deletion of all notes
# Conflicts:
# client/wc-api/notes/operations.js
# src/API/Notes.php
* Code adapted to make code reviewing easier
There was some code that also was present in another PR, that code was removed to make code reviewing easier.
* UnitTest added
This commit adds some unit tests
* Added verification for API response
* Added casting to $note_id
* Inbox notification: Added layout changes (https://github.com/woocommerce/woocommerce-admin/pull/4256)
* Added notes layout and image to the API
Added note layout and note image to the API and the DB
* Unit test modified
Unit test where modified to adapt them to the new elements
* Changed the frontend following the new designs.
The fronted was changed to follow the new inbox messages design.
* Changed default layout type in DB
* Added all the requested visual element
Changed the cards' js, css and actions to achieve the visual requirements
* Added "layout" and "image" to inboxQuery
* Modal confirmation buttons repaired
* Added "layout" and "image" to docs examples.
* Removed "updateNote" from action.js
Removed "updateNote" from action.js, I left it by mistake.
* Spelling error corrected
The button text "Dismiss all message" was corrected
* noteName removed and icon added to make code reviewing easier
This commit removes the "noteName" from card.js and adds the icon to make code reviewing easier
* Dismiss action button refactor
Refactor of the dismiss action button in the InboxNoteCard class
* Removed unnecessary control
* Destructured all the note properties
* Colors replaced by existing variable
* Removed setting of layout and image in the creation of the notes
* Removed blank lines added by mistake
* Close dismiss dropdown when clicking away from the popover.
* Prevented the closing of the inbox panel with an action in the modal
* Added small design changes
* Removed unused "Gridicon" import
* Prevent showing the image tag when the layout is blank
* The method name getDismissButton was changed to getDismissConfirmationButton
* Removed unnecessary vendor-prefixed properties
* Improved note filtering in unreadNotes method
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Inbox notification: Remove icons (https://github.com/woocommerce/woocommerce-admin/pull/4258)
* Info icon removed from inbox notifications
The info icon was removed from inbox notifications
# Conflicts:
# src/Notes/DataStore.php
* Removed "icon" from inboxQuery
* Tests repeared
Some problems with the unit tests were repaired in this commit
# Conflicts:
# docs/examples/activity-panel-inbox.md
# Conflicts:
# tests/api/admin-notes.php
* Removed icon from card.js
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
* Inbox notification: Add dismiss functionality (https://github.com/woocommerce/woocommerce-admin/pull/4262)
* Added is_deleted param to soft delete
# Conflicts:
# src/API/Notes.php
# src/Install.php
# src/Notes/DataStore.php
# src/Notes/WC_Admin_Note.php
# src/Notes/WC_Admin_Notes.php
# tests/api/admin-notes.php
* Added the Dismiss functionality
# Conflicts:
# client/header/activity-panel/panels/inbox/action.js
* Where clause repeared
* Added Snackbar after action.
* API modified to dismiss notes
* Small refactor in "get_item" method
This commit adds a small refactor in "get_item" method to use "prepare_note_data_for_response"
* Added missing logic to Dismiss note
This commit adds missing client logic to Dismiss note.
# Conflicts:
# client/header/activity-panel/panels/inbox/action.js
# client/header/activity-panel/panels/inbox/card.js
* Moved the delete action to WC_Admin_Notes.php
The delete action was moved to WC_Admin_Notes.php to follow the pattern.
* Added changes to dismiss messages
This commit addeds changes to the messages soft delete.
* DataStore.php repaired
This commits adds some code that was deleted by mistake and the param "is_deleted" has been escaped.
* Spelling error corrected
The button text "Dismiss all message" was corrected
* Repaired "get_notes_where_clauses" method
A problem with the deleted notes was repaired
* Added a comment to DataStore.php
* Stopped sending the "dismissType" to action.js
The "dismissType" is not sent to action.js anymore.
* Bugfix: now the method get_notes_with_name also returns deleted notes
* Bugfix: repaired empty notification list
This commit repairs a bug that happens when there isn't anything in the inbox notification list
* Small refactor to not use "some" Lodash method anymore
* Small refactor in rednderNotes method
* Added check to set_layout
* Added small refactor to delete_all_notes method
* Fixed code comment error
* Bugfix: repaired the "delete_note" call
* Inbox notification: Added layout changes (https://github.com/woocommerce/woocommerce-admin/pull/4256)
* Added notes layout and image to the API
Added note layout and note image to the API and the DB
* Unit test modified
Unit test where modified to adapt them to the new elements
* Changed the frontend following the new designs.
The fronted was changed to follow the new inbox messages design.
* Changed default layout type in DB
* Added all the requested visual element
Changed the cards' js, css and actions to achieve the visual requirements
* Added "layout" and "image" to inboxQuery
* Modal confirmation buttons repaired
* Added "layout" and "image" to docs examples.
* Removed "updateNote" from action.js
Removed "updateNote" from action.js, I left it by mistake.
* Spelling error corrected
The button text "Dismiss all message" was corrected
* noteName removed and icon added to make code reviewing easier
This commit removes the "noteName" from card.js and adds the icon to make code reviewing easier
* Dismiss action button refactor
Refactor of the dismiss action button in the InboxNoteCard class
* Removed unnecessary control
* Destructured all the note properties
* Colors replaced by existing variable
* Removed setting of layout and image in the creation of the notes
* Removed blank lines added by mistake
* Close dismiss dropdown when clicking away from the popover.
* Prevented the closing of the inbox panel with an action in the modal
* Added small design changes
* Removed unused "Gridicon" import
* Prevent showing the image tag when the layout is blank
* The method name getDismissButton was changed to getDismissConfirmationButton
* Removed unnecessary vendor-prefixed properties
* Improved note filtering in unreadNotes method
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Inbox notification: Remove icons (https://github.com/woocommerce/woocommerce-admin/pull/4258)
* Info icon removed from inbox notifications
The info icon was removed from inbox notifications
# Conflicts:
# src/Notes/DataStore.php
* Removed "icon" from inboxQuery
* Tests repeared
Some problems with the unit tests were repaired in this commit
# Conflicts:
# docs/examples/activity-panel-inbox.md
# Conflicts:
# tests/api/admin-notes.php
* Removed icon from card.js
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
* Improved error handling for the set_layout method
* Bugfix: fixed error handling clicks inside dropdowns
* Bugfix: repaired dropdown onBlur handler
This commit repairs a weird behavior that the dropdown onBlur handler method had sometimes.
* Text error changed
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Stopped sending the "dismissType" to action.js
The "dismissType" is not sent to action.js anymore.
# Conflicts:
# client/header/activity-panel/panels/inbox/card.js
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Bugfix: solved problem when a note was undismissed
There was a problem with the undismiss functionality. When a note was undismissed, it always was recovered with "plain" layout. This commit solves this problem.
* Inbox notification: add event recording (https://github.com/woocommerce/woocommerce-admin/pull/4320)
* Added events recording
This commit adds events recording to the inbox notifications
# Conflicts:
# client/header/activity-panel/panels/inbox/index.js
* Added 'home_screen' verification
Changed recorded name, now when the client is in the WooCommerce 'home' page we record 'home_screen' instead of 'wc-admin'.
* Added a naming fix and a new prop to the recordEvent
* bugfix: added control before interaction with bodyNotificationRef
* Added more unit tests for new endpoints
This commit adds tests for deleting a single note and for deleting all the notes, both without permission.
* Modified variable name
* Refactor: prop rename and small logic change
* Screen name getter moved into the InboxNoteCard
This commit moves the screen name getter inside the InboxNoteCard.
# Conflicts:
# client/header/activity-panel/panels/inbox/index.js
* Removed "screen" from state
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
* Refactor in admin-notes unit tests
Some unnecessary controls were removed from the admin-notes unit tests
* Indentation fixed in Install.php. Replaced spaces with tabs.
* Inbox notification: added new placeholder and empty card (https://github.com/woocommerce/woocommerce-admin/pull/4379)
* Added a new placeholder and an empty card
This commit adds a new placeholder and a new empty card to the inbox panel
# Conflicts:
# client/header/activity-panel/panels/inbox/index.js
# client/header/activity-panel/panels/inbox/style.scss
* Added border to read notes
* Improved note filtering in unreadNotes method and validNotes
# Conflicts:
# client/header/activity-panel/panels/inbox/index.js
* Actions render refactored
The actions render was refactored in InboxNoteCard component
* Refactor of InboxPanel component
The methods getUnreadNotesCount and hasValidNotes were separated from the InboxPanel component
# Conflicts:
# client/header/activity-panel/panels/inbox/index.js
* Refactor inbox panel subtitle classes
* Added changes for when a note is undismissed
This commit adds the requested changes in behavior and design for when a note is dismissed.
# Conflicts:
# client/header/activity-panel/panels/inbox/index.js
* Bugfix: Added key to itemlist
The InboxNotePlaceholder is shown as an itemlist but it didn't have a key. This commit adds it.
* Removed unnecessary validation
* Refactored actionList map
This commit adds a refactor to the actionList map
* Changes to the getUndoDismissRequesting functionality
This commit adds a few changes to the getUndoDismissRequesting functionality
* Changed className prop
* Changed other className prop
* Modified InboxPanel rendering
* Removed unnecessary method in placeholder.js
* Simplified the card.js renderActions method
* Change renderActions return in card.js
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
* Inbox notification: add client unit tests (https://github.com/woocommerce/woocommerce-admin/pull/4386)
* Added client unit tests
* Added test cases for getUnreadNotesCount and hasValidNotes
* Corrected typo error
* Removed Enzyme and added React Testing Library
* Removed unnecessary param
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
* Resolved some conflicts with master
* Marketing note test repaired
This commit repairs the marketing note test
* Added note type 'marketing' to delete all functionality
* Removed set_icon method from some notes and docs
* Added set_icon method as deprecated to prevent errors.
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
2020-06-03 11:43:35 +00:00
|
|
|
'layout' => 'plain',
|
|
|
|
'image' => '',
|
|
|
|
'is_deleted' => false,
|
2019-03-20 22:03:14 +00:00
|
|
|
);
|
|
|
|
|
2018-09-21 23:44:04 +00:00
|
|
|
parent::__construct( $data );
|
|
|
|
|
|
|
|
if ( $data instanceof WC_Admin_Note ) {
|
|
|
|
$this->set_id( absint( $data->get_id() ) );
|
2018-10-10 23:46:08 +00:00
|
|
|
} elseif ( is_numeric( $data ) ) {
|
2018-09-21 23:44:04 +00:00
|
|
|
$this->set_id( $data );
|
|
|
|
} elseif ( is_object( $data ) && ! empty( $data->note_id ) ) {
|
|
|
|
$this->set_id( $data->note_id );
|
|
|
|
$this->set_props( (array) $data );
|
|
|
|
$this->set_object_read( true );
|
|
|
|
} else {
|
|
|
|
$this->set_object_read( true );
|
|
|
|
}
|
|
|
|
|
2019-07-31 19:47:32 +00:00
|
|
|
$this->data_store = \WC_Data_Store::load( 'admin-note' );
|
2018-09-21 23:44:04 +00:00
|
|
|
if ( $this->get_id() > 0 ) {
|
|
|
|
$this->data_store->read( $this );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-24 17:13:05 +00:00
|
|
|
/**
|
|
|
|
* Merge changes with data and clear.
|
|
|
|
*
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
|
|
|
public function apply_changes() {
|
|
|
|
$this->data = array_replace_recursive( $this->data, $this->changes ); // @codingStandardsIgnoreLine
|
|
|
|
|
|
|
|
// Note actions need to be replaced wholesale.
|
|
|
|
// Merging arrays doesn't allow for deleting note actions.
|
|
|
|
if ( isset( $this->changes['actions'] ) ) {
|
|
|
|
$this->data['actions'] = $this->changes['actions'];
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->changes = array();
|
|
|
|
}
|
|
|
|
|
2018-09-25 23:55:03 +00:00
|
|
|
/*
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
| Helpers
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
| Methods for getting allowed types, statuses.
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get allowed types.
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
2018-09-27 17:48:25 +00:00
|
|
|
public static function get_allowed_types() {
|
2018-09-25 23:55:03 +00:00
|
|
|
$allowed_types = array(
|
|
|
|
self::E_WC_ADMIN_NOTE_ERROR,
|
|
|
|
self::E_WC_ADMIN_NOTE_WARNING,
|
|
|
|
self::E_WC_ADMIN_NOTE_UPDATE,
|
|
|
|
self::E_WC_ADMIN_NOTE_INFORMATIONAL,
|
2020-05-22 13:48:40 +00:00
|
|
|
self::E_WC_ADMIN_NOTE_MARKETING,
|
2018-09-25 23:55:03 +00:00
|
|
|
);
|
|
|
|
|
2019-12-05 23:06:11 +00:00
|
|
|
return apply_filters( 'woocommerce_note_types', $allowed_types );
|
2018-09-25 23:55:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get allowed statuses.
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
2018-09-27 17:48:25 +00:00
|
|
|
public static function get_allowed_statuses() {
|
2018-09-25 23:55:03 +00:00
|
|
|
$allowed_statuses = array(
|
2020-06-05 01:51:25 +00:00
|
|
|
self::E_WC_ADMIN_NOTE_PENDING,
|
2018-09-25 23:55:03 +00:00
|
|
|
self::E_WC_ADMIN_NOTE_ACTIONED,
|
|
|
|
self::E_WC_ADMIN_NOTE_UNACTIONED,
|
2019-03-18 20:41:35 +00:00
|
|
|
self::E_WC_ADMIN_NOTE_SNOOZED,
|
2018-09-25 23:55:03 +00:00
|
|
|
);
|
|
|
|
|
2019-12-05 23:06:11 +00:00
|
|
|
return apply_filters( 'woocommerce_note_statuses', $allowed_statuses );
|
2018-09-25 23:55:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-09-21 23:44:04 +00:00
|
|
|
/*
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
| Getters
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
| Methods for getting data from the note object.
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2020-04-22 16:05:11 +00:00
|
|
|
/**
|
|
|
|
* Returns all data for this object.
|
|
|
|
*
|
|
|
|
* Override \WC_Data::get_data() to avoid errantly including meta data
|
|
|
|
* from ID collisions with the posts table.
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function get_data() {
|
|
|
|
return array_merge( array( 'id' => $this->get_id() ), $this->data );
|
|
|
|
}
|
|
|
|
|
2018-09-21 23:44:04 +00:00
|
|
|
/**
|
|
|
|
* Get note name.
|
|
|
|
*
|
|
|
|
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function get_name( $context = 'view' ) {
|
|
|
|
return $this->get_prop( 'name', $context );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get note type.
|
|
|
|
*
|
|
|
|
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function get_type( $context = 'view' ) {
|
|
|
|
return $this->get_prop( 'type', $context );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get note locale.
|
|
|
|
*
|
|
|
|
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function get_locale( $context = 'view' ) {
|
|
|
|
return $this->get_prop( 'locale', $context );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get note title.
|
|
|
|
*
|
|
|
|
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function get_title( $context = 'view' ) {
|
|
|
|
return $this->get_prop( 'title', $context );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get note content.
|
|
|
|
*
|
|
|
|
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function get_content( $context = 'view' ) {
|
|
|
|
return $this->get_prop( 'content', $context );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get note content data (i.e. values that would be needed for re-localization)
|
|
|
|
*
|
|
|
|
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function get_content_data( $context = 'view' ) {
|
|
|
|
return $this->get_prop( 'content_data', $context );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get note status.
|
|
|
|
*
|
|
|
|
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function get_status( $context = 'view' ) {
|
|
|
|
return $this->get_prop( 'status', $context );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get note source.
|
|
|
|
*
|
|
|
|
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function get_source( $context = 'view' ) {
|
|
|
|
return $this->get_prop( 'source', $context );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get date note was created.
|
|
|
|
*
|
|
|
|
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
|
|
|
|
* @return WC_DateTime|NULL object if the date is set or null if there is no date.
|
|
|
|
*/
|
|
|
|
public function get_date_created( $context = 'view' ) {
|
|
|
|
return $this->get_prop( 'date_created', $context );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get date on which user should be reminded of the note (if any).
|
|
|
|
*
|
|
|
|
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
|
|
|
|
* @return WC_DateTime|NULL object if the date is set or null if there is no date.
|
|
|
|
*/
|
|
|
|
public function get_date_reminder( $context = 'view' ) {
|
|
|
|
return $this->get_prop( 'date_reminder', $context );
|
|
|
|
}
|
|
|
|
|
2019-03-16 00:43:06 +00:00
|
|
|
/**
|
|
|
|
* Get note snoozability.
|
|
|
|
*
|
|
|
|
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
|
|
|
|
* @return bool Whether or not the note can be snoozed.
|
|
|
|
*/
|
|
|
|
public function get_is_snoozable( $context = 'view' ) {
|
|
|
|
return $this->get_prop( 'is_snoozable', $context );
|
|
|
|
}
|
|
|
|
|
2018-09-21 23:44:04 +00:00
|
|
|
/**
|
|
|
|
* Get actions on the note (if any).
|
|
|
|
*
|
|
|
|
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function get_actions( $context = 'view' ) {
|
|
|
|
return $this->get_prop( 'actions', $context );
|
|
|
|
}
|
|
|
|
|
Inbox notification: layout changes (https://github.com/woocommerce/woocommerce-admin/pull/4218)
* Inbox notification: Added layout changes (https://github.com/woocommerce/woocommerce-admin/pull/4256)
* Added notes layout and image to the API
Added note layout and note image to the API and the DB
* Unit test modified
Unit test where modified to adapt them to the new elements
* Changed the frontend following the new designs.
The fronted was changed to follow the new inbox messages design.
* Changed default layout type in DB
* Added all the requested visual element
Changed the cards' js, css and actions to achieve the visual requirements
* Added "layout" and "image" to inboxQuery
* Modal confirmation buttons repaired
* Added "layout" and "image" to docs examples.
* Removed "updateNote" from action.js
Removed "updateNote" from action.js, I left it by mistake.
* Spelling error corrected
The button text "Dismiss all message" was corrected
* noteName removed and icon added to make code reviewing easier
This commit removes the "noteName" from card.js and adds the icon to make code reviewing easier
* Dismiss action button refactor
Refactor of the dismiss action button in the InboxNoteCard class
* Removed unnecessary control
* Destructured all the note properties
* Colors replaced by existing variable
* Removed setting of layout and image in the creation of the notes
* Removed blank lines added by mistake
* Close dismiss dropdown when clicking away from the popover.
* Prevented the closing of the inbox panel with an action in the modal
* Added small design changes
* Removed unused "Gridicon" import
* Prevent showing the image tag when the layout is blank
* The method name getDismissButton was changed to getDismissConfirmationButton
* Removed unnecessary vendor-prefixed properties
* Improved note filtering in unreadNotes method
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Inbox notification: Remove icons (https://github.com/woocommerce/woocommerce-admin/pull/4258)
* Info icon removed from inbox notifications
The info icon was removed from inbox notifications
# Conflicts:
# src/Notes/DataStore.php
* Removed "icon" from inboxQuery
* Tests repeared
Some problems with the unit tests were repaired in this commit
# Conflicts:
# docs/examples/activity-panel-inbox.md
# Conflicts:
# tests/api/admin-notes.php
* Removed icon from card.js
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
* Inbox notification: Add dismiss functionality (https://github.com/woocommerce/woocommerce-admin/pull/4262)
* Added is_deleted param to soft delete
# Conflicts:
# src/API/Notes.php
# src/Install.php
# src/Notes/DataStore.php
# src/Notes/WC_Admin_Note.php
# src/Notes/WC_Admin_Notes.php
# tests/api/admin-notes.php
* Added the Dismiss functionality
# Conflicts:
# client/header/activity-panel/panels/inbox/action.js
* Where clause repeared
* Added Snackbar after action.
* API modified to dismiss notes
* Small refactor in "get_item" method
This commit adds a small refactor in "get_item" method to use "prepare_note_data_for_response"
* Added missing logic to Dismiss note
This commit adds missing client logic to Dismiss note.
# Conflicts:
# client/header/activity-panel/panels/inbox/action.js
# client/header/activity-panel/panels/inbox/card.js
* Moved the delete action to WC_Admin_Notes.php
The delete action was moved to WC_Admin_Notes.php to follow the pattern.
* Added changes to dismiss messages
This commit addeds changes to the messages soft delete.
* DataStore.php repaired
This commits adds some code that was deleted by mistake and the param "is_deleted" has been escaped.
* Spelling error corrected
The button text "Dismiss all message" was corrected
* Repaired "get_notes_where_clauses" method
A problem with the deleted notes was repaired
* Added a comment to DataStore.php
* Stopped sending the "dismissType" to action.js
The "dismissType" is not sent to action.js anymore.
* Bugfix: now the method get_notes_with_name also returns deleted notes
* Bugfix: repaired empty notification list
This commit repairs a bug that happens when there isn't anything in the inbox notification list
* Small refactor to not use "some" Lodash method anymore
* Small refactor in rednderNotes method
* Added check to set_layout
* Added small refactor to delete_all_notes method
* Fixed code comment error
* Bugfix: repaired the "delete_note" call
* Inbox notification: Added layout changes (https://github.com/woocommerce/woocommerce-admin/pull/4256)
* Added notes layout and image to the API
Added note layout and note image to the API and the DB
* Unit test modified
Unit test where modified to adapt them to the new elements
* Changed the frontend following the new designs.
The fronted was changed to follow the new inbox messages design.
* Changed default layout type in DB
* Added all the requested visual element
Changed the cards' js, css and actions to achieve the visual requirements
* Added "layout" and "image" to inboxQuery
* Modal confirmation buttons repaired
* Added "layout" and "image" to docs examples.
* Removed "updateNote" from action.js
Removed "updateNote" from action.js, I left it by mistake.
* Spelling error corrected
The button text "Dismiss all message" was corrected
* noteName removed and icon added to make code reviewing easier
This commit removes the "noteName" from card.js and adds the icon to make code reviewing easier
* Dismiss action button refactor
Refactor of the dismiss action button in the InboxNoteCard class
* Removed unnecessary control
* Destructured all the note properties
* Colors replaced by existing variable
* Removed setting of layout and image in the creation of the notes
* Removed blank lines added by mistake
* Close dismiss dropdown when clicking away from the popover.
* Prevented the closing of the inbox panel with an action in the modal
* Added small design changes
* Removed unused "Gridicon" import
* Prevent showing the image tag when the layout is blank
* The method name getDismissButton was changed to getDismissConfirmationButton
* Removed unnecessary vendor-prefixed properties
* Improved note filtering in unreadNotes method
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Inbox notification: Remove icons (https://github.com/woocommerce/woocommerce-admin/pull/4258)
* Info icon removed from inbox notifications
The info icon was removed from inbox notifications
# Conflicts:
# src/Notes/DataStore.php
* Removed "icon" from inboxQuery
* Tests repeared
Some problems with the unit tests were repaired in this commit
# Conflicts:
# docs/examples/activity-panel-inbox.md
# Conflicts:
# tests/api/admin-notes.php
* Removed icon from card.js
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
* Improved error handling for the set_layout method
* Bugfix: fixed error handling clicks inside dropdowns
* Bugfix: repaired dropdown onBlur handler
This commit repairs a weird behavior that the dropdown onBlur handler method had sometimes.
* Text error changed
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Inbox notification: Add undo snackbar button after deletion (https://github.com/woocommerce/woocommerce-admin/pull/4281)
* Added undo snakbar button for a single note
# Conflicts:
# client/wc-api/notes/mutations.js
# src/Notes/DataStore.php
# src/Notes/WC_Admin_Notes.php
* Added a button to undo the deletion of all notes
# Conflicts:
# client/wc-api/notes/operations.js
# src/API/Notes.php
* Code adapted to make code reviewing easier
There was some code that also was present in another PR, that code was removed to make code reviewing easier.
* UnitTest added
This commit adds some unit tests
* Added verification for API response
* Added casting to $note_id
* Inbox notification: Added layout changes (https://github.com/woocommerce/woocommerce-admin/pull/4256)
* Added notes layout and image to the API
Added note layout and note image to the API and the DB
* Unit test modified
Unit test where modified to adapt them to the new elements
* Changed the frontend following the new designs.
The fronted was changed to follow the new inbox messages design.
* Changed default layout type in DB
* Added all the requested visual element
Changed the cards' js, css and actions to achieve the visual requirements
* Added "layout" and "image" to inboxQuery
* Modal confirmation buttons repaired
* Added "layout" and "image" to docs examples.
* Removed "updateNote" from action.js
Removed "updateNote" from action.js, I left it by mistake.
* Spelling error corrected
The button text "Dismiss all message" was corrected
* noteName removed and icon added to make code reviewing easier
This commit removes the "noteName" from card.js and adds the icon to make code reviewing easier
* Dismiss action button refactor
Refactor of the dismiss action button in the InboxNoteCard class
* Removed unnecessary control
* Destructured all the note properties
* Colors replaced by existing variable
* Removed setting of layout and image in the creation of the notes
* Removed blank lines added by mistake
* Close dismiss dropdown when clicking away from the popover.
* Prevented the closing of the inbox panel with an action in the modal
* Added small design changes
* Removed unused "Gridicon" import
* Prevent showing the image tag when the layout is blank
* The method name getDismissButton was changed to getDismissConfirmationButton
* Removed unnecessary vendor-prefixed properties
* Improved note filtering in unreadNotes method
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Inbox notification: Remove icons (https://github.com/woocommerce/woocommerce-admin/pull/4258)
* Info icon removed from inbox notifications
The info icon was removed from inbox notifications
# Conflicts:
# src/Notes/DataStore.php
* Removed "icon" from inboxQuery
* Tests repeared
Some problems with the unit tests were repaired in this commit
# Conflicts:
# docs/examples/activity-panel-inbox.md
# Conflicts:
# tests/api/admin-notes.php
* Removed icon from card.js
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
* Inbox notification: Add dismiss functionality (https://github.com/woocommerce/woocommerce-admin/pull/4262)
* Added is_deleted param to soft delete
# Conflicts:
# src/API/Notes.php
# src/Install.php
# src/Notes/DataStore.php
# src/Notes/WC_Admin_Note.php
# src/Notes/WC_Admin_Notes.php
# tests/api/admin-notes.php
* Added the Dismiss functionality
# Conflicts:
# client/header/activity-panel/panels/inbox/action.js
* Where clause repeared
* Added Snackbar after action.
* API modified to dismiss notes
* Small refactor in "get_item" method
This commit adds a small refactor in "get_item" method to use "prepare_note_data_for_response"
* Added missing logic to Dismiss note
This commit adds missing client logic to Dismiss note.
# Conflicts:
# client/header/activity-panel/panels/inbox/action.js
# client/header/activity-panel/panels/inbox/card.js
* Moved the delete action to WC_Admin_Notes.php
The delete action was moved to WC_Admin_Notes.php to follow the pattern.
* Added changes to dismiss messages
This commit addeds changes to the messages soft delete.
* DataStore.php repaired
This commits adds some code that was deleted by mistake and the param "is_deleted" has been escaped.
* Spelling error corrected
The button text "Dismiss all message" was corrected
* Repaired "get_notes_where_clauses" method
A problem with the deleted notes was repaired
* Added a comment to DataStore.php
* Stopped sending the "dismissType" to action.js
The "dismissType" is not sent to action.js anymore.
* Bugfix: now the method get_notes_with_name also returns deleted notes
* Bugfix: repaired empty notification list
This commit repairs a bug that happens when there isn't anything in the inbox notification list
* Small refactor to not use "some" Lodash method anymore
* Small refactor in rednderNotes method
* Added check to set_layout
* Added small refactor to delete_all_notes method
* Fixed code comment error
* Bugfix: repaired the "delete_note" call
* Inbox notification: Added layout changes (https://github.com/woocommerce/woocommerce-admin/pull/4256)
* Added notes layout and image to the API
Added note layout and note image to the API and the DB
* Unit test modified
Unit test where modified to adapt them to the new elements
* Changed the frontend following the new designs.
The fronted was changed to follow the new inbox messages design.
* Changed default layout type in DB
* Added all the requested visual element
Changed the cards' js, css and actions to achieve the visual requirements
* Added "layout" and "image" to inboxQuery
* Modal confirmation buttons repaired
* Added "layout" and "image" to docs examples.
* Removed "updateNote" from action.js
Removed "updateNote" from action.js, I left it by mistake.
* Spelling error corrected
The button text "Dismiss all message" was corrected
* noteName removed and icon added to make code reviewing easier
This commit removes the "noteName" from card.js and adds the icon to make code reviewing easier
* Dismiss action button refactor
Refactor of the dismiss action button in the InboxNoteCard class
* Removed unnecessary control
* Destructured all the note properties
* Colors replaced by existing variable
* Removed setting of layout and image in the creation of the notes
* Removed blank lines added by mistake
* Close dismiss dropdown when clicking away from the popover.
* Prevented the closing of the inbox panel with an action in the modal
* Added small design changes
* Removed unused "Gridicon" import
* Prevent showing the image tag when the layout is blank
* The method name getDismissButton was changed to getDismissConfirmationButton
* Removed unnecessary vendor-prefixed properties
* Improved note filtering in unreadNotes method
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Inbox notification: Remove icons (https://github.com/woocommerce/woocommerce-admin/pull/4258)
* Info icon removed from inbox notifications
The info icon was removed from inbox notifications
# Conflicts:
# src/Notes/DataStore.php
* Removed "icon" from inboxQuery
* Tests repeared
Some problems with the unit tests were repaired in this commit
# Conflicts:
# docs/examples/activity-panel-inbox.md
# Conflicts:
# tests/api/admin-notes.php
* Removed icon from card.js
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
* Improved error handling for the set_layout method
* Bugfix: fixed error handling clicks inside dropdowns
* Bugfix: repaired dropdown onBlur handler
This commit repairs a weird behavior that the dropdown onBlur handler method had sometimes.
* Text error changed
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Stopped sending the "dismissType" to action.js
The "dismissType" is not sent to action.js anymore.
# Conflicts:
# client/header/activity-panel/panels/inbox/card.js
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Bugfix: solved problem when a note was undismissed
There was a problem with the undismiss functionality. When a note was undismissed, it always was recovered with "plain" layout. This commit solves this problem.
* Inbox notification: add event recording (https://github.com/woocommerce/woocommerce-admin/pull/4320)
* Added events recording
This commit adds events recording to the inbox notifications
# Conflicts:
# client/header/activity-panel/panels/inbox/index.js
* Added 'home_screen' verification
Changed recorded name, now when the client is in the WooCommerce 'home' page we record 'home_screen' instead of 'wc-admin'.
* Added a naming fix and a new prop to the recordEvent
* bugfix: added control before interaction with bodyNotificationRef
* Added more unit tests for new endpoints
This commit adds tests for deleting a single note and for deleting all the notes, both without permission.
* Modified variable name
* Refactor: prop rename and small logic change
* Screen name getter moved into the InboxNoteCard
This commit moves the screen name getter inside the InboxNoteCard.
# Conflicts:
# client/header/activity-panel/panels/inbox/index.js
* Removed "screen" from state
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
* Refactor in admin-notes unit tests
Some unnecessary controls were removed from the admin-notes unit tests
* Indentation fixed in Install.php. Replaced spaces with tabs.
* Inbox notification: added new placeholder and empty card (https://github.com/woocommerce/woocommerce-admin/pull/4379)
* Added a new placeholder and an empty card
This commit adds a new placeholder and a new empty card to the inbox panel
# Conflicts:
# client/header/activity-panel/panels/inbox/index.js
# client/header/activity-panel/panels/inbox/style.scss
* Added border to read notes
* Improved note filtering in unreadNotes method and validNotes
# Conflicts:
# client/header/activity-panel/panels/inbox/index.js
* Actions render refactored
The actions render was refactored in InboxNoteCard component
* Refactor of InboxPanel component
The methods getUnreadNotesCount and hasValidNotes were separated from the InboxPanel component
# Conflicts:
# client/header/activity-panel/panels/inbox/index.js
* Refactor inbox panel subtitle classes
* Added changes for when a note is undismissed
This commit adds the requested changes in behavior and design for when a note is dismissed.
# Conflicts:
# client/header/activity-panel/panels/inbox/index.js
* Bugfix: Added key to itemlist
The InboxNotePlaceholder is shown as an itemlist but it didn't have a key. This commit adds it.
* Removed unnecessary validation
* Refactored actionList map
This commit adds a refactor to the actionList map
* Changes to the getUndoDismissRequesting functionality
This commit adds a few changes to the getUndoDismissRequesting functionality
* Changed className prop
* Changed other className prop
* Modified InboxPanel rendering
* Removed unnecessary method in placeholder.js
* Simplified the card.js renderActions method
* Change renderActions return in card.js
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
* Inbox notification: add client unit tests (https://github.com/woocommerce/woocommerce-admin/pull/4386)
* Added client unit tests
* Added test cases for getUnreadNotesCount and hasValidNotes
* Corrected typo error
* Removed Enzyme and added React Testing Library
* Removed unnecessary param
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
* Resolved some conflicts with master
* Marketing note test repaired
This commit repairs the marketing note test
* Added note type 'marketing' to delete all functionality
* Removed set_icon method from some notes and docs
* Added set_icon method as deprecated to prevent errors.
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
2020-06-03 11:43:35 +00:00
|
|
|
/**
|
|
|
|
* Get note layout (the old notes won't have one).
|
|
|
|
*
|
|
|
|
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function get_layout( $context = 'view' ) {
|
|
|
|
return $this->get_prop( 'layout', $context );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get note image (if any).
|
|
|
|
*
|
|
|
|
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function get_image( $context = 'view' ) {
|
|
|
|
return $this->get_prop( 'image', $context );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get deleted status.
|
|
|
|
*
|
|
|
|
* @param string $context What the value is for. Valid values are 'view' and 'edit'.
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function get_is_deleted( $context = 'view' ) {
|
|
|
|
return $this->get_prop( 'is_deleted', $context );
|
|
|
|
}
|
|
|
|
|
2018-09-21 23:44:04 +00:00
|
|
|
/*
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
| Setters
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
| Methods for setting note data. These should not update anything in the
|
|
|
|
| database itself and should only change what is stored in the class
|
|
|
|
| object.
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set note name.
|
|
|
|
*
|
|
|
|
* @param string $name Note name.
|
|
|
|
*/
|
|
|
|
public function set_name( $name ) {
|
2018-09-26 23:35:01 +00:00
|
|
|
// Don't allow empty names.
|
2018-09-25 00:09:39 +00:00
|
|
|
if ( empty( $name ) ) {
|
2019-03-13 17:14:02 +00:00
|
|
|
$this->error( 'admin_note_invalid_data', __( 'The admin note name prop cannot be empty.', 'woocommerce-admin' ) );
|
2018-09-25 00:09:39 +00:00
|
|
|
}
|
|
|
|
|
2018-09-21 23:44:04 +00:00
|
|
|
$this->set_prop( 'name', $name );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set note type.
|
|
|
|
*
|
|
|
|
* @param string $type Note type.
|
|
|
|
*/
|
|
|
|
public function set_type( $type ) {
|
2018-09-25 00:09:39 +00:00
|
|
|
if ( empty( $type ) ) {
|
2019-03-13 17:14:02 +00:00
|
|
|
$this->error( 'admin_note_invalid_data', __( 'The admin note type prop cannot be empty.', 'woocommerce-admin' ) );
|
2018-09-25 00:09:39 +00:00
|
|
|
}
|
|
|
|
|
2018-10-12 20:04:23 +00:00
|
|
|
if ( ! in_array( $type, self::get_allowed_types(), true ) ) {
|
2018-09-25 00:09:39 +00:00
|
|
|
$this->error(
|
|
|
|
'admin_note_invalid_data',
|
|
|
|
sprintf(
|
2018-09-26 23:35:01 +00:00
|
|
|
/* translators: %s: admin note type. */
|
2019-03-13 17:14:02 +00:00
|
|
|
__( 'The admin note type prop (%s) is not one of the supported types.', 'woocommerce-admin' ),
|
2018-09-25 00:09:39 +00:00
|
|
|
$type
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-09-21 23:44:04 +00:00
|
|
|
$this->set_prop( 'type', $type );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set note locale.
|
|
|
|
*
|
|
|
|
* @param string $locale Note locale.
|
|
|
|
*/
|
|
|
|
public function set_locale( $locale ) {
|
2018-09-25 00:09:39 +00:00
|
|
|
if ( empty( $locale ) ) {
|
2019-03-13 17:14:02 +00:00
|
|
|
$this->error( 'admin_note_invalid_data', __( 'The admin note locale prop cannot be empty.', 'woocommerce-admin' ) );
|
2018-09-25 00:09:39 +00:00
|
|
|
}
|
|
|
|
|
2018-09-21 23:44:04 +00:00
|
|
|
$this->set_prop( 'locale', $locale );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set note title.
|
|
|
|
*
|
|
|
|
* @param string $title Note title.
|
|
|
|
*/
|
|
|
|
public function set_title( $title ) {
|
2018-09-25 00:09:39 +00:00
|
|
|
if ( empty( $title ) ) {
|
2019-03-13 17:14:02 +00:00
|
|
|
$this->error( 'admin_note_invalid_data', __( 'The admin note title prop cannot be empty.', 'woocommerce-admin' ) );
|
2018-09-25 00:09:39 +00:00
|
|
|
}
|
|
|
|
|
2018-09-21 23:44:04 +00:00
|
|
|
$this->set_prop( 'title', $title );
|
|
|
|
}
|
|
|
|
|
Inbox notification: layout changes (https://github.com/woocommerce/woocommerce-admin/pull/4218)
* Inbox notification: Added layout changes (https://github.com/woocommerce/woocommerce-admin/pull/4256)
* Added notes layout and image to the API
Added note layout and note image to the API and the DB
* Unit test modified
Unit test where modified to adapt them to the new elements
* Changed the frontend following the new designs.
The fronted was changed to follow the new inbox messages design.
* Changed default layout type in DB
* Added all the requested visual element
Changed the cards' js, css and actions to achieve the visual requirements
* Added "layout" and "image" to inboxQuery
* Modal confirmation buttons repaired
* Added "layout" and "image" to docs examples.
* Removed "updateNote" from action.js
Removed "updateNote" from action.js, I left it by mistake.
* Spelling error corrected
The button text "Dismiss all message" was corrected
* noteName removed and icon added to make code reviewing easier
This commit removes the "noteName" from card.js and adds the icon to make code reviewing easier
* Dismiss action button refactor
Refactor of the dismiss action button in the InboxNoteCard class
* Removed unnecessary control
* Destructured all the note properties
* Colors replaced by existing variable
* Removed setting of layout and image in the creation of the notes
* Removed blank lines added by mistake
* Close dismiss dropdown when clicking away from the popover.
* Prevented the closing of the inbox panel with an action in the modal
* Added small design changes
* Removed unused "Gridicon" import
* Prevent showing the image tag when the layout is blank
* The method name getDismissButton was changed to getDismissConfirmationButton
* Removed unnecessary vendor-prefixed properties
* Improved note filtering in unreadNotes method
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Inbox notification: Remove icons (https://github.com/woocommerce/woocommerce-admin/pull/4258)
* Info icon removed from inbox notifications
The info icon was removed from inbox notifications
# Conflicts:
# src/Notes/DataStore.php
* Removed "icon" from inboxQuery
* Tests repeared
Some problems with the unit tests were repaired in this commit
# Conflicts:
# docs/examples/activity-panel-inbox.md
# Conflicts:
# tests/api/admin-notes.php
* Removed icon from card.js
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
* Inbox notification: Add dismiss functionality (https://github.com/woocommerce/woocommerce-admin/pull/4262)
* Added is_deleted param to soft delete
# Conflicts:
# src/API/Notes.php
# src/Install.php
# src/Notes/DataStore.php
# src/Notes/WC_Admin_Note.php
# src/Notes/WC_Admin_Notes.php
# tests/api/admin-notes.php
* Added the Dismiss functionality
# Conflicts:
# client/header/activity-panel/panels/inbox/action.js
* Where clause repeared
* Added Snackbar after action.
* API modified to dismiss notes
* Small refactor in "get_item" method
This commit adds a small refactor in "get_item" method to use "prepare_note_data_for_response"
* Added missing logic to Dismiss note
This commit adds missing client logic to Dismiss note.
# Conflicts:
# client/header/activity-panel/panels/inbox/action.js
# client/header/activity-panel/panels/inbox/card.js
* Moved the delete action to WC_Admin_Notes.php
The delete action was moved to WC_Admin_Notes.php to follow the pattern.
* Added changes to dismiss messages
This commit addeds changes to the messages soft delete.
* DataStore.php repaired
This commits adds some code that was deleted by mistake and the param "is_deleted" has been escaped.
* Spelling error corrected
The button text "Dismiss all message" was corrected
* Repaired "get_notes_where_clauses" method
A problem with the deleted notes was repaired
* Added a comment to DataStore.php
* Stopped sending the "dismissType" to action.js
The "dismissType" is not sent to action.js anymore.
* Bugfix: now the method get_notes_with_name also returns deleted notes
* Bugfix: repaired empty notification list
This commit repairs a bug that happens when there isn't anything in the inbox notification list
* Small refactor to not use "some" Lodash method anymore
* Small refactor in rednderNotes method
* Added check to set_layout
* Added small refactor to delete_all_notes method
* Fixed code comment error
* Bugfix: repaired the "delete_note" call
* Inbox notification: Added layout changes (https://github.com/woocommerce/woocommerce-admin/pull/4256)
* Added notes layout and image to the API
Added note layout and note image to the API and the DB
* Unit test modified
Unit test where modified to adapt them to the new elements
* Changed the frontend following the new designs.
The fronted was changed to follow the new inbox messages design.
* Changed default layout type in DB
* Added all the requested visual element
Changed the cards' js, css and actions to achieve the visual requirements
* Added "layout" and "image" to inboxQuery
* Modal confirmation buttons repaired
* Added "layout" and "image" to docs examples.
* Removed "updateNote" from action.js
Removed "updateNote" from action.js, I left it by mistake.
* Spelling error corrected
The button text "Dismiss all message" was corrected
* noteName removed and icon added to make code reviewing easier
This commit removes the "noteName" from card.js and adds the icon to make code reviewing easier
* Dismiss action button refactor
Refactor of the dismiss action button in the InboxNoteCard class
* Removed unnecessary control
* Destructured all the note properties
* Colors replaced by existing variable
* Removed setting of layout and image in the creation of the notes
* Removed blank lines added by mistake
* Close dismiss dropdown when clicking away from the popover.
* Prevented the closing of the inbox panel with an action in the modal
* Added small design changes
* Removed unused "Gridicon" import
* Prevent showing the image tag when the layout is blank
* The method name getDismissButton was changed to getDismissConfirmationButton
* Removed unnecessary vendor-prefixed properties
* Improved note filtering in unreadNotes method
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Inbox notification: Remove icons (https://github.com/woocommerce/woocommerce-admin/pull/4258)
* Info icon removed from inbox notifications
The info icon was removed from inbox notifications
# Conflicts:
# src/Notes/DataStore.php
* Removed "icon" from inboxQuery
* Tests repeared
Some problems with the unit tests were repaired in this commit
# Conflicts:
# docs/examples/activity-panel-inbox.md
# Conflicts:
# tests/api/admin-notes.php
* Removed icon from card.js
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
* Improved error handling for the set_layout method
* Bugfix: fixed error handling clicks inside dropdowns
* Bugfix: repaired dropdown onBlur handler
This commit repairs a weird behavior that the dropdown onBlur handler method had sometimes.
* Text error changed
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Inbox notification: Add undo snackbar button after deletion (https://github.com/woocommerce/woocommerce-admin/pull/4281)
* Added undo snakbar button for a single note
# Conflicts:
# client/wc-api/notes/mutations.js
# src/Notes/DataStore.php
# src/Notes/WC_Admin_Notes.php
* Added a button to undo the deletion of all notes
# Conflicts:
# client/wc-api/notes/operations.js
# src/API/Notes.php
* Code adapted to make code reviewing easier
There was some code that also was present in another PR, that code was removed to make code reviewing easier.
* UnitTest added
This commit adds some unit tests
* Added verification for API response
* Added casting to $note_id
* Inbox notification: Added layout changes (https://github.com/woocommerce/woocommerce-admin/pull/4256)
* Added notes layout and image to the API
Added note layout and note image to the API and the DB
* Unit test modified
Unit test where modified to adapt them to the new elements
* Changed the frontend following the new designs.
The fronted was changed to follow the new inbox messages design.
* Changed default layout type in DB
* Added all the requested visual element
Changed the cards' js, css and actions to achieve the visual requirements
* Added "layout" and "image" to inboxQuery
* Modal confirmation buttons repaired
* Added "layout" and "image" to docs examples.
* Removed "updateNote" from action.js
Removed "updateNote" from action.js, I left it by mistake.
* Spelling error corrected
The button text "Dismiss all message" was corrected
* noteName removed and icon added to make code reviewing easier
This commit removes the "noteName" from card.js and adds the icon to make code reviewing easier
* Dismiss action button refactor
Refactor of the dismiss action button in the InboxNoteCard class
* Removed unnecessary control
* Destructured all the note properties
* Colors replaced by existing variable
* Removed setting of layout and image in the creation of the notes
* Removed blank lines added by mistake
* Close dismiss dropdown when clicking away from the popover.
* Prevented the closing of the inbox panel with an action in the modal
* Added small design changes
* Removed unused "Gridicon" import
* Prevent showing the image tag when the layout is blank
* The method name getDismissButton was changed to getDismissConfirmationButton
* Removed unnecessary vendor-prefixed properties
* Improved note filtering in unreadNotes method
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Inbox notification: Remove icons (https://github.com/woocommerce/woocommerce-admin/pull/4258)
* Info icon removed from inbox notifications
The info icon was removed from inbox notifications
# Conflicts:
# src/Notes/DataStore.php
* Removed "icon" from inboxQuery
* Tests repeared
Some problems with the unit tests were repaired in this commit
# Conflicts:
# docs/examples/activity-panel-inbox.md
# Conflicts:
# tests/api/admin-notes.php
* Removed icon from card.js
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
* Inbox notification: Add dismiss functionality (https://github.com/woocommerce/woocommerce-admin/pull/4262)
* Added is_deleted param to soft delete
# Conflicts:
# src/API/Notes.php
# src/Install.php
# src/Notes/DataStore.php
# src/Notes/WC_Admin_Note.php
# src/Notes/WC_Admin_Notes.php
# tests/api/admin-notes.php
* Added the Dismiss functionality
# Conflicts:
# client/header/activity-panel/panels/inbox/action.js
* Where clause repeared
* Added Snackbar after action.
* API modified to dismiss notes
* Small refactor in "get_item" method
This commit adds a small refactor in "get_item" method to use "prepare_note_data_for_response"
* Added missing logic to Dismiss note
This commit adds missing client logic to Dismiss note.
# Conflicts:
# client/header/activity-panel/panels/inbox/action.js
# client/header/activity-panel/panels/inbox/card.js
* Moved the delete action to WC_Admin_Notes.php
The delete action was moved to WC_Admin_Notes.php to follow the pattern.
* Added changes to dismiss messages
This commit addeds changes to the messages soft delete.
* DataStore.php repaired
This commits adds some code that was deleted by mistake and the param "is_deleted" has been escaped.
* Spelling error corrected
The button text "Dismiss all message" was corrected
* Repaired "get_notes_where_clauses" method
A problem with the deleted notes was repaired
* Added a comment to DataStore.php
* Stopped sending the "dismissType" to action.js
The "dismissType" is not sent to action.js anymore.
* Bugfix: now the method get_notes_with_name also returns deleted notes
* Bugfix: repaired empty notification list
This commit repairs a bug that happens when there isn't anything in the inbox notification list
* Small refactor to not use "some" Lodash method anymore
* Small refactor in rednderNotes method
* Added check to set_layout
* Added small refactor to delete_all_notes method
* Fixed code comment error
* Bugfix: repaired the "delete_note" call
* Inbox notification: Added layout changes (https://github.com/woocommerce/woocommerce-admin/pull/4256)
* Added notes layout and image to the API
Added note layout and note image to the API and the DB
* Unit test modified
Unit test where modified to adapt them to the new elements
* Changed the frontend following the new designs.
The fronted was changed to follow the new inbox messages design.
* Changed default layout type in DB
* Added all the requested visual element
Changed the cards' js, css and actions to achieve the visual requirements
* Added "layout" and "image" to inboxQuery
* Modal confirmation buttons repaired
* Added "layout" and "image" to docs examples.
* Removed "updateNote" from action.js
Removed "updateNote" from action.js, I left it by mistake.
* Spelling error corrected
The button text "Dismiss all message" was corrected
* noteName removed and icon added to make code reviewing easier
This commit removes the "noteName" from card.js and adds the icon to make code reviewing easier
* Dismiss action button refactor
Refactor of the dismiss action button in the InboxNoteCard class
* Removed unnecessary control
* Destructured all the note properties
* Colors replaced by existing variable
* Removed setting of layout and image in the creation of the notes
* Removed blank lines added by mistake
* Close dismiss dropdown when clicking away from the popover.
* Prevented the closing of the inbox panel with an action in the modal
* Added small design changes
* Removed unused "Gridicon" import
* Prevent showing the image tag when the layout is blank
* The method name getDismissButton was changed to getDismissConfirmationButton
* Removed unnecessary vendor-prefixed properties
* Improved note filtering in unreadNotes method
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Inbox notification: Remove icons (https://github.com/woocommerce/woocommerce-admin/pull/4258)
* Info icon removed from inbox notifications
The info icon was removed from inbox notifications
# Conflicts:
# src/Notes/DataStore.php
* Removed "icon" from inboxQuery
* Tests repeared
Some problems with the unit tests were repaired in this commit
# Conflicts:
# docs/examples/activity-panel-inbox.md
# Conflicts:
# tests/api/admin-notes.php
* Removed icon from card.js
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
* Improved error handling for the set_layout method
* Bugfix: fixed error handling clicks inside dropdowns
* Bugfix: repaired dropdown onBlur handler
This commit repairs a weird behavior that the dropdown onBlur handler method had sometimes.
* Text error changed
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Stopped sending the "dismissType" to action.js
The "dismissType" is not sent to action.js anymore.
# Conflicts:
# client/header/activity-panel/panels/inbox/card.js
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Bugfix: solved problem when a note was undismissed
There was a problem with the undismiss functionality. When a note was undismissed, it always was recovered with "plain" layout. This commit solves this problem.
* Inbox notification: add event recording (https://github.com/woocommerce/woocommerce-admin/pull/4320)
* Added events recording
This commit adds events recording to the inbox notifications
# Conflicts:
# client/header/activity-panel/panels/inbox/index.js
* Added 'home_screen' verification
Changed recorded name, now when the client is in the WooCommerce 'home' page we record 'home_screen' instead of 'wc-admin'.
* Added a naming fix and a new prop to the recordEvent
* bugfix: added control before interaction with bodyNotificationRef
* Added more unit tests for new endpoints
This commit adds tests for deleting a single note and for deleting all the notes, both without permission.
* Modified variable name
* Refactor: prop rename and small logic change
* Screen name getter moved into the InboxNoteCard
This commit moves the screen name getter inside the InboxNoteCard.
# Conflicts:
# client/header/activity-panel/panels/inbox/index.js
* Removed "screen" from state
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
* Refactor in admin-notes unit tests
Some unnecessary controls were removed from the admin-notes unit tests
* Indentation fixed in Install.php. Replaced spaces with tabs.
* Inbox notification: added new placeholder and empty card (https://github.com/woocommerce/woocommerce-admin/pull/4379)
* Added a new placeholder and an empty card
This commit adds a new placeholder and a new empty card to the inbox panel
# Conflicts:
# client/header/activity-panel/panels/inbox/index.js
# client/header/activity-panel/panels/inbox/style.scss
* Added border to read notes
* Improved note filtering in unreadNotes method and validNotes
# Conflicts:
# client/header/activity-panel/panels/inbox/index.js
* Actions render refactored
The actions render was refactored in InboxNoteCard component
* Refactor of InboxPanel component
The methods getUnreadNotesCount and hasValidNotes were separated from the InboxPanel component
# Conflicts:
# client/header/activity-panel/panels/inbox/index.js
* Refactor inbox panel subtitle classes
* Added changes for when a note is undismissed
This commit adds the requested changes in behavior and design for when a note is dismissed.
# Conflicts:
# client/header/activity-panel/panels/inbox/index.js
* Bugfix: Added key to itemlist
The InboxNotePlaceholder is shown as an itemlist but it didn't have a key. This commit adds it.
* Removed unnecessary validation
* Refactored actionList map
This commit adds a refactor to the actionList map
* Changes to the getUndoDismissRequesting functionality
This commit adds a few changes to the getUndoDismissRequesting functionality
* Changed className prop
* Changed other className prop
* Modified InboxPanel rendering
* Removed unnecessary method in placeholder.js
* Simplified the card.js renderActions method
* Change renderActions return in card.js
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
* Inbox notification: add client unit tests (https://github.com/woocommerce/woocommerce-admin/pull/4386)
* Added client unit tests
* Added test cases for getUnreadNotesCount and hasValidNotes
* Corrected typo error
* Removed Enzyme and added React Testing Library
* Removed unnecessary param
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
* Resolved some conflicts with master
* Marketing note test repaired
This commit repairs the marketing note test
* Added note type 'marketing' to delete all functionality
* Removed set_icon method from some notes and docs
* Added set_icon method as deprecated to prevent errors.
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
2020-06-03 11:43:35 +00:00
|
|
|
/**
|
|
|
|
* Set note icon (Deprecated).
|
|
|
|
*
|
|
|
|
* @param string $icon Note icon.
|
|
|
|
*/
|
|
|
|
public function set_icon( $icon ) {
|
|
|
|
wc_deprecated_function( 'set_icon', '4.3' );
|
|
|
|
}
|
|
|
|
|
2018-09-21 23:44:04 +00:00
|
|
|
/**
|
|
|
|
* Set note content.
|
|
|
|
*
|
|
|
|
* @param string $content Note content.
|
|
|
|
*/
|
|
|
|
public function set_content( $content ) {
|
2018-09-26 17:38:25 +00:00
|
|
|
$allowed_html = array(
|
2018-09-26 23:35:01 +00:00
|
|
|
'br' => array(),
|
|
|
|
'em' => array(),
|
2018-09-26 17:38:25 +00:00
|
|
|
'strong' => array(),
|
2019-05-21 19:34:33 +00:00
|
|
|
'a' => array(
|
|
|
|
'href' => true,
|
|
|
|
'rel' => true,
|
|
|
|
'name' => true,
|
|
|
|
'target' => true,
|
|
|
|
'download' => array(
|
|
|
|
'valueless' => 'y',
|
|
|
|
),
|
|
|
|
),
|
2019-05-29 22:28:37 +00:00
|
|
|
'p' => array(),
|
2018-09-26 17:38:25 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
$content = wp_kses( $content, $allowed_html );
|
|
|
|
|
2018-09-25 00:09:39 +00:00
|
|
|
if ( empty( $content ) ) {
|
2019-03-13 17:14:02 +00:00
|
|
|
$this->error( 'admin_note_invalid_data', __( 'The admin note content prop cannot be empty.', 'woocommerce-admin' ) );
|
2018-09-25 00:09:39 +00:00
|
|
|
}
|
|
|
|
|
2018-09-21 23:44:04 +00:00
|
|
|
$this->set_prop( 'content', $content );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set note data for potential re-localization.
|
|
|
|
*
|
2019-03-13 17:14:02 +00:00
|
|
|
* @todo Set a default empty array? https://github.com/woocommerce/woocommerce-admin/pull/1763#pullrequestreview-212442921.
|
2018-09-26 23:35:01 +00:00
|
|
|
* @param object $content_data Note data.
|
2018-09-21 23:44:04 +00:00
|
|
|
*/
|
|
|
|
public function set_content_data( $content_data ) {
|
2018-09-25 00:09:39 +00:00
|
|
|
$allowed_type = false;
|
|
|
|
|
2018-09-26 23:35:01 +00:00
|
|
|
// Make sure $content_data is stdClass Object or an array.
|
2019-07-31 19:47:32 +00:00
|
|
|
if ( ! ( $content_data instanceof \stdClass ) ) {
|
2019-03-13 17:14:02 +00:00
|
|
|
$this->error( 'admin_note_invalid_data', __( 'The admin note content_data prop must be an instance of stdClass.', 'woocommerce-admin' ) );
|
2018-09-21 23:44:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$this->set_prop( 'content_data', $content_data );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set note status.
|
|
|
|
*
|
|
|
|
* @param string $status Note status.
|
|
|
|
*/
|
|
|
|
public function set_status( $status ) {
|
2018-09-25 00:09:39 +00:00
|
|
|
if ( empty( $status ) ) {
|
2019-03-13 17:14:02 +00:00
|
|
|
$this->error( 'admin_note_invalid_data', __( 'The admin note status prop cannot be empty.', 'woocommerce-admin' ) );
|
2018-09-25 00:09:39 +00:00
|
|
|
}
|
|
|
|
|
2018-10-12 20:04:23 +00:00
|
|
|
if ( ! in_array( $status, self::get_allowed_statuses(), true ) ) {
|
2018-09-25 00:09:39 +00:00
|
|
|
$this->error(
|
|
|
|
'admin_note_invalid_data',
|
|
|
|
sprintf(
|
2018-09-26 23:35:01 +00:00
|
|
|
/* translators: %s: admin note status property. */
|
2019-03-13 17:14:02 +00:00
|
|
|
__( 'The admin note status prop (%s) is not one of the supported statuses.', 'woocommerce-admin' ),
|
2018-09-25 00:09:39 +00:00
|
|
|
$status
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-09-21 23:44:04 +00:00
|
|
|
$this->set_prop( 'status', $status );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set note source.
|
|
|
|
*
|
|
|
|
* @param string $source Note source.
|
|
|
|
*/
|
|
|
|
public function set_source( $source ) {
|
2018-09-25 00:09:39 +00:00
|
|
|
if ( empty( $source ) ) {
|
2019-03-13 17:14:02 +00:00
|
|
|
$this->error( 'admin_note_invalid_data', __( 'The admin note source prop cannot be empty.', 'woocommerce-admin' ) );
|
2018-09-25 00:09:39 +00:00
|
|
|
}
|
|
|
|
|
2018-09-21 23:44:04 +00:00
|
|
|
$this->set_prop( 'source', $source );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set date note was created. NULL is not allowed
|
|
|
|
*
|
|
|
|
* @param string|integer $date UTC timestamp, or ISO 8601 DateTime. If the DateTime string has no timezone or offset, WordPress site timezone will be assumed.
|
|
|
|
*/
|
|
|
|
public function set_date_created( $date ) {
|
2018-09-25 00:09:39 +00:00
|
|
|
if ( empty( $date ) ) {
|
2019-03-13 17:14:02 +00:00
|
|
|
$this->error( 'admin_note_invalid_data', __( 'The admin note date prop cannot be empty.', 'woocommerce-admin' ) );
|
2018-09-25 00:09:39 +00:00
|
|
|
}
|
|
|
|
|
2018-09-21 23:44:04 +00:00
|
|
|
$this->set_date_prop( 'date_created', $date );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set date admin should be reminded of note. NULL IS allowed
|
|
|
|
*
|
|
|
|
* @param string|integer|null $date UTC timestamp, or ISO 8601 DateTime. If the DateTime string has no timezone or offset, WordPress site timezone will be assumed. Null if there is no date.
|
|
|
|
*/
|
|
|
|
public function set_date_reminder( $date ) {
|
|
|
|
$this->set_date_prop( 'date_reminder', $date );
|
|
|
|
}
|
|
|
|
|
2019-03-16 00:43:06 +00:00
|
|
|
/**
|
|
|
|
* Set note snoozability.
|
|
|
|
*
|
|
|
|
* @param bool $is_snoozable Whether or not the note can be snoozed.
|
|
|
|
*/
|
|
|
|
public function set_is_snoozable( $is_snoozable ) {
|
|
|
|
return $this->set_prop( 'is_snoozable', $is_snoozable );
|
|
|
|
}
|
|
|
|
|
2018-10-26 22:07:59 +00:00
|
|
|
/**
|
|
|
|
* Clear actions from a note.
|
|
|
|
*/
|
|
|
|
public function clear_actions() {
|
|
|
|
$this->set_prop( 'actions', array() );
|
|
|
|
}
|
|
|
|
|
Inbox notification: layout changes (https://github.com/woocommerce/woocommerce-admin/pull/4218)
* Inbox notification: Added layout changes (https://github.com/woocommerce/woocommerce-admin/pull/4256)
* Added notes layout and image to the API
Added note layout and note image to the API and the DB
* Unit test modified
Unit test where modified to adapt them to the new elements
* Changed the frontend following the new designs.
The fronted was changed to follow the new inbox messages design.
* Changed default layout type in DB
* Added all the requested visual element
Changed the cards' js, css and actions to achieve the visual requirements
* Added "layout" and "image" to inboxQuery
* Modal confirmation buttons repaired
* Added "layout" and "image" to docs examples.
* Removed "updateNote" from action.js
Removed "updateNote" from action.js, I left it by mistake.
* Spelling error corrected
The button text "Dismiss all message" was corrected
* noteName removed and icon added to make code reviewing easier
This commit removes the "noteName" from card.js and adds the icon to make code reviewing easier
* Dismiss action button refactor
Refactor of the dismiss action button in the InboxNoteCard class
* Removed unnecessary control
* Destructured all the note properties
* Colors replaced by existing variable
* Removed setting of layout and image in the creation of the notes
* Removed blank lines added by mistake
* Close dismiss dropdown when clicking away from the popover.
* Prevented the closing of the inbox panel with an action in the modal
* Added small design changes
* Removed unused "Gridicon" import
* Prevent showing the image tag when the layout is blank
* The method name getDismissButton was changed to getDismissConfirmationButton
* Removed unnecessary vendor-prefixed properties
* Improved note filtering in unreadNotes method
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Inbox notification: Remove icons (https://github.com/woocommerce/woocommerce-admin/pull/4258)
* Info icon removed from inbox notifications
The info icon was removed from inbox notifications
# Conflicts:
# src/Notes/DataStore.php
* Removed "icon" from inboxQuery
* Tests repeared
Some problems with the unit tests were repaired in this commit
# Conflicts:
# docs/examples/activity-panel-inbox.md
# Conflicts:
# tests/api/admin-notes.php
* Removed icon from card.js
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
* Inbox notification: Add dismiss functionality (https://github.com/woocommerce/woocommerce-admin/pull/4262)
* Added is_deleted param to soft delete
# Conflicts:
# src/API/Notes.php
# src/Install.php
# src/Notes/DataStore.php
# src/Notes/WC_Admin_Note.php
# src/Notes/WC_Admin_Notes.php
# tests/api/admin-notes.php
* Added the Dismiss functionality
# Conflicts:
# client/header/activity-panel/panels/inbox/action.js
* Where clause repeared
* Added Snackbar after action.
* API modified to dismiss notes
* Small refactor in "get_item" method
This commit adds a small refactor in "get_item" method to use "prepare_note_data_for_response"
* Added missing logic to Dismiss note
This commit adds missing client logic to Dismiss note.
# Conflicts:
# client/header/activity-panel/panels/inbox/action.js
# client/header/activity-panel/panels/inbox/card.js
* Moved the delete action to WC_Admin_Notes.php
The delete action was moved to WC_Admin_Notes.php to follow the pattern.
* Added changes to dismiss messages
This commit addeds changes to the messages soft delete.
* DataStore.php repaired
This commits adds some code that was deleted by mistake and the param "is_deleted" has been escaped.
* Spelling error corrected
The button text "Dismiss all message" was corrected
* Repaired "get_notes_where_clauses" method
A problem with the deleted notes was repaired
* Added a comment to DataStore.php
* Stopped sending the "dismissType" to action.js
The "dismissType" is not sent to action.js anymore.
* Bugfix: now the method get_notes_with_name also returns deleted notes
* Bugfix: repaired empty notification list
This commit repairs a bug that happens when there isn't anything in the inbox notification list
* Small refactor to not use "some" Lodash method anymore
* Small refactor in rednderNotes method
* Added check to set_layout
* Added small refactor to delete_all_notes method
* Fixed code comment error
* Bugfix: repaired the "delete_note" call
* Inbox notification: Added layout changes (https://github.com/woocommerce/woocommerce-admin/pull/4256)
* Added notes layout and image to the API
Added note layout and note image to the API and the DB
* Unit test modified
Unit test where modified to adapt them to the new elements
* Changed the frontend following the new designs.
The fronted was changed to follow the new inbox messages design.
* Changed default layout type in DB
* Added all the requested visual element
Changed the cards' js, css and actions to achieve the visual requirements
* Added "layout" and "image" to inboxQuery
* Modal confirmation buttons repaired
* Added "layout" and "image" to docs examples.
* Removed "updateNote" from action.js
Removed "updateNote" from action.js, I left it by mistake.
* Spelling error corrected
The button text "Dismiss all message" was corrected
* noteName removed and icon added to make code reviewing easier
This commit removes the "noteName" from card.js and adds the icon to make code reviewing easier
* Dismiss action button refactor
Refactor of the dismiss action button in the InboxNoteCard class
* Removed unnecessary control
* Destructured all the note properties
* Colors replaced by existing variable
* Removed setting of layout and image in the creation of the notes
* Removed blank lines added by mistake
* Close dismiss dropdown when clicking away from the popover.
* Prevented the closing of the inbox panel with an action in the modal
* Added small design changes
* Removed unused "Gridicon" import
* Prevent showing the image tag when the layout is blank
* The method name getDismissButton was changed to getDismissConfirmationButton
* Removed unnecessary vendor-prefixed properties
* Improved note filtering in unreadNotes method
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Inbox notification: Remove icons (https://github.com/woocommerce/woocommerce-admin/pull/4258)
* Info icon removed from inbox notifications
The info icon was removed from inbox notifications
# Conflicts:
# src/Notes/DataStore.php
* Removed "icon" from inboxQuery
* Tests repeared
Some problems with the unit tests were repaired in this commit
# Conflicts:
# docs/examples/activity-panel-inbox.md
# Conflicts:
# tests/api/admin-notes.php
* Removed icon from card.js
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
* Improved error handling for the set_layout method
* Bugfix: fixed error handling clicks inside dropdowns
* Bugfix: repaired dropdown onBlur handler
This commit repairs a weird behavior that the dropdown onBlur handler method had sometimes.
* Text error changed
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Inbox notification: Add undo snackbar button after deletion (https://github.com/woocommerce/woocommerce-admin/pull/4281)
* Added undo snakbar button for a single note
# Conflicts:
# client/wc-api/notes/mutations.js
# src/Notes/DataStore.php
# src/Notes/WC_Admin_Notes.php
* Added a button to undo the deletion of all notes
# Conflicts:
# client/wc-api/notes/operations.js
# src/API/Notes.php
* Code adapted to make code reviewing easier
There was some code that also was present in another PR, that code was removed to make code reviewing easier.
* UnitTest added
This commit adds some unit tests
* Added verification for API response
* Added casting to $note_id
* Inbox notification: Added layout changes (https://github.com/woocommerce/woocommerce-admin/pull/4256)
* Added notes layout and image to the API
Added note layout and note image to the API and the DB
* Unit test modified
Unit test where modified to adapt them to the new elements
* Changed the frontend following the new designs.
The fronted was changed to follow the new inbox messages design.
* Changed default layout type in DB
* Added all the requested visual element
Changed the cards' js, css and actions to achieve the visual requirements
* Added "layout" and "image" to inboxQuery
* Modal confirmation buttons repaired
* Added "layout" and "image" to docs examples.
* Removed "updateNote" from action.js
Removed "updateNote" from action.js, I left it by mistake.
* Spelling error corrected
The button text "Dismiss all message" was corrected
* noteName removed and icon added to make code reviewing easier
This commit removes the "noteName" from card.js and adds the icon to make code reviewing easier
* Dismiss action button refactor
Refactor of the dismiss action button in the InboxNoteCard class
* Removed unnecessary control
* Destructured all the note properties
* Colors replaced by existing variable
* Removed setting of layout and image in the creation of the notes
* Removed blank lines added by mistake
* Close dismiss dropdown when clicking away from the popover.
* Prevented the closing of the inbox panel with an action in the modal
* Added small design changes
* Removed unused "Gridicon" import
* Prevent showing the image tag when the layout is blank
* The method name getDismissButton was changed to getDismissConfirmationButton
* Removed unnecessary vendor-prefixed properties
* Improved note filtering in unreadNotes method
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Inbox notification: Remove icons (https://github.com/woocommerce/woocommerce-admin/pull/4258)
* Info icon removed from inbox notifications
The info icon was removed from inbox notifications
# Conflicts:
# src/Notes/DataStore.php
* Removed "icon" from inboxQuery
* Tests repeared
Some problems with the unit tests were repaired in this commit
# Conflicts:
# docs/examples/activity-panel-inbox.md
# Conflicts:
# tests/api/admin-notes.php
* Removed icon from card.js
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
* Inbox notification: Add dismiss functionality (https://github.com/woocommerce/woocommerce-admin/pull/4262)
* Added is_deleted param to soft delete
# Conflicts:
# src/API/Notes.php
# src/Install.php
# src/Notes/DataStore.php
# src/Notes/WC_Admin_Note.php
# src/Notes/WC_Admin_Notes.php
# tests/api/admin-notes.php
* Added the Dismiss functionality
# Conflicts:
# client/header/activity-panel/panels/inbox/action.js
* Where clause repeared
* Added Snackbar after action.
* API modified to dismiss notes
* Small refactor in "get_item" method
This commit adds a small refactor in "get_item" method to use "prepare_note_data_for_response"
* Added missing logic to Dismiss note
This commit adds missing client logic to Dismiss note.
# Conflicts:
# client/header/activity-panel/panels/inbox/action.js
# client/header/activity-panel/panels/inbox/card.js
* Moved the delete action to WC_Admin_Notes.php
The delete action was moved to WC_Admin_Notes.php to follow the pattern.
* Added changes to dismiss messages
This commit addeds changes to the messages soft delete.
* DataStore.php repaired
This commits adds some code that was deleted by mistake and the param "is_deleted" has been escaped.
* Spelling error corrected
The button text "Dismiss all message" was corrected
* Repaired "get_notes_where_clauses" method
A problem with the deleted notes was repaired
* Added a comment to DataStore.php
* Stopped sending the "dismissType" to action.js
The "dismissType" is not sent to action.js anymore.
* Bugfix: now the method get_notes_with_name also returns deleted notes
* Bugfix: repaired empty notification list
This commit repairs a bug that happens when there isn't anything in the inbox notification list
* Small refactor to not use "some" Lodash method anymore
* Small refactor in rednderNotes method
* Added check to set_layout
* Added small refactor to delete_all_notes method
* Fixed code comment error
* Bugfix: repaired the "delete_note" call
* Inbox notification: Added layout changes (https://github.com/woocommerce/woocommerce-admin/pull/4256)
* Added notes layout and image to the API
Added note layout and note image to the API and the DB
* Unit test modified
Unit test where modified to adapt them to the new elements
* Changed the frontend following the new designs.
The fronted was changed to follow the new inbox messages design.
* Changed default layout type in DB
* Added all the requested visual element
Changed the cards' js, css and actions to achieve the visual requirements
* Added "layout" and "image" to inboxQuery
* Modal confirmation buttons repaired
* Added "layout" and "image" to docs examples.
* Removed "updateNote" from action.js
Removed "updateNote" from action.js, I left it by mistake.
* Spelling error corrected
The button text "Dismiss all message" was corrected
* noteName removed and icon added to make code reviewing easier
This commit removes the "noteName" from card.js and adds the icon to make code reviewing easier
* Dismiss action button refactor
Refactor of the dismiss action button in the InboxNoteCard class
* Removed unnecessary control
* Destructured all the note properties
* Colors replaced by existing variable
* Removed setting of layout and image in the creation of the notes
* Removed blank lines added by mistake
* Close dismiss dropdown when clicking away from the popover.
* Prevented the closing of the inbox panel with an action in the modal
* Added small design changes
* Removed unused "Gridicon" import
* Prevent showing the image tag when the layout is blank
* The method name getDismissButton was changed to getDismissConfirmationButton
* Removed unnecessary vendor-prefixed properties
* Improved note filtering in unreadNotes method
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Update client/header/activity-panel/panels/inbox/style.scss
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Inbox notification: Remove icons (https://github.com/woocommerce/woocommerce-admin/pull/4258)
* Info icon removed from inbox notifications
The info icon was removed from inbox notifications
# Conflicts:
# src/Notes/DataStore.php
* Removed "icon" from inboxQuery
* Tests repeared
Some problems with the unit tests were repaired in this commit
# Conflicts:
# docs/examples/activity-panel-inbox.md
# Conflicts:
# tests/api/admin-notes.php
* Removed icon from card.js
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
* Improved error handling for the set_layout method
* Bugfix: fixed error handling clicks inside dropdowns
* Bugfix: repaired dropdown onBlur handler
This commit repairs a weird behavior that the dropdown onBlur handler method had sometimes.
* Text error changed
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Stopped sending the "dismissType" to action.js
The "dismissType" is not sent to action.js anymore.
# Conflicts:
# client/header/activity-panel/panels/inbox/card.js
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
* Bugfix: solved problem when a note was undismissed
There was a problem with the undismiss functionality. When a note was undismissed, it always was recovered with "plain" layout. This commit solves this problem.
* Inbox notification: add event recording (https://github.com/woocommerce/woocommerce-admin/pull/4320)
* Added events recording
This commit adds events recording to the inbox notifications
# Conflicts:
# client/header/activity-panel/panels/inbox/index.js
* Added 'home_screen' verification
Changed recorded name, now when the client is in the WooCommerce 'home' page we record 'home_screen' instead of 'wc-admin'.
* Added a naming fix and a new prop to the recordEvent
* bugfix: added control before interaction with bodyNotificationRef
* Added more unit tests for new endpoints
This commit adds tests for deleting a single note and for deleting all the notes, both without permission.
* Modified variable name
* Refactor: prop rename and small logic change
* Screen name getter moved into the InboxNoteCard
This commit moves the screen name getter inside the InboxNoteCard.
# Conflicts:
# client/header/activity-panel/panels/inbox/index.js
* Removed "screen" from state
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
* Refactor in admin-notes unit tests
Some unnecessary controls were removed from the admin-notes unit tests
* Indentation fixed in Install.php. Replaced spaces with tabs.
* Inbox notification: added new placeholder and empty card (https://github.com/woocommerce/woocommerce-admin/pull/4379)
* Added a new placeholder and an empty card
This commit adds a new placeholder and a new empty card to the inbox panel
# Conflicts:
# client/header/activity-panel/panels/inbox/index.js
# client/header/activity-panel/panels/inbox/style.scss
* Added border to read notes
* Improved note filtering in unreadNotes method and validNotes
# Conflicts:
# client/header/activity-panel/panels/inbox/index.js
* Actions render refactored
The actions render was refactored in InboxNoteCard component
* Refactor of InboxPanel component
The methods getUnreadNotesCount and hasValidNotes were separated from the InboxPanel component
# Conflicts:
# client/header/activity-panel/panels/inbox/index.js
* Refactor inbox panel subtitle classes
* Added changes for when a note is undismissed
This commit adds the requested changes in behavior and design for when a note is dismissed.
# Conflicts:
# client/header/activity-panel/panels/inbox/index.js
* Bugfix: Added key to itemlist
The InboxNotePlaceholder is shown as an itemlist but it didn't have a key. This commit adds it.
* Removed unnecessary validation
* Refactored actionList map
This commit adds a refactor to the actionList map
* Changes to the getUndoDismissRequesting functionality
This commit adds a few changes to the getUndoDismissRequesting functionality
* Changed className prop
* Changed other className prop
* Modified InboxPanel rendering
* Removed unnecessary method in placeholder.js
* Simplified the card.js renderActions method
* Change renderActions return in card.js
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
* Inbox notification: add client unit tests (https://github.com/woocommerce/woocommerce-admin/pull/4386)
* Added client unit tests
* Added test cases for getUnreadNotesCount and hasValidNotes
* Corrected typo error
* Removed Enzyme and added React Testing Library
* Removed unnecessary param
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
* Resolved some conflicts with master
* Marketing note test repaired
This commit repairs the marketing note test
* Added note type 'marketing' to delete all functionality
* Removed set_icon method from some notes and docs
* Added set_icon method as deprecated to prevent errors.
Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
Co-authored-by: Joshua T Flowers <joshuatf@gmail.com>
2020-06-03 11:43:35 +00:00
|
|
|
/**
|
|
|
|
* Set note layout.
|
|
|
|
*
|
|
|
|
* @param string $layout Note layout.
|
|
|
|
*/
|
|
|
|
public function set_layout( $layout ) {
|
|
|
|
// If we don't receive a layout we will set it by default as "plain".
|
|
|
|
if ( empty( $layout ) ) {
|
|
|
|
$layout = 'plain';
|
|
|
|
}
|
|
|
|
$valid_layouts = array( 'banner', 'plain', 'thumbnail' );
|
|
|
|
if ( in_array( $layout, $valid_layouts, true ) ) {
|
|
|
|
$this->set_prop( 'layout', $layout );
|
|
|
|
} else {
|
|
|
|
$this->error( 'admin_note_invalid_data', __( 'The admin note layout has a wrong prop value.', 'woocommerce-admin' ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set note image.
|
|
|
|
*
|
|
|
|
* @param string $image Note image.
|
|
|
|
*/
|
|
|
|
public function set_image( $image ) {
|
|
|
|
$this->set_prop( 'image', $image );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set note deleted status. NULL is not allowed
|
|
|
|
*
|
|
|
|
* @param bool $is_deleted Note deleted status.
|
|
|
|
*/
|
|
|
|
public function set_is_deleted( $is_deleted ) {
|
|
|
|
$this->set_prop( 'is_deleted', $is_deleted );
|
|
|
|
}
|
|
|
|
|
2018-09-21 23:44:04 +00:00
|
|
|
/**
|
|
|
|
* Add an action to the note
|
2018-09-26 23:35:01 +00:00
|
|
|
*
|
2019-05-24 17:05:12 +00:00
|
|
|
* @param string $name Action name (not presented to user).
|
|
|
|
* @param string $label Action label (presented as button label).
|
|
|
|
* @param string $url Action URL, if navigation needed. Optional.
|
|
|
|
* @param string $status Status to transition parent Note to upon click. Defaults to 'actioned'.
|
2019-05-21 19:01:55 +00:00
|
|
|
* @param boolean $primary Whether or not this is the primary action. Defaults to false.
|
|
|
|
*/
|
2019-05-24 17:05:12 +00:00
|
|
|
public function add_action( $name, $label, $url = '', $status = self::E_WC_ADMIN_NOTE_ACTIONED, $primary = false ) {
|
2019-05-21 19:01:55 +00:00
|
|
|
$name = wc_clean( $name );
|
|
|
|
$label = wc_clean( $label );
|
2019-05-24 17:05:12 +00:00
|
|
|
$query = esc_url_raw( $url );
|
2019-05-21 19:01:55 +00:00
|
|
|
$status = wc_clean( $status );
|
|
|
|
$primary = (bool) $primary;
|
2018-09-26 17:38:25 +00:00
|
|
|
|
|
|
|
if ( empty( $name ) ) {
|
2019-03-13 17:14:02 +00:00
|
|
|
$this->error( 'admin_note_invalid_data', __( 'The admin note action name prop cannot be empty.', 'woocommerce-admin' ) );
|
2018-09-26 17:38:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( empty( $label ) ) {
|
2019-03-13 17:14:02 +00:00
|
|
|
$this->error( 'admin_note_invalid_data', __( 'The admin note action label prop cannot be empty.', 'woocommerce-admin' ) );
|
2018-09-26 17:38:25 +00:00
|
|
|
}
|
2018-09-25 00:09:39 +00:00
|
|
|
|
2018-09-26 17:38:25 +00:00
|
|
|
$action = array(
|
2019-05-21 19:01:55 +00:00
|
|
|
'name' => $name,
|
|
|
|
'label' => $label,
|
|
|
|
'query' => $query,
|
|
|
|
'status' => $status,
|
|
|
|
'primary' => $primary,
|
2018-09-26 17:38:25 +00:00
|
|
|
);
|
|
|
|
|
2018-09-26 23:35:01 +00:00
|
|
|
$note_actions = $this->get_prop( 'actions', 'edit' );
|
2018-09-26 17:38:25 +00:00
|
|
|
$note_actions[] = (object) $action;
|
|
|
|
$this->set_prop( 'actions', $note_actions );
|
2018-09-21 23:44:04 +00:00
|
|
|
}
|
2019-05-24 19:20:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set actions on a note.
|
|
|
|
*
|
|
|
|
* @param array $actions Note actions.
|
|
|
|
*/
|
|
|
|
public function set_actions( $actions ) {
|
|
|
|
$this->set_prop( 'actions', $actions );
|
|
|
|
}
|
2018-09-21 23:44:04 +00:00
|
|
|
}
|