Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Show report load errors in a notice across the report, without Retry when access is denied. Show access denied on author, post, and video details as an error.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ export {
type DetailPageSectionProps,
} from './detail-page-layout';
export { DetailPageEmptyState, type DetailPageEmptyStateProps } from './detail-page-empty-state';
export { DetailPageNotice, type DetailPageNoticeProps } from './detail-page-notice';
export { describeDetailPageError } from './describe-detail-page-error';
export { DetailPageShell, type DetailPageShellProps } from './detail-page-shell';
export {
DetailPageActions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ export {
export {
ReportChartSection,
ReportDrilldownTable,
ReportErrorState,
ReportLocationsMap,
ReportPageLayout,
ReportPageSection,
Expand All @@ -156,7 +155,6 @@ export {
type ReportChartMetric,
type ReportChartSectionProps,
type ReportDrilldownTableProps,
type ReportErrorStateProps,
type ReportLocationsMapProps,
type ReportPageLayoutProps,
type ReportPageSectionProps,
Expand All @@ -174,20 +172,18 @@ export {
DETAIL_HEADER_GLYPH_SIZE,
DetailPageEmptyState,
DetailPageLayout,
DetailPageNotice,
DetailPageSection,
DetailPageShell,
describeDetailPageError,
useDetailPageCustomize,
type DetailPageActionsProps,
type DetailPageBreadcrumbsProps,
type DetailPageCustomize,
type DetailPageHeaderSlots,
type DetailPageLayoutProps,
type DetailPageNoticeProps,
type DetailPageSectionProps,
type DetailPageShellProps,
} from './detail-page';
export { PageNotice, type PageNoticeProps } from './page-notice';
export {
FeedbackModal,
PageOptionsMenu,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* External dependencies
*/
import { render } from '@testing-library/react';
/**
* Internal dependencies
*/
import { getNoticeAnnouncement } from '../../../../../../tests/js/notice-test-utils';
import { PageNotice } from '../page-notice';

describe( 'PageNotice', () => {
it.each( [
[ 'assertively by default', undefined, 'assertive' ],
[ 'politely for info', 'info', 'polite' ],
] as const )( 'announces %s', ( _, intent, politeness ) => {
render( <PageNotice intent={ intent } description="Something happened." /> );

expect( getNoticeAnnouncement( 'Something happened.', politeness ) ).toBeInTheDocument();
} );
} );
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { PageNotice, type PageNoticeProps } from './page-notice';
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,21 @@ import { Notice } from '@jetpack-premium-analytics/externals';
import type { WidgetStateError } from '../widget-state';
import type { ReactElement } from 'react';

export interface DetailPageNoticeProps extends Pick< WidgetStateError, 'description' | 'actions' > {
/** `error` when something failed; `info` when the request answered and the answer is a fact, such as no access. */
intent: 'error' | 'info';
export interface PageNoticeProps extends Pick< WidgetStateError, 'description' | 'actions' > {
/** `info` for a fact rather than a fault, such as a missing item; failures, access denied included, are an `error`. */
intent?: 'error' | 'info';
/** A way out of the page, such as back to its report; `render` is a childless router link, as its children would replace `label`. */
link?: { label: string; render: ReactElement };
}

/**
* Stand in for a detail page's widgets when the page's subject failed to load or does not exist.
* Stand in for a report's sections or a detail page's widgets when their data failed to load or does not exist.
* Replace the sections rather than sit beside them: report tables pick their empty state from row count, not fetch status.
*
* @param {DetailPageNoticeProps} props - The component props.
* @return The detail page notice.
* @param {PageNoticeProps} props - The component props.
* @return The page notice.
*/
export function DetailPageNotice( { intent, description, actions, link }: DetailPageNoticeProps ) {
export function PageNotice( { intent = 'error', description, actions, link }: PageNoticeProps ) {
return (
// The default announcement (children) would trail the action labels.
<Notice.Root intent={ intent } spokenMessage={ description }>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export {
type ReportPageSectionProps,
} from './report-page-layout';
export { ReportChartSection, type ReportChartSectionProps } from './report-chart-section';
export { ReportErrorState, type ReportErrorStateProps } from './report-error-state';
export { ReportLocationsMap, type ReportLocationsMapProps } from './report-locations-map';
export { ExporterCsvAction } from './exporter-csv-action';
export { ReportCsvAction, type ReportCsvActionProps } from './report-csv-action';
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -122,23 +122,22 @@ export {
DETAIL_HEADER_GLYPH_SIZE,
DetailPageEmptyState,
DetailPageLayout,
DetailPageNotice,
DetailPageSection,
DetailPageActions,
DetailPageBreadcrumbs,
DetailPageShell,
describeDetailPageError,
useDetailPageCustomize,
type DetailPageActionsProps,
type DetailPageBreadcrumbsProps,
type DetailPageCustomize,
type DetailPageHeaderSlots,
type DetailPageLayoutProps,
type DetailPageNoticeProps,
type DetailPageSectionProps,
type DetailPageShellProps,
FeedbackModal,
type FeedbackSource,
PageNotice,
type PageNoticeProps,
PageOptionsMenu,
type PageOptionsMenuProps,
ResetLayoutAction,
Expand All @@ -150,7 +149,6 @@ export {
type LocationsGeoRow,
ReportChartSection,
ReportDrilldownTable,
ReportErrorState,
ReportLocationsMap,
ReportPageLayout,
ReportPageSection,
Expand All @@ -166,7 +164,6 @@ export {
type ReportChartMetric,
type ReportChartSectionProps,
type ReportDrilldownTableProps,
type ReportErrorStateProps,
type ReportLocationsMapProps,
type ReportPageLayoutProps,
type ReportPageSectionProps,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ describe( 'author detail stage', () => {

expect( getNoticeText( "You don't have access to this data." ) ).toBeInTheDocument();
expect(
getNoticeAnnouncement( "You don't have access to this data.", 'polite' )
getNoticeAnnouncement( "You don't have access to this data.", 'assertive' )
).toBeInTheDocument();
expect( screen.queryByRole( 'button', { name: 'Retry' } ) ).not.toBeInTheDocument();
} );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ import {
DetailPageActions,
DetailPageBreadcrumbs,
DetailPageLayout,
DetailPageNotice,
PageNotice,
DetailPageSection,
DetailPageShell,
describeDetailPageError,
describeError,
useDetailPageCustomize,
useStoredDetailLayout,
useTrackedDateRangeApply,
type DetailPageNoticeProps,
type PageNoticeProps,
} from '@jetpack-premium-analytics/widgets-toolkit';
import { useCallback, useMemo } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
Expand Down Expand Up @@ -143,7 +143,7 @@ function AuthorDetail(): JSX.Element {
[ search ]
);

let notice: DetailPageNoticeProps | null = null;
let notice: PageNoticeProps | null = null;

if ( summary.isError ) {
// Same split as the widgets, plus a 404: sites that hide the users
Expand All @@ -157,7 +157,7 @@ function AuthorDetail(): JSX.Element {
'jetpack-premium-analytics-pkg'
),
}
: describeDetailPageError( summary.error, {
: describeError( summary.error, {
retryDescription: __(
"We couldn't load this author. Please try again in a moment.",
'jetpack-premium-analytics-pkg'
Expand Down Expand Up @@ -230,7 +230,7 @@ function AuthorDetail(): JSX.Element {
) : null }
{ notice ? (
<DetailPageSection>
<DetailPageNotice { ...notice } />
<PageNotice { ...notice } />
</DetailPageSection>
) : null }
</DetailPageLayout>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ describe( 'post detail stage on the provisional all-time window', () => {
expect( refetch ).toHaveBeenCalledTimes( 1 );
} );

it( 'offers no Retry when the publish day is denied, as an info notice', () => {
it( 'offers no Retry when the publish day is denied', () => {
mockSummary( {
isError: true,
error: { code: 'rest_forbidden', status: 403 },
Expand All @@ -751,7 +751,7 @@ describe( 'post detail stage on the provisional all-time window', () => {

expect( getNoticeText( "You don't have access to this data." ) ).toBeInTheDocument();
expect(
getNoticeAnnouncement( "You don't have access to this data.", 'polite' )
getNoticeAnnouncement( "You don't have access to this data.", 'assertive' )
).toBeInTheDocument();
expect( screen.queryByRole( 'button', { name: 'Retry' } ) ).not.toBeInTheDocument();
} );
Expand Down
Loading
Loading