-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
prompt on leave feature ✅ Closes: COMUI-1289
- Loading branch information
Gavin Everett
authored and
Gavin Everett
committed
Mar 1, 2023
1 parent
b40fff4
commit 270b039
Showing
9 changed files
with
221 additions
and
14 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { boolean, constant, Decoder, object, optional, string } from 'decoders'; | ||
import { labeledDecoder, LabeledMsg } from './LabeledMsg'; | ||
|
||
/** A prompt on leave dialog to be displayed | ||
* by the host application. If the host application receives a message with the shouldPrompt field set to true | ||
* a dialog will be displayed asking the user for confirmation before navigating. | ||
*/ | ||
export interface PromptOnLeave { | ||
/** The host application will ask the user for confirmation before | ||
* leaving the current page if it has received a message with the shouldPrompt field set to true. | ||
*/ | ||
shouldPrompt: boolean; | ||
/** Optional message to prompt the user with. */ | ||
message?: string; | ||
} | ||
|
||
/** | ||
* A message used to request a prompt on leave dialog to be displayed in the host app. | ||
*/ | ||
export interface LabeledPrompt | ||
extends LabeledMsg<'promptOnLeave', PromptOnLeave> { | ||
/** Message identifier */ | ||
msgType: 'promptOnLeave'; | ||
/** Message details */ | ||
msg: PromptOnLeave; | ||
} | ||
|
||
const decoder: Decoder<LabeledPrompt> = labeledDecoder( | ||
constant<'promptOnLeave'>('promptOnLeave'), | ||
object({ | ||
shouldPrompt: boolean, | ||
message: optional(string) | ||
}) | ||
); | ||
|
||
export { decoder }; |
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