Skip to content

Commit 43f8ec2

Browse files
committed
Show a message when the spinner is displayed
1 parent 93cab68 commit 43f8ec2

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

resources/scripts/components/elements/SpinnerOverlay.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,17 @@ interface Props {
1010
backgroundOpacity?: number;
1111
}
1212

13-
const SpinnerOverlay = ({ size, fixed, visible, backgroundOpacity }: Props) => (
13+
const SpinnerOverlay: React.FC<Props> = ({ size, fixed, visible, backgroundOpacity, children }) => (
1414
<Fade timeout={150} in={visible} unmountOnExit>
1515
<div
1616
css={[
17-
tw`top-0 left-0 flex items-center justify-center w-full h-full rounded`,
17+
tw`top-0 left-0 flex items-center justify-center w-full h-full rounded flex-col`,
1818
!fixed ? tw`absolute` : tw`fixed`,
1919
]}
2020
style={{ zIndex: 9999, background: `rgba(0, 0, 0, ${backgroundOpacity || 0.45})` }}
2121
>
2222
<Spinner size={size}/>
23+
{children && (typeof children === 'string' ? <p css={tw`mt-4 text-neutral-400`}>{children}</p> : children)}
2324
</div>
2425
</Fade>
2526
);

resources/scripts/components/server/files/MassActionsBar.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState } from 'react';
1+
import React, { useEffect, useState } from 'react';
22
import tw from 'twin.macro';
33
import Button from '@/components/elements/Button';
44
import { useFormikContext } from 'formik';
@@ -19,13 +19,19 @@ const MassActionsBar = () => {
1919
const { mutate } = useFileManagerSwr();
2020
const { clearFlashes, clearAndAddHttpError } = useFlash();
2121
const [ loading, setLoading ] = useState(false);
22+
const [ loadingMessage, setLoadingMessage ] = useState('');
2223
const [ showConfirm, setShowConfirm ] = useState(false);
2324
const { values, setFieldValue } = useFormikContext<{ selectedFiles: string[] }>();
2425
const directory = ServerContext.useStoreState(state => state.files.directory);
2526

27+
useEffect(() => {
28+
if (!loading) setLoadingMessage('');
29+
}, [ loading ]);
30+
2631
const onClickCompress = () => {
2732
setLoading(true);
2833
clearFlashes('files');
34+
setLoadingMessage('Archiving files...');
2935

3036
compressFiles(uuid, directory, values.selectedFiles)
3137
.then(() => mutate())
@@ -38,6 +44,7 @@ const MassActionsBar = () => {
3844
setLoading(true);
3945
setShowConfirm(false);
4046
clearFlashes('files');
47+
setLoadingMessage('Deleting files...');
4148

4249
deleteFiles(uuid, directory, values.selectedFiles)
4350
.then(() => {
@@ -54,7 +61,9 @@ const MassActionsBar = () => {
5461
return (
5562
<Fade timeout={75} in={values.selectedFiles.length > 0} unmountOnExit>
5663
<div css={tw`fixed bottom-0 z-50 left-0 right-0 flex justify-center`}>
57-
<SpinnerOverlay visible={loading} size={'large'} fixed/>
64+
<SpinnerOverlay visible={loading} size={'large'} fixed>
65+
{loadingMessage}
66+
</SpinnerOverlay>
5867
<ConfirmationModal
5968
visible={showConfirm}
6069
title={'Delete these files?'}

0 commit comments

Comments
 (0)