-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added unscoped file client to the files components context * wip: created some basic files and stories for new filepicker component * fix some types after require filesclient to be passed in * added file picker state and some basic tests * added file picker context * added missing file client value * updated file picker stories * expanded files context; * remove the size observable and also added a test for file removal and adding of duplicates * added error content component * refactor upload component to not take files client as prop * updated shared file compoennts context value * added test for adding multiple files at once * allow passing in string or array of strings * added some i18n texts * move the creation of a file kinds registry to a common location * set file kinds only once * a bunch of stuff: added title component, using grid, removed responsive on upload controls * refactor layour components to own component using grid, added new i18n texts for empty state prompt * minor copy tweak * added basic story with some files * added file grid and refactored picker to only exist in modal for now * get the css grid algo that we want: auto-fill not auto-fit! * override styling for content area of file * split stories of files * delete commented out code * give the modal a fixed width * fix upload file state, where we do not want a fixed width modal * moved styles down to card, and combined margin removal rules * optimize for filtering files, first pass just filter on names * include xxl * moved debounceTime to rxjs land, added test for filtering behaviour * added story with more images * big ol wip * empty prompt when uploading a file * added pagination * fixed tests and added some comments * address lint * moved copy to i18n and updated size and color of empty error prompt * remove use of css` * remove non existant prop * also reload files * fileUpload -> files * update logic for watching if selected * disambiguate i18n ids * use abort signal and call sendRequest from file$, filtering done server side now, update tests * fix a few off by one errors and hook up the new system to the ui * added test for in flight requests behaviour * update the files example app * fix minor card layout styling to make all cards the same size regardless of text or image conten * added new file picker component * make file cards a bit wider and text a bit smaller so that it wraps... * fix issue of throwing abort error and prematurely setting request to completed... * remove unused import * replace filter i18n * a bunch of cool changes * added export for the file picker component * updated example app to use multiple file upload * added some comments and made images load eagerly in file picker for now... * complete ux for examples * only files that are "READY" should be in the file picker * set loading to false if error * install data-test-subj everywhere! * added some react component tests * remove unused import * fix storybook case * fix up where the files example plugin is listed, moved it to the developer examples area * fix potential flashing of loader by debouncing * do not create new observable on every render * i18n * have only filepicker ctx used in filepicker components * refactor loadImageEagerly -> lazy * useObservable instead of useEffect * factor modal footer to own component and remove css util * use the middle dot luke * copy update in files example app * added filter story Co-authored-by: Kibana Machine <[email protected]>
- Loading branch information
1 parent
ffc8fb9
commit a42f182
Showing
44 changed files
with
1,611 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
x-pack/examples/files_example/public/components/file_picker.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
import type { FunctionComponent } from 'react'; | ||
|
||
import { exampleFileKind } from '../../common'; | ||
|
||
import { FilePicker } from '../imports'; | ||
|
||
interface Props { | ||
onClose: () => void; | ||
onDone: (ids: string[]) => void; | ||
} | ||
|
||
export const MyFilePicker: FunctionComponent<Props> = ({ onClose, onDone }) => { | ||
return <FilePicker kind={exampleFileKind.id} onClose={onClose} onDone={onDone} />; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
x-pack/plugins/files/public/components/file_picker/components/clear_filter_button.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
import React from 'react'; | ||
import type { FunctionComponent } from 'react'; | ||
import useObservable from 'react-use/lib/useObservable'; | ||
import { EuiLink } from '@elastic/eui'; | ||
import { css } from '@emotion/react'; | ||
import { useFilePickerContext } from '../context'; | ||
|
||
import { i18nTexts } from '../i18n_texts'; | ||
|
||
interface Props { | ||
onClick: () => void; | ||
} | ||
|
||
export const ClearFilterButton: FunctionComponent<Props> = ({ onClick }) => { | ||
const { state } = useFilePickerContext(); | ||
const query = useObservable(state.queryDebounced$); | ||
if (!query) { | ||
return null; | ||
} | ||
return ( | ||
<div | ||
css={css` | ||
display: grid; | ||
place-items: center; | ||
`} | ||
> | ||
<EuiLink onClick={onClick}>{i18nTexts.clearFilterButton}</EuiLink> | ||
</div> | ||
); | ||
}; |
37 changes: 37 additions & 0 deletions
37
x-pack/plugins/files/public/components/file_picker/components/error_content.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
import type { FunctionComponent } from 'react'; | ||
import { EuiButton, EuiEmptyPrompt } from '@elastic/eui'; | ||
import { i18nTexts } from '../i18n_texts'; | ||
import { useFilePickerContext } from '../context'; | ||
import { useBehaviorSubject } from '../../use_behavior_subject'; | ||
|
||
interface Props { | ||
error: Error; | ||
} | ||
|
||
export const ErrorContent: FunctionComponent<Props> = ({ error }) => { | ||
const { state } = useFilePickerContext(); | ||
const isLoading = useBehaviorSubject(state.isLoading$); | ||
return ( | ||
<EuiEmptyPrompt | ||
data-test-subj="errorPrompt" | ||
iconType="alert" | ||
iconColor="danger" | ||
titleSize="xs" | ||
title={<h3>{i18nTexts.loadingFilesErrorTitle}</h3>} | ||
body={error.message} | ||
actions={ | ||
<EuiButton disabled={isLoading} onClick={state.retry}> | ||
{i18nTexts.retryButtonLabel} | ||
</EuiButton> | ||
} | ||
/> | ||
); | ||
}; |
5 changes: 5 additions & 0 deletions
5
x-pack/plugins/files/public/components/file_picker/components/file_card.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.filesFilePicker { | ||
.euiCard__content, .euiCard__description { | ||
margin :0; // make the cards a little bit more compact | ||
} | ||
} |
Oops, something went wrong.