Skip to content

Commit

Permalink
Fixed multiple media files deletion (#2434)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsorohova authored Mar 13, 2024
1 parent 43f34bd commit 02a0c07
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/admin/help/helpModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class HelpModal extends React.Component<HelpModalProps, HelpModalState> {
<ul>
<li><Text block><Link href="https://aka.ms/apimdocs/portal/cors" target="_blank">Enable CORS</Link></Text></li>
<li><Text block><Link href="https://aka.ms/apimdocs/portal/access" target="_blank">Secure access to the API Management developer portal</Link></Text></li>
<li><Text block><Link href="https://aka.ms/apimdocs/portalcustomization" target="_blank">Add custom features to the developer portal</Link></Text></li>
<li><Text block><Link href="https://aka.ms/apimdocs/portal/customization" target="_blank">Add custom features to the developer portal</Link></Text></li>
</ul>

<Text as="h3" block variant="large" styles={headerStyles}>Give feedback</Text>
Expand Down
7 changes: 5 additions & 2 deletions src/admin/media/mediaModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,10 @@ export class MediaModal extends React.Component<MediaModalProps, MediaModalState
}

deleteMedia = async (): Promise<void> => {
await Promise.all(this.state.selectedFiles.map(async file => await this.mediaService.deleteMedia(file)));

for (const file of this.state.selectedFiles) {
await this.mediaService.deleteMedia(file);
}

this.setState({ selectedFiles: [], showDeleteConfirmation: false });
this.eventManager.dispatchEvent('onSaveChanges');
this.searchMedia();
Expand Down Expand Up @@ -183,6 +185,7 @@ export class MediaModal extends React.Component<MediaModalProps, MediaModalState
<IconButton
iconProps={{ iconName: 'CheckMark' }}
onClick={() => this.renameMedia(mediaItem)}
disabled={this.state.fileNewName === ''}
/>
<IconButton
iconProps={{ iconName: 'Cancel' }}
Expand Down
26 changes: 23 additions & 3 deletions src/admin/utils/components/deleteConfirmationOverlay.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { Stack, Layer, Overlay, Popup, mergeStyleSets, DefaultButton, FocusTrapZone, PrimaryButton } from '@fluentui/react';
import { Stack, Layer, Overlay, Popup, mergeStyleSets, DefaultButton, FocusTrapZone, PrimaryButton, Spinner } from '@fluentui/react';

const popupStyles = mergeStyleSets({
root: {
Expand All @@ -21,13 +21,25 @@ const popupStyles = mergeStyleSets({
},
});

interface DeleteConfirmationState {
isLoading: boolean
}

interface DeleteConfirmationProps {
deleteItemTitle: string,
onConfirm: () => void,
onDismiss: () => void
}

export class DeleteConfirmationOverlay extends React.Component<DeleteConfirmationProps, {}> {
export class DeleteConfirmationOverlay extends React.Component<DeleteConfirmationProps, DeleteConfirmationState> {
constructor(props: DeleteConfirmationProps) {
super(props);

this.state = {
isLoading: false
}
}

render(): JSX.Element {
return <>
<Layer>
Expand All @@ -41,9 +53,17 @@ export class DeleteConfirmationOverlay extends React.Component<DeleteConfirmatio
<Overlay onClick={this.props.onDismiss} />
<FocusTrapZone style={{ position: 'unset' }}>
<div role="document" className={popupStyles.content}>
{this.state.isLoading && <Spinner className="spinner-modal" />}
<p>Are you sure you want to delete {this.props.deleteItemTitle}?</p>
<Stack horizontal tokens={{ childrenGap: 20 }}>
<PrimaryButton onClick={this.props.onConfirm}>Yes</PrimaryButton>
<PrimaryButton
onClick={() => {
this.setState({ isLoading: true });
this.props.onConfirm();
}}
>
Yes
</PrimaryButton>
<DefaultButton onClick={this.props.onDismiss}>No</DefaultButton>
</Stack>
</div>
Expand Down
10 changes: 10 additions & 0 deletions src/themes/designer/styles/admin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,16 @@
font-weight: 600;
}

.spinner-modal {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
background-color: rgba(0, 0, 0, 0.4);
z-index: 10;
}

// CHECK THIS!!!!!
// .toolbox-position-right-top {
// display: none !important;
Expand Down

0 comments on commit 02a0c07

Please sign in to comment.