mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[Reporting] Copy Post URL: track layoutID in state (#30029)
* [Reporting] Post URL: track layoutID in state
* I think this code was not supposed to be here
* ts fix
* revert some diff
* Revert "I think this code was not supposed to be here"
This reverts commit b2e5f60afb
.
* static getAbsoluteReportGenerationUrl
* ts fix
This commit is contained in:
parent
e36da1bc5a
commit
ef0fba1bd2
3 changed files with 27 additions and 10 deletions
|
@ -19,6 +19,7 @@ import { reportingClient } from '../lib/reporting_client';
|
|||
|
||||
interface Props {
|
||||
reportType: string;
|
||||
layoutId: string | undefined;
|
||||
objectId?: string;
|
||||
objectType: string;
|
||||
getJobParams: () => any;
|
||||
|
@ -31,9 +32,27 @@ interface Props {
|
|||
interface State {
|
||||
isStale: boolean;
|
||||
absoluteUrl: string;
|
||||
layoutId: string;
|
||||
}
|
||||
|
||||
class ReportingPanelContentUi extends Component<Props, State> {
|
||||
public static getDerivedStateFromProps(nextProps: Props, prevState: State) {
|
||||
if (nextProps.layoutId !== prevState.layoutId) {
|
||||
return {
|
||||
...prevState,
|
||||
absoluteUrl: ReportingPanelContentUi.getAbsoluteReportGenerationUrl(nextProps),
|
||||
};
|
||||
}
|
||||
return prevState;
|
||||
}
|
||||
|
||||
private static getAbsoluteReportGenerationUrl = (props: Props) => {
|
||||
const relativePath = reportingClient.getReportingJobPath(
|
||||
props.reportType,
|
||||
props.getJobParams()
|
||||
);
|
||||
return url.resolve(window.location.href, relativePath);
|
||||
};
|
||||
private mounted?: boolean;
|
||||
|
||||
constructor(props: Props) {
|
||||
|
@ -42,6 +61,7 @@ class ReportingPanelContentUi extends Component<Props, State> {
|
|||
this.state = {
|
||||
isStale: false,
|
||||
absoluteUrl: '',
|
||||
layoutId: '',
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -54,7 +74,6 @@ class ReportingPanelContentUi extends Component<Props, State> {
|
|||
|
||||
public componentDidMount() {
|
||||
this.mounted = true;
|
||||
this.setAbsoluteReportGenerationUrl();
|
||||
|
||||
window.addEventListener('hashchange', this.markAsStale, false);
|
||||
window.addEventListener('resize', this.setAbsoluteReportGenerationUrl);
|
||||
|
@ -177,12 +196,7 @@ class ReportingPanelContentUi extends Component<Props, State> {
|
|||
if (!this.mounted) {
|
||||
return;
|
||||
}
|
||||
|
||||
const relativePath = reportingClient.getReportingJobPath(
|
||||
this.props.reportType,
|
||||
this.props.getJobParams()
|
||||
);
|
||||
const absoluteUrl = url.resolve(window.location.href, relativePath);
|
||||
const absoluteUrl = ReportingPanelContentUi.getAbsoluteReportGenerationUrl(this.props);
|
||||
this.setState({ absoluteUrl });
|
||||
};
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ export class ScreenCapturePanelContent extends Component<Props, State> {
|
|||
return (
|
||||
<ReportingPanelContent
|
||||
reportType={this.props.reportType}
|
||||
layoutId={this.getLayout().id}
|
||||
objectType={this.props.objectType}
|
||||
objectId={this.props.objectId}
|
||||
getJobParams={this.getJobParams}
|
||||
|
@ -103,8 +104,9 @@ export class ScreenCapturePanelContent extends Component<Props, State> {
|
|||
};
|
||||
|
||||
private getJobParams = () => {
|
||||
const jobParams = this.props.getJobParams();
|
||||
jobParams.layout = this.getLayout();
|
||||
return jobParams;
|
||||
return {
|
||||
...this.props.getJobParams(),
|
||||
layout: this.getLayout(),
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -51,6 +51,7 @@ function reportingProvider(Private: any, i18n: I18nServiceType) {
|
|||
content: (
|
||||
<ReportingPanelContent
|
||||
reportType="csv"
|
||||
layoutId={undefined}
|
||||
objectType={objectType}
|
||||
objectId={objectId}
|
||||
getJobParams={getJobParams}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue