mirror of https://github.com/grafana/grafana
FolderPicker: Make lazy in prep for exposing publicly (#100118)
* Make lazy NestedFolderPicker * Change permission prop to use string union instead of enum * reword commentpull/100124/head
parent
39d94eabcd
commit
0ca1febb77
@ -0,0 +1,16 @@ |
|||||||
|
import { Suspense, lazy } from 'react'; |
||||||
|
|
||||||
|
import { FolderPickerSkeleton } from './Skeleton'; |
||||||
|
|
||||||
|
const SuspendingNestedFolderPicker = lazy(() => |
||||||
|
import('./NestedFolderPicker').then((module) => ({ default: module.NestedFolderPicker })) |
||||||
|
); |
||||||
|
|
||||||
|
// Lazily load folder picker, is what is exposed to plugins through @grafana/runtime
|
||||||
|
export const LazyFolderPicker = (props: Parameters<typeof SuspendingNestedFolderPicker>[0]) => { |
||||||
|
return ( |
||||||
|
<Suspense fallback={<FolderPickerSkeleton />}> |
||||||
|
<SuspendingNestedFolderPicker {...props} /> |
||||||
|
</Suspense> |
||||||
|
); |
||||||
|
}; |
@ -0,0 +1,36 @@ |
|||||||
|
import { css } from '@emotion/css'; |
||||||
|
import Skeleton from 'react-loading-skeleton'; |
||||||
|
|
||||||
|
import type { GrafanaTheme2 } from '@grafana/data'; |
||||||
|
import { getInputStyles, useStyles2 } from '@grafana/ui'; |
||||||
|
|
||||||
|
// This component is used as a fallback for codesplitting, so aim to keep
|
||||||
|
// the bundle size of it as small as possible :)
|
||||||
|
export function FolderPickerSkeleton() { |
||||||
|
const styles = useStyles2(getStyles); |
||||||
|
|
||||||
|
return ( |
||||||
|
<div className={styles.wrapper}> |
||||||
|
<div className={styles.inputWrapper}> |
||||||
|
<button type="button" className={styles.fakeInput} aria-disabled> |
||||||
|
<Skeleton width={100} /> |
||||||
|
</button> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
const getStyles = (theme: GrafanaTheme2) => { |
||||||
|
const baseStyles = getInputStyles({ theme }); |
||||||
|
|
||||||
|
return { |
||||||
|
wrapper: baseStyles.wrapper, |
||||||
|
inputWrapper: baseStyles.inputWrapper, |
||||||
|
fakeInput: css([ |
||||||
|
baseStyles.input, |
||||||
|
{ |
||||||
|
textAlign: 'left', |
||||||
|
}, |
||||||
|
]), |
||||||
|
}; |
||||||
|
}; |
Loading…
Reference in new issue