Skip to content

Commit

Permalink
disable button while extracting archive
Browse files Browse the repository at this point in the history
  • Loading branch information
jrief committed Oct 12, 2024
1 parent 897fdfd commit cf30b1c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 5 additions & 2 deletions client/components/editor/Archive.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import React, {Fragment} from 'react';
import React, {Fragment, useState} from 'react';
import FileDetails from 'finder/FileDetails';
import UnarchiveIcon from '../../icons/unarchive.svg';


export default function Archive(props) {
const {settings} = props;
const [extracting, setExtracting] = useState(false);

async function extractArchive() {
setExtracting(true);
const fetchUrl = `${settings.base_url}${settings.file_id}/unarchive`;
const response = await fetch(fetchUrl, {
method: 'POST',
Expand All @@ -20,11 +22,12 @@ export default function Archive(props) {
} else {
console.error(response);
}
// setUnarchiving(false); // why would someone extract an archive twice?
}

const controlButtons = [
<Fragment key="extract-archive">
<button type="button" onClick={extractArchive}><UnarchiveIcon/>{gettext("Extract archive")}</button>
<button type="button" disabled={extracting} onClick={extractArchive}><UnarchiveIcon/>{gettext("Extract archive")}</button>
</Fragment>
];

Expand Down
4 changes: 4 additions & 0 deletions client/finder-admin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,10 @@ $active-rectangle: rgb(210, 210, 112);
&:hover {
background: var(--default-button-hover-bg);
}
&[disabled] {
opacity: 0.4;
cursor: not-allowed;
}

svg {
margin-right: 0.5rem;
Expand Down

0 comments on commit cf30b1c

Please sign in to comment.