-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
replace native dialog with vue modal #1781
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
71 changes: 71 additions & 0 deletions
71
apps/studio/src/components/common/modals/ConfirmationModal.vue
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,71 @@ | ||
<template> | ||
<portal to="modals"> | ||
<modal | ||
class="vue-dialog beekeeper-modal confirmation-modal" | ||
:name="name" | ||
@before-open="beforeOpen" | ||
@before-close="beforeClose" | ||
> | ||
<div class="dialog-content"> | ||
<div class="dialog-c-title"> | ||
{{ title }} | ||
</div> | ||
{{ message }} | ||
</div> | ||
<div class="vue-dialog-buttons"> | ||
<button | ||
class="btn btn-flat" | ||
type="button" | ||
@click.prevent="cancel" | ||
> | ||
Cancel | ||
</button> | ||
<button | ||
class="btn btn-primary" | ||
type="button" | ||
@click.prevent="confirm" | ||
autofocus | ||
> | ||
Confirm | ||
</button> | ||
</div> | ||
</modal> | ||
</portal> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import Vue from "vue"; | ||
|
||
const DEFAULT_TITLE = "Are you sure?"; | ||
const DEFAULT_MESSAGE = "This action cannot be undone."; | ||
|
||
export default Vue.extend({ | ||
data() { | ||
return { | ||
name: Vue.prototype.$confirmModalId, | ||
onConfirm: null, | ||
onCancel: null, | ||
title: "", | ||
message: "", | ||
}; | ||
}, | ||
methods: { | ||
beforeOpen(event: any) { | ||
this.onConfirm = event.params.onConfirm; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't super like this, but I guess it's fine for the confirm dialog. |
||
this.onCancel = event.params.onCancel; | ||
this.title = event.params.title || DEFAULT_TITLE; | ||
this.message = event.params.message || DEFAULT_MESSAGE; | ||
}, | ||
confirm() { | ||
this.$modal.hide(this.name, { confirmed: true }); | ||
}, | ||
cancel() { | ||
this.$modal.hide(this.name, { confirmed: false }); | ||
}, | ||
beforeClose(event: any) { | ||
if (event.params.confirmed) this.onConfirm?.(); | ||
else this.onCancel?.(); | ||
}, | ||
}, | ||
}); | ||
</script> |
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 |
---|---|---|
|
@@ -196,7 +196,7 @@ import QueryRenameForm from '@/components/common/form/QueryRenameForm.vue' | |
this.$root.$emit('favoriteClick', item) | ||
}, | ||
async remove(favorite) { | ||
if (window.confirm("Really delete?")) { | ||
if (await this.$confirm("Really delete?")) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. great work adapting the API for this! |
||
await this.$store.dispatch('data/queries/remove', favorite) | ||
} | ||
}, | ||
|
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,14 @@ | ||
#! /bin/bash | ||
|
||
git grep -a "window\.confirm" apps/studio/src | ||
STATUS=$? | ||
|
||
if [[ $STATUS -eq 0 ]] | ||
then | ||
echo "Found native dialogs. Please avoid using the native dialogs." | ||
exit 1; | ||
|
||
else | ||
echo "OK. No native dialogs found." | ||
exit 0 | ||
fi |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a comment that we need to get this from the prototype because we need it to call the
modal
function?