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

Snapshot merge #92

Merged
merged 14 commits into from Oct 10, 2016

Conversation

Projects
None yet
3 participants
@PatelUtkarsh
Copy link
Collaborator

commented Oct 6, 2016

Fixes #67

} );
foreach ( $posts as $post ) {
$post->post_content = $this->get_post_content( $post );

This comment has been minimized.

Copy link
@westonruter

westonruter Oct 6, 2016

Contributor

I think the data parsed from the post_content should be put into another array instead of stuffed back into $post. So maybe:

$snapshots_data = array();
foreach ( $posts as $post ) {
    $snapshots_data[] = $this->get_post_content( $post );
}

And use $snapshots_data instead of $content.

This comment has been minimized.

Copy link
@PatelUtkarsh

PatelUtkarsh Oct 7, 2016

Author Collaborator

I have changed that, I kept it as such because I thought we will need mapping of post and data. However, I never used that mapping, but now to add uuid in merge_conflcit i will use it,
Creating another array like

$snapshot_post_data = array();
foreach ( $posts as $post ) {
    $snapshot_post_data[] = array(
        'data' => $this->get_post_content( $post ),
        'uuid' => $post->post_name,
    );
}
}
$content = wp_list_pluck( $posts, 'post_content' );
$conflict_keys = call_user_func_array( 'array_intersect_key', $content );
$merge_value = call_user_func_array( 'array_merge', $content );

This comment has been minimized.

Copy link
@westonruter

westonruter Oct 6, 2016

Contributor

Better name than $merge_value would be $merged_snapshot_data.

@@ -115,6 +115,16 @@ public function register() {
add_action( 'admin_notices', array( $this, 'show_publish_error_admin_notice' ) );
add_action( 'post_submitbox_minor_actions', array( $this, 'hide_disabled_publishing_actions' ) );
add_action( 'admin_print_scripts-revision.php', array( $this, 'disable_revision_ui_for_published_posts' ) );
// Version check for bulk action.
if ( version_compare( get_bloginfo( 'version' ), '4.7', '>=' ) ) {

This comment has been minimized.

Copy link
@westonruter

westonruter Oct 6, 2016

Contributor

Nice. Better than using the $wp_version global which I usually use. I'll do this in the future.

$original_values[] = $post->post_content[ $key ];
}
}
array_pop( $original_values );

This comment has been minimized.

Copy link
@westonruter

westonruter Oct 6, 2016

Contributor

Maybe leave the winner in the merge conflict intact?

}
}
array_pop( $original_values );
$merge_value[ $key ]['merge_conflict'] = $original_values;

This comment has been minimized.

Copy link
@westonruter

westonruter Oct 6, 2016

Contributor

Maybe merge_conflict should use the source UUID as they key for each value here? Then we'll be able to look up later which snapshot the value came from.

jQuery('<option>').val('merge_snapshot').text('<?php esc_html_e( 'Merge Snapshot', 'customize-snapshots' ); ?>').appendTo("select[name='action']");
jQuery('<option>').val('merge_snapshot').text('<?php esc_html_e( 'Merge Snapshot', 'customize-snapshots' ); ?>').appendTo("select[name='action2']");
});
</script>

This comment has been minimized.

Copy link
@westonruter

westonruter Oct 6, 2016

Contributor

Indentation problem.

<script type="text/javascript">
jQuery(document).ready(function() {
jQuery('<option>').val('merge_snapshot').text('<?php esc_html_e( 'Merge Snapshot', 'customize-snapshots' ); ?>').appendTo("select[name='action']");
jQuery('<option>').val('merge_snapshot').text('<?php esc_html_e( 'Merge Snapshot', 'customize-snapshots' ); ?>').appendTo("select[name='action2']");

This comment has been minimized.

Copy link
@westonruter

westonruter Oct 6, 2016

Contributor

These lines aren't right. There could be a translation string that has an apostrophe and this would cause a JS error. I suggest refactoring as follows:

jQuery( function( $ ) {
    var optionText = <?php echo wp_json_encode( __( 'Merge Snapshot', 'customize-snapshots' ) ); ?>;
    $( 'select[name="action"], select[name="action2"]' ).each( function() {
        var option = $( '<option>', {
            text: optionText,
            value: 'merge_snapshot'
        } );
        $( this ).append( option );
    } );
} );

This comment has been minimized.

Copy link
@PatelUtkarsh

PatelUtkarsh Oct 7, 2016

Author Collaborator

Super clean 👍 🙇

@coveralls

This comment has been minimized.

Copy link

commented Oct 7, 2016

Coverage Status

Coverage decreased (-1.7%) to 89.326% when pulling 37e3b7b on feature/snapshot-merge into 9625866 on develop.

@coveralls

This comment has been minimized.

Copy link

commented Oct 7, 2016

Coverage Status

Coverage decreased (-0.2%) to 90.814% when pulling 2919e51 on feature/snapshot-merge into 9625866 on develop.

@westonruter

This comment has been minimized.

Copy link
Contributor

commented Oct 7, 2016

@PatelUtkarsh is this still a WIP or is it complete from your perspective?

@PatelUtkarsh

This comment has been minimized.

Copy link
Collaborator Author

commented Oct 9, 2016

@westonruter Resolve Conflict UI part is remaining.

@PatelUtkarsh

This comment has been minimized.

Copy link
Collaborator Author

commented Oct 10, 2016

@westonruter I am working on Resolve Conflict UI on a separate branch so this can be reviewed and merged if you think Resolve Conflict UI is not critical.

@westonruter westonruter changed the title [WIP] Snapshot merge Snapshot merge Oct 10, 2016

@coveralls

This comment has been minimized.

Copy link

commented Oct 10, 2016

Coverage Status

Coverage decreased (-0.2%) to 90.814% when pulling f2cefad on feature/snapshot-merge into 9625866 on develop.

@westonruter westonruter merged commit 59b8b66 into develop Oct 10, 2016

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@westonruter westonruter deleted the feature/snapshot-merge branch Oct 10, 2016

@westonruter westonruter added this to the 0.6.0 milestone Jul 5, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.