-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds multi-item view and bulk features
- Loading branch information
1 parent
13dad07
commit 7fec2ff
Showing
30 changed files
with
2,160 additions
and
621 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import * as ReactDOM from "react-dom"; | ||
import * as React from "react"; | ||
import Dialog, { DialogFooter, DialogType } from "@fluentui/react/lib/Dialog"; | ||
import { DefaultButton } from "@fluentui/react/lib/Button"; | ||
import * as strings from "RetentionControlsCommandSetStrings"; | ||
|
||
export default class AlertDialogManager { | ||
private domElement: HTMLDivElement | null = null; | ||
private onClosedCallback: (confirmed?: boolean) => void; | ||
|
||
constructor(private title: string, private subText: string, private buttonText?: string) { | ||
} | ||
|
||
public async close(confirmed?: boolean): Promise<void> { | ||
if (this.domElement) { | ||
ReactDOM.unmountComponentAtNode(this.domElement); | ||
this.domElement.remove(); | ||
this.domElement = null; | ||
} | ||
|
||
if (this.onClosedCallback !== undefined) { | ||
this.onClosedCallback(confirmed); | ||
} | ||
} | ||
|
||
public onClosed(callback: (confirmed?:boolean)=>void): void { | ||
this.onClosedCallback = callback; | ||
} | ||
|
||
public async show(): Promise<void> { | ||
this.domElement = document.createElement('div'); | ||
document.body.appendChild(this.domElement); | ||
|
||
const close = async (confirmed?: boolean): Promise<void> => { | ||
await this.close(confirmed); | ||
}; | ||
|
||
const reactElement = <Dialog | ||
hidden={false} | ||
onDismiss={() => close()} | ||
dialogContentProps={{ | ||
type: DialogType.normal, | ||
showCloseButton: false, | ||
title: this.title, | ||
subText: this.subText, | ||
}}> | ||
<DialogFooter> | ||
{ <DefaultButton onClick={() => close(false)} text={this.buttonText ?? strings.CloseModal} /> } | ||
</DialogFooter> | ||
</Dialog> | ||
|
||
ReactDOM.render(reactElement, | ||
this.domElement); | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
src/extensions/retentionControls/ConfirmationDialogManager.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import * as ReactDOM from "react-dom"; | ||
import * as React from "react"; | ||
import Dialog, { DialogFooter, DialogType } from "@fluentui/react/lib/Dialog"; | ||
import { DefaultButton, PrimaryButton } from "@fluentui/react/lib/Button"; | ||
import * as strings from "RetentionControlsCommandSetStrings"; | ||
|
||
export default class ConfirmationDialogManager { | ||
private domElement: HTMLDivElement | null = null; | ||
private onClosedCallback: (confirmed?: boolean) => void; | ||
|
||
constructor(private title: string, private subText: string, private primaryButtonText?: string, private secondaryButtonText?: string, private showPrimaryButton: boolean = true, private showSecondaryButton: boolean = true) { | ||
} | ||
|
||
public async close(confirmed?: boolean): Promise<void> { | ||
if (this.domElement) { | ||
ReactDOM.unmountComponentAtNode(this.domElement); | ||
this.domElement.remove(); | ||
this.domElement = null; | ||
} | ||
|
||
if (this.onClosedCallback !== undefined) { | ||
this.onClosedCallback(confirmed); | ||
} | ||
} | ||
|
||
public onClosed(callback: (confirmed?:boolean)=>void): void { | ||
this.onClosedCallback = callback; | ||
} | ||
|
||
public async show(): Promise<void> { | ||
this.domElement = document.createElement('div'); | ||
document.body.appendChild(this.domElement); | ||
|
||
const close = async (confirmed?: boolean): Promise<void> => { | ||
await this.close(confirmed); | ||
}; | ||
|
||
const reactElement = <Dialog | ||
hidden={false} | ||
onDismiss={() => close()} | ||
dialogContentProps={{ | ||
type: DialogType.normal, | ||
showCloseButton: true, | ||
title: this.title, | ||
closeButtonAriaLabel: 'Close', | ||
subText: this.subText, | ||
}}> | ||
<DialogFooter> | ||
{ this.showPrimaryButton ? <PrimaryButton onClick={() => close(true)} text={this.primaryButtonText ?? strings.Yes} /> : <></> } | ||
{ this.showSecondaryButton ? <DefaultButton onClick={() => close(false)} text={this.secondaryButtonText ?? strings.No} /> : <></> } | ||
</DialogFooter> | ||
</Dialog> | ||
|
||
ReactDOM.render(reactElement, | ||
this.domElement); | ||
} | ||
} |
Oops, something went wrong.