Skip to content

Commit 0d3f28d

Browse files
Fix files management flyout crashing (#237588)
## Summary This PR fixes flyout on files management page (click `Statistics` on `/app/management/kibana/filesManagement`) crashing. It has been crashing since 9.1. I'm not exactly sure what the actual reason for crashing is. This fix changes the `xScaleType` from `Time` to `Ordinal`. The value displayed on x axis is `key`, which in this context is file extension, so it doesn't make a sense to use `Time` here. Closes: #235534 (cherry picked from commit 72c5997)
1 parent c2cd0a3 commit 0d3f28d

3 files changed

Lines changed: 43 additions & 6 deletions

File tree

src/platform/plugins/private/files_management/public/app.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,11 @@ export const App: FunctionComponent = () => {
8787
}}
8888
withoutPageTemplateWrapper
8989
additionalRightSideActions={[
90-
<EuiButtonEmpty onClick={() => setShowDiagnosticsFlyout(true)}>
90+
<EuiButtonEmpty
91+
onClick={() => setShowDiagnosticsFlyout(true)}
92+
aria-label={i18nTexts.diagnosticsFlyoutTitle}
93+
data-test-subj="filesManagementOpenDiagnosticsFlyoutButton"
94+
>
9195
{i18nTexts.diagnosticsFlyoutTitle}
9296
</EuiButtonEmpty>,
9397
]}

src/platform/plugins/private/files_management/public/components/diagnostics_flyout.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,13 @@ export const DiagnosticsFlyout: FunctionComponent<Props> = ({ onClose }) => {
4444
const titleId = useGeneratedHtmlId({ prefix: 'diagnosticsFlyoutTitle' });
4545

4646
return (
47-
<EuiFlyout ownFocus onClose={onClose} size="s" aria-labelledby={titleId}>
47+
<EuiFlyout
48+
ownFocus
49+
onClose={onClose}
50+
size="s"
51+
aria-labelledby={titleId}
52+
data-test-subj="diagnosticsFlyout"
53+
>
4854
<EuiFlyoutHeader hasBorder>
4955
<EuiTitle size="m">
5056
<h2 id={titleId}>{i18nTexts.diagnosticsFlyoutTitle}</h2>
@@ -106,9 +112,8 @@ export const DiagnosticsFlyout: FunctionComponent<Props> = ({ onClose }) => {
106112
id="Status"
107113
xAccessor={'key'}
108114
yAccessors={['count']}
109-
xScaleType={ScaleType.Time}
115+
xScaleType={ScaleType.Ordinal}
110116
yScaleType={ScaleType.Linear}
111-
timeZone="local"
112117
/>
113118
</Chart>
114119
</EuiPanel>
@@ -129,9 +134,8 @@ export const DiagnosticsFlyout: FunctionComponent<Props> = ({ onClose }) => {
129134
id="Extension"
130135
xAccessor={'key'}
131136
yAccessors={['count']}
132-
xScaleType={ScaleType.Time}
137+
xScaleType={ScaleType.Ordinal}
133138
yScaleType={ScaleType.Linear}
134-
timeZone="local"
135139
/>
136140
</Chart>
137141
</EuiPanel>

test/functional/apps/management/_files.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,23 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
1313
const PageObjects = getPageObjects(['common', 'filesManagement']);
1414
const testSubjects = getService('testSubjects');
1515
const retry = getService('retry');
16+
const supertest = getService('supertest');
17+
const fileRoute = '/api/files/files/defaultImage';
1618

1719
describe('Files management', () => {
20+
let createdFileIds: string[] = [];
21+
1822
before(async () => {
1923
await PageObjects.filesManagement.navigateTo();
2024
});
2125

26+
after(async () => {
27+
for (const fileId of createdFileIds) {
28+
await supertest.delete(`${fileRoute}/${fileId}`).set('kbn-xsrf', 'xxx');
29+
}
30+
createdFileIds = [];
31+
});
32+
2233
it(`should render an empty prompt`, async () => {
2334
await testSubjects.existOrFail('filesManagementApp');
2435

@@ -27,5 +38,23 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
2738
return pageText.includes('No files found');
2839
});
2940
});
41+
42+
it('should display charts in diagnostics flyout if any files exist', async () => {
43+
const createFileResponse = await supertest.post(fileRoute).set('kbn-xsrf', 'xxx').send({
44+
name: 'test',
45+
mimeType: 'image/png',
46+
});
47+
48+
const createdFileId = createFileResponse.body.file.id;
49+
createdFileIds.push(createdFileId);
50+
51+
await testSubjects.click('filesManagementOpenDiagnosticsFlyoutButton');
52+
await testSubjects.existOrFail('diagnosticsFlyout');
53+
54+
await retry.waitFor('Display charts', async () => {
55+
const flyoutText = await (await testSubjects.find('diagnosticsFlyout')).getVisibleText();
56+
return flyoutText.includes('Count by extension') && flyoutText.includes('Count by status');
57+
});
58+
});
3059
});
3160
}

0 commit comments

Comments
 (0)