Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add promote modal on job save #2522

Merged
merged 13 commits into from
Jul 17, 2023

Conversation

renatho
Copy link
Contributor

@renatho renatho commented Jul 17, 2023

Fixes #2518

Changes proposed in this Pull Request

  • Extract some logic related to the modals, so we can use it in the editor.
  • Display promote modal when a post is changed from any status to publish.
    • It doesn't work with Classic Editor.

Testing instructions

  • Make sure the promote and deactivate modals continue working properly in the job listing.
  • Create a new job, and publish.
  • Make sure it displays a modal to promote the job and it works properly.

Screenshot / Video

Screen.Recording.2023-07-17.at.17.51.21.mov

@renatho renatho self-assigned this Jul 17, 2023
if ( 'edit-job_listing' !== $screen->id ) {
return;

if ( in_array( $screen->id, [ 'edit-job_listing', 'job_listing' ], true ) ) { // Job listing and job editor.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is to also load the promote modal on the job editor page.

@renatho renatho force-pushed the add/promote-modal-on-job-save branch 2 times, most recently from 619ce4a to ac137c0 Compare July 17, 2023 18:06
Base automatically changed from add/fetch-promoted-template to feature/promoted-jobs July 17, 2023 18:25
*
* @return {Function} Unsubscribe function.
*/
const editorLifecycle = ( {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Borrowed from Sensei LMS.

@renatho renatho force-pushed the add/promote-modal-on-job-save branch from 44add0b to 72c04ac Compare July 17, 2023 19:01
@renatho renatho force-pushed the add/promote-modal-on-job-save branch from c18278d to f5866b0 Compare July 17, 2023 19:07
@@ -0,0 +1,49 @@
/**
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic was extracted from the admin.js, so we can use it properly in the editor.

@@ -0,0 +1,21 @@
/**
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was also extracted, just in order to make it a module instead of a global function.

@@ -128,6 +128,21 @@ public function admin_enqueue_scripts() {
);
}

if ( 'job_listing' === $screen->id && $screen->is_block_editor() ) { // Check if it's block editor in job post.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems the standard to include the JS files is here, so I included a JS for the job editor here, including a global variable for the promote URL.

@renatho renatho requested a review from a team July 17, 2023 20:56
@renatho renatho marked this pull request as ready for review July 17, 2023 20:57
Copy link
Member

@jom jom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good and works well.

I also tested some strange WPJM scenarios where it is in draft and I publish with a old expiration date, but it looks like that moves the expiration date forward and continues to publish the job. Deactivate still works well.

@renatho renatho merged commit d275e7e into feature/promoted-jobs Jul 17, 2023
@renatho renatho deleted the add/promote-modal-on-job-save branch July 17, 2023 22:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants