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

Schedule UI for snapshot in customizer #68

Merged
merged 62 commits into from Aug 11, 2016

Conversation

Projects
None yet
4 participants
@PatelUtkarsh
Copy link
Collaborator

commented Jul 28, 2016

No description provided.

@coveralls

This comment has been minimized.

Copy link

commented Jul 28, 2016

Coverage Status

Coverage increased (+0.2%) to 87.585% when pulling 30df6bd on feature/schedule-ui-customizer into 68e8f34 on develop.

@westonruter westonruter referenced this pull request Jul 28, 2016

Merged

Add post date control and preview #202

15 of 17 tasks complete
event.preventDefault();
component.sendUpdateSnapshotRequest( { status: 'draft' } );
if ( $( this ).html() === component.data.i18n.scheduleButton && ! _.isEmpty( component.snapshotScheduleBox ) && component.getDateFromInputs() && component.isScheduleDateFuture() ) {

This comment has been minimized.

Copy link
@westonruter

westonruter Aug 4, 2016

Contributor

$( this ).html() seems dirty. Can't you look at snapshotStatus instead?

This comment has been minimized.

Copy link
@PatelUtkarsh

PatelUtkarsh Aug 4, 2016

Author Collaborator

snapshotStatus can be draft or future we can remove that check as we are checking for the future date on the same condition. And will also add isSnapshotHasUnsavedChanges check.


component.snapshotScheduleBox = {};

component.addSlideDown = function slideDown() {

This comment has been minimized.

Copy link
@westonruter

westonruter Aug 4, 2016

Contributor

Add JSDoc.


};

component.updateSnapshotScheduleBox = function updateSnapshotScheduleBox() {

This comment has been minimized.

Copy link
@westonruter

westonruter Aug 4, 2016

Contributor

Add JSDoc.

@westonruter

This comment has been minimized.

Copy link
Contributor

commented Aug 4, 2016

ESLint errors:

js/customize-snapshots.js: line 212, col 54, Error - 'e' is already declared in the upper scope. (no-shadow)
js/customize-snapshots.js: line 261, col 72, Error - 'component' is already declared in the upper scope. (no-shadow)
js/customize-snapshots.js: line 531, col 62, Error - No magic number: 1. (no-magic-numbers)
js/customize-snapshots.js: line 575, col 55, Error - No magic number: 1. (no-magic-numbers)
js/customize-snapshots.js: line 613, col 39, Error - Expected to return a value at the end of this function. (consistent-return)
js/customize-snapshots.js: line 626, col 6, Error - Blocks are nested too deeply (4). (max-depth)
js/customize-snapshots.js: line 633, col 5, Error - Unexpected if as the only statement in an else block. (no-lonely-if)
js/customize-snapshots.js: line 648, col 2, Error - Missing JSDoc return description. (valid-jsdoc)
js/customize-snapshots.js: line 660, col 46, Error - No magic number: 1000. (no-magic-numbers)
js/customize-snapshots.js: line 691, col 46, Error - No magic number: 1000. (no-magic-numbers)

And phpunit failure:

1) CustomizeSnapshots\Test_Ajax_Customize_Snapshot_Manager::test_ajax_update_snapshot_cap_check with data set #4 ('administrator', array(true, array(null, array(true))))
Failed asserting that Array &0 (
    'success' => true
    'data' => Array &1 (
        'errors' => null
        'setting_validities' => Array &2 (
            'anyonecanedit' => true
        )
        'snapshot_publish_date' => '0000-00-00 00:00:00'
    )
) is identical to Array &0 (
    'success' => true
    'data' => Array &1 (
        'errors' => null
        'setting_validities' => Array &2 (
            'anyonecanedit' => true
        )
    )
).
return false;
}

remainingTime = component.dateValueOf( date );

This comment has been minimized.

Copy link
@westonruter

westonruter Aug 10, 2016

Contributor

Somewhat of a problem here. date is a Date object. However, the component.dateValueOf() function takes a string as its param. It looks like dateValueOf needs to take a Date as its argument as well?

diff --git a/js/customize-snapshots.js b/js/customize-snapshots.js
index 40cf91e..6ecd668 100644
--- a/js/customize-snapshots.js
+++ b/js/customize-snapshots.js
@@ -774,19 +774,21 @@
    /**
     * Get the primitive value of a Date object.
     *
-    * @param {string} dateString The post status for the snapshot.
+    * @param {Date|string} [date] The post status for the snapshot. Defaults to current date.
     * @returns {object|string} The primitive value or date object.
     */
-   component.dateValueOf = function( dateString ) {
-       var date;
+   component.dateValueOf = function( date ) {
+       var dateObj;

-       if ( _.isUndefined( dateString ) ) {
-           date = new Date();
+       if ( _.isUndefined( date ) ) {
+           dateObj = new Date();
+       } else if ( 'string' === typeof date ) {
+           dateObj = new Date( date );
        } else {
-           date = new Date( dateString );
+           dateObj = date;
        }

-       return date.valueOf();
+       return dateObj.valueOf();
    };

    component.init();

This comment has been minimized.

Copy link
@PatelUtkarsh

PatelUtkarsh Aug 10, 2016

Author Collaborator

Fixed dateValueOf function.

// Script data array.
$exports = apply_filters( 'customize_snapshots_export_data', array(
'action' => self::AJAX_ACTION,
'uuid' => $this->snapshot ? $this->snapshot->uuid() : self::generate_uuid(),
'editLink' => $this->snapshot ? get_edit_post_link( $this->snapshot->post(), 'raw' ) : '',
'editLink' => $this->snapshot ? get_edit_post_link( $post, 'raw' ) : '',

This comment has been minimized.

Copy link
@westonruter

westonruter Aug 10, 2016

Contributor

Warning: $post may not have been defined. Above you should do $post = null to initialize, or else we'll get undefined variable warnings.

@westonruter

This comment has been minimized.

Copy link
Contributor

commented Aug 10, 2016

@PatelUtkarsh something is wrong with the time being entered. I change a date and then click Reset and it always is showing for me as 16:25, no matter what the current time is:

date/time

@PatelUtkarsh

This comment has been minimized.

Copy link
Collaborator Author

commented Aug 10, 2016

@westonruter Maybe that is the time when snapshot was saved in DB, reset only reset time to snapshot's publish date if publish date is empty it resets to current date/time,

Should we tweak it like this: if snapshot date is future reset to that date or else reset to current date/time?

@westonruter

This comment has been minimized.

Copy link
Contributor

commented Aug 10, 2016

The (Reset) link should be initially shown if the date is not 0000-00-00 00:00:00? Instead, it is initially hidden:

@westonruter

This comment has been minimized.

Copy link
Contributor

commented Aug 10, 2016

@PatelUtkarsh ah, thanks for that info. OK, it does make sense to me now I think. The reset link is initially hidden because it behaves differently than it does in Customize Posts. Instead of resetting it to NOW it resets it to the original value. I was expecting Reset to undo the scheduling, by setting the date back to 0000-00-00 00:00:00 so that it would un-schedule and make it go live presently.

@coveralls

This comment has been minimized.

Copy link

commented Aug 10, 2016

Coverage Status

Coverage decreased (-0.4%) to 89.133% when pulling ae7189d on feature/schedule-ui-customizer into b53f954 on develop.

@coveralls

This comment has been minimized.

Copy link

commented Aug 10, 2016

Coverage Status

Coverage decreased (-0.4%) to 89.133% when pulling 59a7484 on feature/schedule-ui-customizer into b53f954 on develop.

@westonruter westonruter referenced this pull request Aug 10, 2016

Merged

Snapshot Conflicts #71

@coveralls

This comment has been minimized.

Copy link

commented Aug 11, 2016

Coverage Status

Coverage decreased (-1.0%) to 88.561% when pulling 4ea308b on feature/schedule-ui-customizer into b53f954 on develop.

@westonruter

This comment has been minimized.

Copy link
Contributor

commented Aug 11, 2016

How in the world did the coverage go DOWN when I added MORE tests?!

PatelUtkarsh added some commits Aug 11, 2016

Merge branch 'feature/schedule-ui-customizer' of github.com:xwp/wp-cu…
…stomize-snapshots into feature/schedule-ui-customizer
@coveralls

This comment has been minimized.

Copy link

commented Aug 11, 2016

Coverage Status

Coverage decreased (-1.0%) to 88.561% when pulling 3e5ce8a on feature/schedule-ui-customizer into b53f954 on develop.

@coveralls

This comment has been minimized.

Copy link

commented Aug 11, 2016

Coverage Status

Coverage increased (+1.2%) to 90.753% when pulling 535cbd5 on feature/schedule-ui-customizer into b53f954 on develop.

@valendesigns valendesigns merged commit 0763819 into develop Aug 11, 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

@valendesigns valendesigns deleted the feature/schedule-ui-customizer branch Aug 11, 2016

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.