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

[Reporting] Reporting info panel touch ups #120617

Merged
merged 22 commits into from
Dec 15, 2021
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
223af50
changed info -> summary and combined maximum attempts and attempts field
jloleysens Dec 7, 2021
305059f
added spaceId if it is there to job info
jloleysens Dec 7, 2021
bfb8036
moved space id to job details section
jloleysens Dec 7, 2021
318f8e1
moved processing and job info into a single array
jloleysens Dec 7, 2021
d828732
wip, introduced a new structure to the flyout for easier visual parsi…
jloleysens Dec 7, 2021
586e43f
remove unnecessary div
jloleysens Dec 7, 2021
1c0062e
added warnings and errors to callout and cleaned up comments
jloleysens Dec 7, 2021
0ffd3fc
remove unused functionality and introduce date formatting per advance…
jloleysens Dec 7, 2021
28fb5c0
remove unused import
jloleysens Dec 7, 2021
c67b758
remove unused i18n
jloleysens Dec 7, 2021
c2e4e74
Merge branch 'main' into reporting/info-panel-touch-ups
kibanamachine Dec 8, 2021
4d14d9f
Merge branch 'main' into reporting/info-panel-touch-ups
kibanamachine Dec 8, 2021
09707a8
refactor check for info.max_attempts in flyout content
jloleysens Dec 13, 2021
b3d1ead
update info.lyout.dimensions.height to be Math.ceiled
jloleysens Dec 13, 2021
009b5fb
update info.lyout.dimensions.width to be Math.ceiled
jloleysens Dec 13, 2021
f4d1166
Merge branch 'main' into reporting/info-panel-touch-ups
kibanamachine Dec 13, 2021
c6e3942
lint and remove bad suggestion commit
jloleysens Dec 13, 2021
614c723
added actions button to flyout, in flyout footer
jloleysens Dec 13, 2021
b218605
create a little bit more breathing room for the section titles
jloleysens Dec 13, 2021
0612c02
added logic to disable the action buttons in the flyout when the acti…
jloleysens Dec 13, 2021
d94957d
update copy per feedback
jloleysens Dec 14, 2021
72346b7
added basic tests for the actions menu in the flyout
jloleysens Dec 14, 2021
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
7 changes: 6 additions & 1 deletion x-pack/plugins/reporting/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,12 @@ export const CSV_SEARCHSOURCE_IMMEDIATE_TYPE = 'csv_searchsource_immediate';
export const CSV_REPORT_TYPE_DEPRECATED = 'CSV';
export const CSV_JOB_TYPE_DEPRECATED = 'csv';

export const USES_HEADLESS_JOB_TYPES = [PDF_JOB_TYPE, PNG_JOB_TYPE];
export const USES_HEADLESS_JOB_TYPES = [
PDF_JOB_TYPE,
PNG_JOB_TYPE,
PDF_JOB_TYPE_V2,
PNG_JOB_TYPE_V2,
];

export const DEPRECATED_JOB_TYPES = [CSV_JOB_TYPE_DEPRECATED];

Expand Down
49 changes: 24 additions & 25 deletions x-pack/plugins/reporting/public/lib/job.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import { EuiText, EuiTextColor } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n-react';
import moment from 'moment';
import React from 'react';
import { JOB_STATUSES } from '../../common/constants';
Expand Down Expand Up @@ -38,6 +37,7 @@ export class Job {
public spaceId: ReportPayload['spaceId'];
public browserTimezone?: ReportPayload['browserTimezone'];
public layout: ReportPayload['layout'];
public version: ReportPayload['version'];

public jobtype: ReportSource['jobtype'];
public created_by: ReportSource['created_by'];
Expand Down Expand Up @@ -68,6 +68,7 @@ export class Job {
this.objectType = report.payload.objectType;
this.title = report.payload.title;
this.layout = report.payload.layout;
this.version = report.payload.version;
this.created_by = report.created_by;
this.created_at = report.created_at;
this.started_at = report.started_at;
Expand Down Expand Up @@ -141,34 +142,32 @@ export class Job {
return null;
}

getStatus() {
const statusLabel = jobStatusLabelsMap.get(this.status) as string;
const statusTimestamp = this.getStatusTimestamp();
public get prettyStatus(): string {
return (
jobStatusLabelsMap.get(this.status) ??
i18n.translate('xpack.reporting.jobStatusDetail.unknownText', { defaultMessage: 'Unknown' })
);
}

if (statusTimestamp) {
return (
<FormattedMessage
id="xpack.reporting.jobStatusDetail.statusTimestampText"
defaultMessage="{statusLabel} at {statusTimestamp}"
values={{
statusLabel,
statusTimestamp: (
<span className="eui-textNoWrap">{this.formatDate(statusTimestamp)}</span>
),
}}
/>
);
}
public get canLinkToKibanaApp(): boolean {
return Boolean(this.locatorParams);
}

return statusLabel;
public get isDownloadReady(): boolean {
return this.status === JOB_STATUSES.COMPLETED || this.status === JOB_STATUSES.WARNINGS;
}

getStatusLabel() {
return (
<>
{this.getStatus()} {this.getStatusMessage()}
</>
);
public get prettyTimeout(): string {
if (this.timeout == null) {
return i18n.translate('xpack.reporting.jobStatusDetail.timeoutSecondsUnknown', {
defaultMessage: 'Unknown',
});
}
const seconds = this.timeout / 1000;
return i18n.translate('xpack.reporting.jobStatusDetail.timeoutSeconds', {
defaultMessage: '{timeout} seconds',
values: { timeout: seconds },
});
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,17 @@ import {
EuiFlyout,
EuiFlyoutBody,
EuiFlyoutHeader,
EuiFlyoutFooter,
EuiPortal,
EuiText,
EuiFlexGroup,
EuiFlexItem,
EuiButtonEmpty,
EuiButton,
EuiTitle,
EuiLoadingSpinner,
EuiPopover,
EuiContextMenuItem,
EuiContextMenuPanel,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';

Expand All @@ -31,10 +38,13 @@ interface Props {
export const ReportInfoFlyout: FunctionComponent<Props> = ({ onClose, job }) => {
const [isLoading, setIsLoading] = useState<boolean>(true);
const [loadingError, setLoadingError] = useState<undefined | Error>();
const [isActionsPopoverOpen, setIsActionsPopoverOpen] = useState<boolean>(false);
const [info, setInfo] = useState<undefined | Job>();
const isMounted = useMountedState();
const { apiClient } = useInternalApiClient();

const closePopover = () => setIsActionsPopoverOpen(false);

useEffect(() => {
(async function loadInfo() {
if (isLoading) {
Expand All @@ -56,6 +66,42 @@ export const ReportInfoFlyout: FunctionComponent<Props> = ({ onClose, job }) =>
})();
}, [isLoading, apiClient, job.id, isMounted]);

const actionsButton = (
<EuiButton iconType="arrowUp" onClick={() => setIsActionsPopoverOpen((isOpen) => !isOpen)}>
{i18n.translate('xpack.reporting.reportInfoFlyout.actionsButtonLabel', {
defaultMessage: 'Actions',
})}
</EuiButton>
);

const actionItems = [
<EuiContextMenuItem
key="download"
icon="download"
disabled={!job.isDownloadReady}
onClick={() => {
apiClient.downloadReport(job.id);
}}
>
{i18n.translate('xpack.reporting.reportInfoFlyout.downloadButtonLabel', {
defaultMessage: 'Download',
})}
</EuiContextMenuItem>,
<EuiContextMenuItem
disabled={!job.canLinkToKibanaApp}
key="openInKibanaApp"
icon="popout"
onClick={() => {
window.open(apiClient.getKibanaAppHref(job), '_blank');
window.focus();
}}
>
{i18n.translate('xpack.reporting.reportInfoFlyout.openInKibanaAppButtonLabel', {
defaultMessage: 'Open in Kibana App',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really have the context for this text, but can it be: Open in Kibana

If you do include app, it should be lower case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Open in Kibana" sounds good!

})}
</EuiContextMenuItem>,
];

return (
<EuiPortal>
<EuiFlyout
Expand All @@ -72,8 +118,9 @@ export const ReportInfoFlyout: FunctionComponent<Props> = ({ onClose, job }) =>
? i18n.translate('xpack.reporting.listing.table.reportInfoUnableToFetch', {
defaultMessage: 'Unable to fetch report info.',
})
: i18n.translate('xpack.reporting.listing.table.reportCalloutTitle', {
defaultMessage: 'Report info',
: info?.title ??
i18n.translate('xpack.reporting.listing.table.untitledReport', {
defaultMessage: 'Untitled report',
})}
</h2>
</EuiTitle>
Expand All @@ -82,11 +129,33 @@ export const ReportInfoFlyout: FunctionComponent<Props> = ({ onClose, job }) =>
{isLoading ? (
<EuiLoadingSpinner />
) : loadingError ? undefined : !!info ? (
<EuiText>
<ReportInfoFlyoutContent info={info} />
</EuiText>
<ReportInfoFlyoutContent info={info} />
) : undefined}
</EuiFlyoutBody>
{!isLoading && (
<EuiFlyoutFooter>
<EuiFlexGroup gutterSize="none" justifyContent="spaceBetween">
<EuiFlexItem grow={false}>
<EuiButtonEmpty iconType="cross" flush="left" onClick={onClose}>
{i18n.translate('xpack.reporting.listing.flyout.closeButtonLabel', {
defaultMessage: 'Close',
})}
</EuiButtonEmpty>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiPopover
id="reportInfoFlyoutActionsPopover"
button={actionsButton}
isOpen={isActionsPopoverOpen}
closePopover={closePopover}
panelPaddingSize="none"
>
<EuiContextMenuPanel items={actionItems} />
</EuiPopover>
</EuiFlexItem>
</EuiFlexGroup>
</EuiFlyoutFooter>
)}
</EuiFlyout>
</EuiPortal>
);
Expand Down
Loading