-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create spotlight on analytics revenue report (#36653)
* Add `RevenueReportDateTour` component * Add changelog * Fix styles * Rename RevenueReportDateTour to ReportDateTour to use it in two different reports: Orders and Revenue * Change default sort date to date_paid # Conflicts: # plugins/woocommerce/src/Admin/API/Reports/Orders/Stats/DataStore.php * Update changelog * Assign date_column_name before calling parent constructor * Remove date_type default value from configuration and show tour only if user didn't assign a value --------- Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com> Co-authored-by: Nathan Schneider <nsschneider1@gmail.com>
- Loading branch information
1 parent
87d79f1
commit 756fe32
Showing
8 changed files
with
135 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
plugins/woocommerce-admin/client/guided-tours/report-date-tour.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.woocommerce-revenue-report-date-tour { | ||
h2.woocommerce-tour-kit-step__heading { | ||
font-size: 1.5em; | ||
line-height: 1.5em; | ||
letter-spacing: 0.4px; | ||
} | ||
} |
100 changes: 100 additions & 0 deletions
100
plugins/woocommerce-admin/client/guided-tours/report-date-tour.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { TourKit, TourKitTypes } from '@woocommerce/components'; | ||
import { __ } from '@wordpress/i18n'; | ||
import { OPTIONS_STORE_NAME } from '@woocommerce/data'; | ||
import { | ||
createElement, | ||
createInterpolateElement, | ||
useState, | ||
} from '@wordpress/element'; | ||
import { useSelect, useDispatch } from '@wordpress/data'; | ||
import { getAdminLink } from '@woocommerce/settings'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import './report-date-tour.scss'; | ||
|
||
const DATE_TYPE_OPTION = 'woocommerce_date_type'; | ||
|
||
export const ReportDateTour: React.FC< { | ||
optionName: string; | ||
headingText: string; | ||
} > = ( { optionName, headingText } ) => { | ||
const [ isDismissed, setIsDismissed ] = useState( false ); | ||
const { updateOptions } = useDispatch( OPTIONS_STORE_NAME ); | ||
|
||
const { shouldShowTour, isResolving } = useSelect( ( select ) => { | ||
const { getOption, hasFinishedResolution } = | ||
select( OPTIONS_STORE_NAME ); | ||
return { | ||
shouldShowTour: | ||
getOption( optionName ) !== 'yes' && | ||
getOption( DATE_TYPE_OPTION ) === false, | ||
isResolving: ! ( | ||
hasFinishedResolution( 'getOption', [ optionName ] ) && | ||
hasFinishedResolution( 'getOption', [ DATE_TYPE_OPTION ] ) | ||
), | ||
}; | ||
} ); | ||
|
||
if ( isDismissed || ! shouldShowTour || isResolving ) { | ||
return null; | ||
} | ||
|
||
const config: TourKitTypes.WooConfig = { | ||
steps: [ | ||
{ | ||
referenceElements: { | ||
desktop: | ||
'.woocommerce-filters-filter > .components-dropdown', | ||
}, | ||
focusElement: { | ||
desktop: | ||
'.woocommerce-filters-filter > .components-dropdown', | ||
}, | ||
meta: { | ||
name: 'product-feedback-', | ||
heading: headingText, | ||
descriptions: { | ||
desktop: createInterpolateElement( | ||
__( | ||
'We now collect orders in this table based on when the payment went through, rather than when they were placed. You can change this in <link>settings</link>.', | ||
'woocommerce' | ||
), | ||
{ | ||
link: createElement( 'a', { | ||
href: getAdminLink( | ||
'admin.php?page=wc-admin&path=/analytics/settings' | ||
), | ||
'aria-label': __( | ||
'Analytics date settings', | ||
'woocommerce' | ||
), | ||
} ), | ||
} | ||
), | ||
}, | ||
primaryButton: { | ||
text: __( 'Got it', 'woocommerce' ), | ||
}, | ||
}, | ||
options: { | ||
classNames: { | ||
desktop: 'woocommerce-revenue-report-date-tour', | ||
}, | ||
}, | ||
}, | ||
], | ||
closeHandler: () => { | ||
updateOptions( { | ||
[ optionName ]: 'yes', | ||
} ); | ||
setIsDismissed( true ); | ||
}, | ||
}; | ||
|
||
return <TourKit config={ config } />; | ||
}; |
4 changes: 4 additions & 0 deletions
4
plugins/woocommerce/changelog/update-35887_spotlight_on_analytics_revenue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: major | ||
Type: update | ||
|
||
Change the default date used on Revenue and Orders report to 'date_paid' and create spotlight on both reports |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters