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

Editor Media Google Photos: date range filter #25762

Closed
wants to merge 52 commits into from

Commits on Feb 1, 2019

  1. Adds Media Date Range component

    jakejones1984 authored and getdave committed Feb 1, 2019
    Configuration menu
    Copy the full SHA
    e280994 View commit details
    Browse the repository at this point in the history
  2. Fix Date Filters to show only when enabled

    Add both a config feature flag and prop to determine whether to show the Date Filters. Append `?flags=external-media/google-photos/date-filters` to enable the feature for testing
    jakejones1984 authored and getdave committed Feb 1, 2019
    Configuration menu
    Copy the full SHA
    e2f1fe1 View commit details
    Browse the repository at this point in the history
  3. Adds date range selection to Media Date Range

    Updates DatePicker component to allow for usage of selectedDays and to show more than 1 month at a time. MediaDateRange component can now take advantage of this functionality to enable a date-range style picker.
    jakejones1984 authored and getdave committed Feb 1, 2019
    Configuration menu
    Copy the full SHA
    449f765 View commit details
    Browse the repository at this point in the history
  4. Adds support to DatePicker for more React Day Picker library props

    Previously DatePicker component was missing support for toMonth, fromMonth and selectedDays props. This limited ability of consumers of DatePicker component to utilise features of React Day Picker library. Particularly useful if you need to create a range picker.
    
    See http://react-day-picker.js.org/examples/selected-range
    jakejones1984 authored and getdave committed Feb 1, 2019
    Configuration menu
    Copy the full SHA
    02bac1a View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    6dc3565 View commit details
    Browse the repository at this point in the history
  6. Refactor to make component render more readable

    Previously component render was one huge method. Refactored to several smaller utliity methods to make main render more concise.
    jakejones1984 authored and getdave committed Feb 1, 2019
    Configuration menu
    Copy the full SHA
    4111f79 View commit details
    Browse the repository at this point in the history
  7. Add Tests to Media Data Range component

    # Conflicts:
    #	package.json
    jakejones1984 authored and getdave committed Feb 1, 2019
    Configuration menu
    Copy the full SHA
    90c5a4d View commit details
    Browse the repository at this point in the history
  8. Utilise moment props provided by localize HOC

    Ensure dates used in MediaDateRange implements correct internationalization of dates and times using the moment instance provided by `i18n-calypso`
    
    https://github.com/Automattic/i18n-calypso
    jakejones1984 authored and getdave committed Feb 1, 2019
    Configuration menu
    Copy the full SHA
    3c467d2 View commit details
    Browse the repository at this point in the history
  9. Fixes errors generated by missing check for selectedDays prop

    Prevously code attempted to access `from` and `to` properties of the `selectedDays` Component prop before checking that `selectedDays` existed.
    jakejones1984 authored and getdave committed Feb 1, 2019
    Configuration menu
    Copy the full SHA
    622cb5c View commit details
    Browse the repository at this point in the history
  10. Fix trigger date display to be in local timezone

    Previously was hard coded to be in UK date format (DD/MM/YYYY). Updated to use moment utility to display in local date format.
    jakejones1984 authored and getdave committed Feb 1, 2019
    Configuration menu
    Copy the full SHA
    59629fa View commit details
    Browse the repository at this point in the history
  11. Add onDateSelect prop and test coverage

    Adds a new onDateSelect prop which is trigger each time a date is selected by the user. Adds tests coverage for this. Also sets a known locale for the injected momentJS in tests to ensure consistent results.
    jakejones1984 authored and getdave committed Feb 1, 2019
    Configuration menu
    Copy the full SHA
    36269c0 View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    e25e923 View commit details
    Browse the repository at this point in the history
  13. Makes dateselection callbacks pass start/end date as args

    Previously `onDateSelect` and `onDateCommit` callbacks were called without arguments. This meant they weren’t that useful. Now passes start and end dates as args when called. Test coverage added.
    jakejones1984 authored and getdave committed Feb 1, 2019
    Configuration menu
    Copy the full SHA
    8cb10f2 View commit details
    Browse the repository at this point in the history
  14. Adds dateRange prop to MediaLibrary component trees and query

    Previously the selected date range was not communicated outside of the MediaDateRange component. Adds a dateRange prop and onDateChange callback prop which are used to store the current date range and update the state of the dateRange prop respectively. This enables us to pass the dateRange into the API query used to retrieve photos data.
    jakejones1984 authored and getdave committed Feb 1, 2019
    Configuration menu
    Copy the full SHA
    ac57285 View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    4053ab7 View commit details
    Browse the repository at this point in the history
  16. Fixes EditorMediaModal tests by passing moment prop

    Previously due to use of localize HOC, the tests were failing due to the missing moment property which is injected by the HOC but not included in the tests. Unlike the similarly required translate prop, we cannot simply ‘identity’ this so we inject the actual moment lib from i18n-calypso during tests
    jakejones1984 authored and getdave committed Feb 1, 2019
    Configuration menu
    Copy the full SHA
    2b7d788 View commit details
    Browse the repository at this point in the history
  17. Fixes Enzyme warning about isEmpty

    Tweak test to utilise exists() rather than isEmpty(). Required inverting the assertions as the assertion itself is the inverse
    jakejones1984 authored and getdave committed Feb 1, 2019
    Configuration menu
    Copy the full SHA
    dc913e6 View commit details
    Browse the repository at this point in the history
  18. Adds text input based date entry in sync with DatePicker

    Previously only way to select dates was to use the DatePicker. However, many users may be unable (or choose not) to use that interface. Best a11y practice is to provide a standard form input. Adds functionality and test coverage.
    jakejones1984 authored and getdave committed Feb 1, 2019
    Configuration menu
    Copy the full SHA
    6a1d1c9 View commit details
    Browse the repository at this point in the history
  19. Fix bug with blurring input caused both inputs to update to blurred i…

    …nput’s date
    
    Previously when blurring input #1 the value would be automatically be “copied” to input #2 if input #1’s value was the same as that stored in state. This is due to the way the DateUtils.addDayToRange() method works. Fix this by checking whether the value of the input that has just been blurred is the same as that stored in state. If so then don’t trigger an update of the selected date range. Adds test coverage.
    jakejones1984 authored and getdave committed Feb 1, 2019
    Configuration menu
    Copy the full SHA
    09aecd2 View commit details
    Browse the repository at this point in the history
  20. Updates Media Date Range to utilise “mobile first” approach to layout

    On screens smaller than 480px:
    
    * removes selected date text on button (leaving just an icon)
    * displays only 1 month of calendar at a time (instead of two)
    
    Adds tests to cover this.
    jakejones1984 authored and getdave committed Feb 1, 2019
    Configuration menu
    Copy the full SHA
    23ee7be View commit details
    Browse the repository at this point in the history
  21. Update implementation to utilise showOutside days prop

    Standardise implementation to utilise prop “showOutsideDays” rather than the previously added (non-standard) “enableOutsideDays”.
    jakejones1984 authored and getdave committed Feb 1, 2019
    Configuration menu
    Copy the full SHA
    ffe782d View commit details
    Browse the repository at this point in the history
  22. Fix date range tests

    Update tests to utilise “showOutsideDays” prop and properly mock matchMedia using standard Jest pattern
    jakejones1984 authored and getdave committed Feb 1, 2019
    Configuration menu
    Copy the full SHA
    162c85f View commit details
    Browse the repository at this point in the history
  23. Restore styling for Media Date Range into 2 colums

    Date range picker styling update to ensure 2 datepickers are in 2 columns.
    jakejones1984 authored and getdave committed Feb 1, 2019
    Configuration menu
    Copy the full SHA
    61a5a7f View commit details
    Browse the repository at this point in the history
  24. Fixes moment date formats to standard on Media Date Range

    Previously dates were being passed to momentJS using a nonstandard format (“MM/DD/YYYY”). Moment falls back to JS Date which has unreliable rules around parsing formats, so it’s best practise to give moment a explicit format as the second arg. Apply to code and tests.
    getdave committed Feb 1, 2019
    Configuration menu
    Copy the full SHA
    260f405 View commit details
    Browse the repository at this point in the history
  25. Fixes styles to use CSS vars

    getdave committed Feb 1, 2019
    Configuration menu
    Copy the full SHA
    2808a2b View commit details
    Browse the repository at this point in the history
  26. Updates to utilise core DateRange component

    Previously utillised a bespoke DateRange implementation. Updates to use the standard core DateRange component created in `29938`.
    
    Also removes custom `dateRange` prop and ensure `filter` and `onFilterChange` props are passed down into ExternalMediaHeader
    getdave committed Feb 1, 2019
    Configuration menu
    Copy the full SHA
    b9896fb View commit details
    Browse the repository at this point in the history
  27. Fixes DateRange Popover to appear over Dialog

    Previously within the post editor Media Modal the Popover wasn’t visible because it was “behind” the Media modal.
    
    `client/components/date-range/index.js` defines a modifier `is-dialog-visible` which accounts for this. Ensure this is always applied to the DateRange to account for this scenario.
    getdave committed Feb 1, 2019
    Configuration menu
    Copy the full SHA
    1ea7ffe View commit details
    Browse the repository at this point in the history
  28. Adds ability to modify Media service query with date filters

    Working prototype of date filtering of Google Photos Media now in place for post media modal view _only_. Adds “queryFilter” data prop and handler prop and update the query past to the REST API if the `DateRange` component triggers an update.
    getdave committed Feb 1, 2019
    Configuration menu
    Copy the full SHA
    682a3dd View commit details
    Browse the repository at this point in the history
  29. Configuration menu
    Copy the full SHA
    6b29b8d View commit details
    Browse the repository at this point in the history
  30. Updates to convert dateRange to REST API query format

    Update to handle edge cases around selected date ranges. Now handles scenarios where dates in the range aren’t selected and replaces with the “wildcard” selection.
    
    Any portion of the range passed as `0000-00-00` means any date.
    https://developers.google.com/photos/library/reference/rest/v1/mediaItems/search#Date
    getdave committed Feb 1, 2019
    Configuration menu
    Copy the full SHA
    51da934 View commit details
    Browse the repository at this point in the history
  31. Remove legacy component

    This has been replaced with the core `DateRange` component
    getdave committed Feb 1, 2019
    Configuration menu
    Copy the full SHA
    a220d39 View commit details
    Browse the repository at this point in the history
  32. Updates Media Date Range for better presentation on small viewports

    Previously the DateRange button was large on small screens. With the limited screen real estate we need to drop down to only using icons. This commit implements that whilst also removing all of the other Media Date Range styles which are now part of the core DateRange and thus no longer needed.
    getdave committed Feb 1, 2019
    Configuration menu
    Copy the full SHA
    71b5d2b View commit details
    Browse the repository at this point in the history
  33. Removes redunant Media Date Range tests

    These tests are now covered in the core `DateRange` component.
    getdave committed Feb 1, 2019
    Configuration menu
    Copy the full SHA
    0feb410 View commit details
    Browse the repository at this point in the history
  34. Fixes DateRange clear button to butt up against main trigger

    Previously the Trigger button and the Clear “X” button we’re spaced due to a blanket CSS rule applying RHS margin to all `.button` elements. Overides this to ensure button and clear are butting up alongside each other as per a standard button group element.
    getdave committed Feb 1, 2019
    Configuration menu
    Copy the full SHA
    b549071 View commit details
    Browse the repository at this point in the history
  35. Fixes propagating invalid dates as queryFilter change

    Previously strings such as “InvalidDate” were being propagated upwards with `onQueryFiltersChange`. This caused logic errors further up the component tree. Fixed by checking date validity prior to propagating.
    getdave committed Feb 1, 2019
    Configuration menu
    Copy the full SHA
    a873947 View commit details
    Browse the repository at this point in the history
  36. Updates “No Results” UI to account for query filters

    Previously if a queryFilter (eg: date range) caused there to be no Media returned then the UI would show “No photos in your library” (or simialr).
    
    Updates so that if there is no Media when a queryFilter is applied then this is treated as a “No results” rather than “No content” issue and the appropriate UI is displayed.
    getdave committed Feb 1, 2019
    Configuration menu
    Copy the full SHA
    a2c3d5b View commit details
    Browse the repository at this point in the history
  37. Resolves eslint warnings

    ESLint was triggering warnings that had to be resolved (annoyingly in a single commit!).
    
    Firstly, regarding usage of setState in componentDidMount. This is often true. However React docs themselves say this is valid when doing DOM interaction such as measuring widths…etc.
    
    > …when you need to measure a DOM node before rendering something that depends on its size or position
    
    See https://reactjs.org/docs/react-component.html#componentdidmount
    
    Secondly, string refs were being used. Modified to use createRef() pattern.
    getdave committed Feb 1, 2019
    Configuration menu
    Copy the full SHA
    acd01f9 View commit details
    Browse the repository at this point in the history
  38. Adds query filters props to other instance of Media Library

    Previously the query filters that allow for Date Range filtering were only added to the Media Modal instance of Media Library. Manually copied these across into the “main” Media library instance as well.
    getdave committed Feb 1, 2019
    Configuration menu
    Copy the full SHA
    6942cb7 View commit details
    Browse the repository at this point in the history
  39. Fixes use of invalid React string based ref

    React has deprecated string based refs. Converted to a `createRef()` version.
    getdave committed Feb 1, 2019
    Configuration menu
    Copy the full SHA
    b38967c View commit details
    Browse the repository at this point in the history
  40. Fixes code conditional logic and improves comments

    Previously conditional logic and accompanying comment we’re very clear as to the intent of the conditional. Amended for clarity.
    getdave committed Feb 1, 2019
    Configuration menu
    Copy the full SHA
    74a9164 View commit details
    Browse the repository at this point in the history
  41. Configuration menu
    Copy the full SHA
    cba3ac9 View commit details
    Browse the repository at this point in the history
  42. Updates DateRange to compact render mode

    Matches existing toolbar styles more closely.
    getdave committed Feb 1, 2019
    Configuration menu
    Copy the full SHA
    1adf4cb View commit details
    Browse the repository at this point in the history
  43. Fixes Media Library header toolbar responsive layout issues

    Previously the responsive behaviour of the toolbar wasn’t consistent across viewports. Moreover the alignment and centering of content was achieved via hacks such as absolute positioning and margins.
    
    Updates to utilise flexbox for alignment in order to improve resilience of layout across various viewports sizes.
    
    Resolves: #25762 (comment)
    getdave committed Feb 1, 2019
    Configuration menu
    Copy the full SHA
    5c08958 View commit details
    Browse the repository at this point in the history
  44. Configuration menu
    Copy the full SHA
    1d10883 View commit details
    Browse the repository at this point in the history
  45. Fixes focused date defaults in DatePicker

    Previously if you selected a single date away from the current month by a few months in the past and closed the picker and then reopened it the calendar would be focused on today’s date rather than the date you just picked.
    
    Fixes to always focus on the start date if there is not focused date explicitly set.
    
    Resolves #25762 (comment)
    getdave committed Feb 1, 2019
    Configuration menu
    Copy the full SHA
    d33cf6e View commit details
    Browse the repository at this point in the history
  46. Fixes regression where buttons were too tall

    Comparing with production all buttons were suddenly larger. Fixes to ensure toolbar buttons are not suddenly taller.
    
    Resolves #25762 (comment)
    getdave committed Feb 1, 2019
    Configuration menu
    Copy the full SHA
    15b32a8 View commit details
    Browse the repository at this point in the history
  47. Configuration menu
    Copy the full SHA
    7476254 View commit details
    Browse the repository at this point in the history
  48. Fixes list data tests to match changes

    Previously tests were out of sync with changes to files. Added initial date range filter test. Also updated wording of tests to avoid using the term “media query” as this is potentially confusing due to it’s significance in responsive design.
    getdave committed Feb 1, 2019
    Configuration menu
    Copy the full SHA
    14cf9b9 View commit details
    Browse the repository at this point in the history
  49. Fixes logic errors uncovered by tests

    Updating tests to cover various scenarios uncovered x2 errors:
    
    1. Non-string dates were accepted by moment’s parsing and were incorrectly added to the filter (eg: `new Date()`)
    2. If either from or to were wildcards (eg: `0000-00-00`) then the filer wouldn’t be added. However we only wanrt to avoid the filter being added if BOTH the dates are wildcards.
    
    Fixed and added tests to cover.
    getdave committed Feb 1, 2019
    Configuration menu
    Copy the full SHA
    0783bad View commit details
    Browse the repository at this point in the history
  50. Updates to simplify translation by removing Media type from no result…

    …s listing
    
    Previously translated strings were broken up into separately translated strings and then concatenated to produce a full “no results” status string for the UI. This would not have been best practice as often sentances need to be compeltely reordered in other languages.
    
    Updates to ensure strings are translated in a single go. As part of this @johngodley and I decided to remove the Media type from the no results statement as it didn’t add much value and would have added considerably verbosity to the code.
    
    Resolves #25762 (comment)
    getdave committed Feb 1, 2019
    Configuration menu
    Copy the full SHA
    845ce46 View commit details
    Browse the repository at this point in the history
  51. Fix CircleCI Lint warnings

    Resolves Circle CI Lint warnings:
    
    1. incorrect usages of let var declaration
    2. 'component-event' should be listed in the project's dependencies. Run 'npm i -S component-event' to add it.
    
    Both fixed.
    getdave committed Feb 1, 2019
    Configuration menu
    Copy the full SHA
    ac19fad View commit details
    Browse the repository at this point in the history
  52. Configuration menu
    Copy the full SHA
    982c47e View commit details
    Browse the repository at this point in the history