-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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] Clean up types for internal APIs needed for UI #105508
[Reporting] Clean up types for internal APIs needed for UI #105508
Conversation
Pinging @elastic/kibana-app-services (Team:AppServices) |
Pinging @elastic/kibana-reporting-services (Team:Reporting Services) |
max_attempts: number; | ||
started_at: string | undefined; | ||
attempts: number; | ||
status: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was all nearly duplicated from ReportSource
import { IlmPolicyLink } from './ilm_policy_link'; | ||
|
||
export interface Job { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hoisted this to a class defined in another file
@@ -325,28 +303,7 @@ class ReportListingUi extends Component<Props, State> { | |||
this.setState(() => ({ | |||
isLoading: false, | |||
total, | |||
jobs: jobs.map( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The map
is no longer needed as apiClient.list
returns data in a usable format
980ac90
to
5d548ed
Compare
jobId: string; | ||
apiClient: ReportingAPIClient; | ||
} | ||
} & Pick<ListingProps, 'apiClient' | 'intl'>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This component is updated with a minor UI improvement to show a tooltip over the "info" icon. This makes it consistent with the "download" icon.
Fixes #103360
const job = await createJob!(jobParams, context, request); | ||
|
||
// 1. Add the report to ReportingStore to show as pending | ||
const report = await store.addReport( | ||
new Report({ | ||
jobtype: exportType.jobType, | ||
created_by: user ? user.username : false, | ||
max_attempts: config.get('capture', 'maxAttempts'), // NOTE: since max attempts is stored in the document, changing the capture.maxAttempts setting does not affect existing pending reports |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Max attempts is set on the report once it is claimed. The main reason to do this is to show the information in the "info" panel in the UI.
6fc3653
to
eefc828
Compare
@@ -26,26 +22,13 @@ const apiResponseFields = [ | |||
'status', | |||
]; | |||
|
|||
// TODO: clean up the /list and /info endpoints to return ReportApiJSON interface data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is done. The /list
endpoint had the most inconsistencies.
@@ -135,9 +135,8 @@ export class ExecuteReportTask implements ReportingTask { | |||
|
|||
const m = moment(); | |||
|
|||
// check if job has exceeded maxAttempts (stored in job params) and somehow hasn't been marked as failed yet | |||
// NOTE: the max attempts value comes from the stored document, so changing the capture.maxAttempts config setting does not affect existing pending reports |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is no longer true as of this PR
eefc828
to
3a85a26
Compare
@@ -306,11 +306,14 @@ export class ExecuteReportTask implements ReportingTask { | |||
} | |||
|
|||
if (!report) { | |||
this.reporting.untrackReport(jobId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes #105155
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job @tsullivan ! I did not run this locally, but all the changes make sense and I'm happy for this to be merged given green CI.
* This class represents a report job for the UI | ||
* It can be instantiated with ReportApiJSON: the response data format for the report job APIs | ||
*/ | ||
export class Job { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we using a class here? I think we could accomplish the same thing with just an interface and a function that maps one object to another (if needed). Unless we intend to associate behaviours with this in way that is in keeping with how we use classes elsewhere in Reporting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless we intend to associate behaviours with this in way that is in keeping with how we use classes elsewhere in Reporting.
Yes, this is the case. In an earlier incarnation of the code, there are methods on this class for achieving consistency about warnings [1], and then further on, showing some info about deprecated export types. That got to be a lot of changes in the UI that just needed to be isolated to a separate PR.
[1] Why is the only warning shown in a table cell about when the max size was reached? Why don't we use the table to show that a CSV could contain formulas, but we do show it in the toast notification? Why doesn't the info side panel show "status" the same way it's shown in the table?
x-pack/plugins/reporting/public/lib/reporting_api_client/reporting_api_client.ts
Outdated
Show resolved
Hide resolved
public verifyConfig = (): Promise<DiagnoseResponse> => | ||
this.http.post(`${API_BASE_URL}/diagnose/config`, { | ||
public async verifyConfig() { | ||
return await this.http.post(`${API_BASE_URL}/diagnose/config`, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just FWIW: these functions don't do anything with the call result so we don't need async
await
sugar. I think the return type gaurds have us covered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's kind of been preached to me to use this way instead of "desugared promises." It makes stack traces more readable, and there are some optimizations in V8 that went into making async and await native. https://v8.dev/blog/fast-async
x-pack/plugins/reporting/public/management/report_info_button.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/reporting/public/management/report_info_button.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few minor suggestions. LGTM, great job 👍
Co-authored-by: Jean-Louis Leysens <jloleysens@gmail.com>
Co-authored-by: Michael Dokolin <dokmic@gmail.com>
Co-authored-by: Michael Dokolin <dokmic@gmail.com>
Co-authored-by: Michael Dokolin <dokmic@gmail.com>
Found some bugs in the info panel due to usage of The next PR will have functional tests that cover the info panel in Reporting Management. |
💚 Build SucceededMetrics [docs]Module Count
Async chunks
Public APIs missing exports
Page load bundle
History
To update your PR or re-run it, just comment with: |
…05508) * [Reporting] Refactor types for API response data * fix api test * Update x-pack/plugins/reporting/common/types.ts Co-authored-by: Jean-Louis Leysens <jloleysens@gmail.com> * more verbose comments * set comments in interface type definition * Update x-pack/plugins/reporting/common/types.ts Co-authored-by: Michael Dokolin <dokmic@gmail.com> * more strict * Update x-pack/plugins/reporting/public/management/report_info_button.tsx Co-authored-by: Michael Dokolin <dokmic@gmail.com> * Update x-pack/plugins/reporting/public/management/report_info_button.tsx Co-authored-by: Michael Dokolin <dokmic@gmail.com> * fix suggestion * fix accidental declaration of interface methods as function properties * fix info panel Co-authored-by: Jean-Louis Leysens <jloleysens@gmail.com> Co-authored-by: Michael Dokolin <dokmic@gmail.com>
…105702) * [Reporting] Refactor types for API response data * fix api test * Update x-pack/plugins/reporting/common/types.ts Co-authored-by: Jean-Louis Leysens <jloleysens@gmail.com> * more verbose comments * set comments in interface type definition * Update x-pack/plugins/reporting/common/types.ts Co-authored-by: Michael Dokolin <dokmic@gmail.com> * more strict * Update x-pack/plugins/reporting/public/management/report_info_button.tsx Co-authored-by: Michael Dokolin <dokmic@gmail.com> * Update x-pack/plugins/reporting/public/management/report_info_button.tsx Co-authored-by: Michael Dokolin <dokmic@gmail.com> * fix suggestion * fix accidental declaration of interface methods as function properties * fix info panel Co-authored-by: Jean-Louis Leysens <jloleysens@gmail.com> Co-authored-by: Michael Dokolin <dokmic@gmail.com> Co-authored-by: Jean-Louis Leysens <jloleysens@gmail.com> Co-authored-by: Michael Dokolin <dokmic@gmail.com>
…-png-pdf-report-type * 'master' of github.com:elastic/kibana: (75 commits) [Search Sessions] Don’t try to delete errored searches (elastic#105434) [Search Sessions] fix saved object can be created even if courier:batchSearches is enabled (elastic#105407) [Remote Clusters] Fixed remote clusters details flyout for long strings (elastic#105592) [ML] Functional tests - re-activate a11y tests (elastic#105198) [APM] Typed client-side routing (elastic#104274) [Canvas] Expression error (elastic#103048) [ML] Fixing job wizard with missing description (elastic#105574) [Security Solution][Alerts] - Add alerts subfeature UI (elastic#105505) Upgrade EUI to v35.0.0 (elastic#105127) [Reporting] Clean up types for internal APIs needed for UI (elastic#105508) skip flaky suite (elastic#105087) [Workplace Search] Fix Chrome issues with GitHub sources (elastic#105680) [Fleet] Add containerized fleet server instructions to Fleet README (elastic#105669) [ML] Add api integration test for analytics map endpoint (elastic#105531) Fixes cypress flake across two tests (elastic#105645) [Logs&Metrics UI] add owner properties to plugin manifest (elastic#105580) chore(NA): introduce preset for jest-integration tests on @kbn/test (elastic#105144) [Enterprise Search] Added Thumbnails to Search UI (elastic#104199) Translate App Search credentials list (elastic#105619) [APM] APM agent config created prior to Fleet migration is not injected into integration policy (elastic#105504) ... # Conflicts: # x-pack/plugins/reporting/common/types.ts # x-pack/plugins/reporting/public/management/report_listing.test.tsx
Summary
Needed for #102833
Closes #104791
Closes #105155
Closes #103360
Cleanups to achieve type consistency:
ReportSource['max_attempts']
is allowed to be undefined.Note: The max attempts number is taken from configuration of the Kibana instance executing the job. This makes the max attempts number more consistent with other fields that only apply to jobs that have been claimed such as
timeout
andbrowser_type
.ReportApiJSON
:ReportSource
as the source of truthpayload.headers
andoutput.content
are omitted to avoid long strings of encrypted text in API responsesJob
class inreporting/public/lib/job.ts
to handle implementation details of the fields of a report job for the UI.public/lib/reporting_api_client/reporting_api_client.ts
any
_.get()
Changes to API responses:
/api/reporting/jobs/list
ReportApiJSON[]
format. Previously, the response data was unformatted from the original document in Elasticsearch (ReportSource
format).These are internal APIs and are not subject to backwards compatibility with older scripts.
This PR will not contain any user-facing changes as those will be isolated to #102833
Checklist
Delete any items that are not applicable to this PR.
For maintainers