Skip to content
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

Remove <Delay /> component #4132

Merged
merged 6 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions catalog/app/components/Placeholder/Placeholder.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import * as React from 'react'
import * as M from '@material-ui/core'

import Delay from 'utils/Delay'

interface PlaceholderProps extends M.BoxProps {
delay?: number
}

export default function Placeholder({ delay, ...props }: PlaceholderProps) {
export default function Placeholder({ delay = 1000, ...props }: PlaceholderProps) {
return (
<M.Box
alignItems="center"
Expand All @@ -17,7 +15,9 @@ export default function Placeholder({ delay, ...props }: PlaceholderProps) {
color="common.white"
{...props}
>
<Delay ms={delay}>{() => <M.CircularProgress size={120} color="inherit" />}</Delay>
<M.Fade in style={{ transitionDelay: `${delay}ms` }}>
<M.CircularProgress size={120} color="inherit" />
</M.Fade>
</M.Box>
)
}
21 changes: 8 additions & 13 deletions catalog/app/components/SearchResults/SearchResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import * as AWS from 'utils/AWS'
import AsyncResult from 'utils/AsyncResult'
import { useBucketExistence } from 'utils/BucketCache'
import * as Data from 'utils/Data'
import Delay from 'utils/Delay'
import * as NamedRoutes from 'utils/NamedRoutes'
import StyledLink, { linkStyle } from 'utils/StyledLink'
import { readableBytes } from 'utils/string'
Expand Down Expand Up @@ -575,18 +574,14 @@ export function Alt({ className, ...props }: $TSFixMe) {
export function Progress({ children }: $TSFixMe) {
return (
<Alt>
<Delay alwaysRender>
{(ready) => (
<M.Fade in={ready}>
<M.Box display="flex" alignItems="center">
<M.Box pr={2}>
<M.CircularProgress size={24} />
</M.Box>
<M.Typography variant="body1">{children}</M.Typography>
</M.Box>
</M.Fade>
)}
</Delay>
<M.Fade in style={{ transitionDelay: '1000ms' }}>
<M.Box display="flex" alignItems="center">
<M.Box pr={2}>
<M.CircularProgress size={24} />
</M.Box>
<M.Typography variant="body1">{children}</M.Typography>
</M.Box>
</M.Fade>
</Alt>
)
}
Expand Down
31 changes: 15 additions & 16 deletions catalog/app/containers/Admin/Buckets/Buckets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import * as Notifications from 'containers/Notifications'
import type * as Model from 'model'
import * as APIConnector from 'utils/APIConnector'
import Delay from 'utils/Delay'
import type FormSpec from 'utils/FormSpec'
import * as GQL from 'utils/GraphQL'
import MetaTitle from 'utils/MetaTitle'
Expand Down Expand Up @@ -586,7 +585,11 @@
/>
)}
</div>
{state.submitting && <Delay>{() => <M.CircularProgress size={24} />}</Delay>}
{state.submitting && (
<M.Fade in style={{ transitionDelay: '1000ms' }}>

Check warning on line 589 in catalog/app/containers/Admin/Buckets/Buckets.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/containers/Admin/Buckets/Buckets.tsx#L589

Added line #L589 was not covered by tests
<M.CircularProgress size={24} />
</M.Fade>
)}
<M.Button
className={classes.button}
onClick={() => reset()}
Expand Down Expand Up @@ -1358,13 +1361,11 @@
/>
)}
{submitting && (
<Delay>
{() => (
<M.Box flexGrow={1} display="flex" pl={2}>
<M.CircularProgress size={24} />
</M.Box>
)}
</Delay>
<M.Fade in style={{ transitionDelay: '1000ms' }}>

Check warning on line 1364 in catalog/app/containers/Admin/Buckets/Buckets.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/containers/Admin/Buckets/Buckets.tsx#L1364

Added line #L1364 was not covered by tests
<M.Box flexGrow={1} display="flex" pl={2}>
<M.CircularProgress size={24} />
</M.Box>
</M.Fade>
)}
<M.Button
onClick={() => back('cancel')}
Expand Down Expand Up @@ -1478,13 +1479,11 @@
)}
<M.DialogActions>
{submitting && (
<Delay>
{() => (
<M.Box flexGrow={1} display="flex" pl={2}>
<M.CircularProgress size={24} />
</M.Box>
)}
</Delay>
<M.Fade in style={{ transitionDelay: '1000ms' }}>

Check warning on line 1482 in catalog/app/containers/Admin/Buckets/Buckets.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/containers/Admin/Buckets/Buckets.tsx#L1482

Added line #L1482 was not covered by tests
<M.Box flexGrow={1} display="flex" pl={2}>
<M.CircularProgress size={24} />
</M.Box>
</M.Fade>
)}
{!submitting && !!error && (
<M.Box flexGrow={1} display="flex" alignItems="center" pl={2}>
Expand Down
17 changes: 6 additions & 11 deletions catalog/app/containers/Bucket/PackageDialog/MetaInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { JsonValue, ValidationErrors } from 'components/JsonEditor/constants'
import JsonValidationErrors from 'components/JsonValidationErrors'
import MetadataEditor from 'components/MetadataEditor'
import * as Notifications from 'containers/Notifications'
import Delay from 'utils/Delay'
import useDragging from 'utils/dragging'
import { JsonSchema } from 'utils/json-schema'
import * as spreadsheets from 'utils/spreadsheets'
Expand Down Expand Up @@ -377,16 +376,12 @@ export const MetaInput = React.forwardRef<HTMLDivElement, MetaInputProps>(

{locked && (
<div className={classes.overlay}>
<Delay ms={500} alwaysRender>
{(ready) => (
<M.Fade in={ready}>
<div className={classes.overlayContents}>
<M.CircularProgress size={20} className={classes.overlayProgress} />
<div className={classes.overlayText}>Reading file contents</div>
</div>
</M.Fade>
)}
</Delay>
<M.Fade in style={{ transitionDelay: '500ms' }}>
<div className={classes.overlayContents}>
<M.CircularProgress size={20} className={classes.overlayProgress} />
<div className={classes.overlayText}>Reading file contents</div>
</div>
</M.Fade>
</div>
)}

Expand Down
40 changes: 17 additions & 23 deletions catalog/app/containers/Bucket/PackageDialog/SubmitSpinner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

import * as M from '@material-ui/core'

import Delay from 'utils/Delay'

interface SubmitSpinnerProps {
children?: React.ReactNode
value?: number
Expand All @@ -14,28 +12,24 @@
const hasValue = R.is(Number, value) && value! < 100

return (
<Delay ms={200} alwaysRender>
{(ready) => (
<M.Fade in={ready}>
<M.Box flexGrow={1} display="flex" alignItems="center" pl={2}>
<M.CircularProgress
size={24}
variant={hasValue ? 'determinate' : 'indeterminate'}
value={hasValue ? value! * 0.9 : undefined}
/>
<M.Fade in style={{ transitionDelay: '200ms' }}>
<M.Box flexGrow={1} display="flex" alignItems="center" pl={2}>
<M.CircularProgress
size={24}
variant={hasValue ? 'determinate' : 'indeterminate'}
value={hasValue ? value! * 0.9 : undefined}
/>

{!!children && (
<>
<M.Box pl={1} />
{!!children && (
<>

Check warning on line 24 in catalog/app/containers/Bucket/PackageDialog/SubmitSpinner.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/containers/Bucket/PackageDialog/SubmitSpinner.tsx#L24

Added line #L24 was not covered by tests
<M.Box pl={1} />

<M.Typography variant="body2" color="textSecondary">
{children}
</M.Typography>
</>
)}
</M.Box>
</M.Fade>
)}
</Delay>
<M.Typography variant="body2" color="textSecondary">
{children}
</M.Typography>
</>
)}
</M.Box>
</M.Fade>
)
}
9 changes: 7 additions & 2 deletions catalog/app/containers/NavBar/BucketSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import Autocomplete from '@material-ui/lab/Autocomplete'
import BucketIcon from 'components/BucketIcon'
import * as style from 'constants/style'
import * as BucketConfig from 'utils/BucketConfig'
import Delay from 'utils/Delay'
import * as NamedRoutes from 'utils/NamedRoutes'

const normalizeBucket = R.pipe(
Expand Down Expand Up @@ -221,7 +220,13 @@ function BucketSelect({ cancel, forwardedRef, ...props }) {

export default React.forwardRef(function BucketSelectSuspended(props, ref) {
return (
<React.Suspense fallback={<Delay>{() => <M.CircularProgress />}</Delay>}>
<React.Suspense
fallback={
<M.Fade in style={{ transitionDelay: '1000ms' }}>
<M.CircularProgress />
</M.Fade>
}
>
<BucketSelect {...props} forwardedRef={ref} />
</React.Suspense>
)
Expand Down
11 changes: 3 additions & 8 deletions catalog/app/containers/NavBar/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import * as M from '@material-ui/core'
import { fade } from '@material-ui/core/styles/colorManipulator'

import cfg from 'constants/config'
import Delay from 'utils/Delay'

import { useNavBar, expandAnimationDuration } from './Provider'
import Suggestions from './Suggestions'
Expand Down Expand Up @@ -172,13 +171,9 @@ function SearchNotAvailable() {

function DelayedProgress() {
return (
<Delay alwaysRender>
{(ready) => (
<M.Fade in={ready}>
<M.CircularProgress />
</M.Fade>
)}
</Delay>
<M.Fade in style={{ transitionDelay: '1000ms' }}>
<M.CircularProgress />
</M.Fade>
)
}

Expand Down
19 changes: 0 additions & 19 deletions catalog/app/utils/Delay.tsx

This file was deleted.