-
-
Notifications
You must be signed in to change notification settings - Fork 554
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[5.x] Add ability to reset namespaced blueprints (#9327)
Co-authored-by: Jason Varga <[email protected]>
- Loading branch information
1 parent
9fd729f
commit ceb4096
Showing
10 changed files
with
199 additions
and
0 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
102 changes: 102 additions & 0 deletions
102
resources/js/components/blueprints/BlueprintResetter.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,102 @@ | ||
<template> | ||
<confirmation-modal | ||
v-if="resetting" | ||
:title="modalTitle" | ||
:bodyText="modalBody" | ||
:buttonText="__('Reset')" | ||
:danger="true" | ||
@confirm="confirmed" | ||
@cancel="cancel" | ||
> | ||
</confirmation-modal> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
props: { | ||
resource: { | ||
type: Object | ||
}, | ||
resourceTitle: { | ||
type: String | ||
}, | ||
route: { | ||
type: String, | ||
}, | ||
redirect: { | ||
type: String | ||
}, | ||
reload: { | ||
type: Boolean | ||
} | ||
}, | ||
data() { | ||
return { | ||
resetting: false, | ||
redirectFromServer: null, | ||
} | ||
}, | ||
computed: { | ||
title() { | ||
return data_get(this.resource, 'title', this.resourceTitle); | ||
}, | ||
modalTitle() { | ||
return __('Reset :resource', {resource: this.title}); | ||
}, | ||
modalBody() { | ||
return __('Are you sure you want to reset this item?'); | ||
}, | ||
resetUrl() { | ||
let url = data_get(this.resource, 'reset_url', this.route); | ||
if (! url) console.error('BlueprintResetter cannot find reset url'); | ||
return url; | ||
}, | ||
redirectUrl() { | ||
return this.redirect || this.redirectFromServer; | ||
}, | ||
}, | ||
methods: { | ||
confirm() { | ||
this.resetting = true; | ||
}, | ||
confirmed() { | ||
this.$axios.delete(this.resetUrl) | ||
.then(response => { | ||
this.redirectFromServer = data_get(response, 'data.redirect'); | ||
this.success(); | ||
}) | ||
.catch(() => { | ||
this.$toast.error(__('Something went wrong')); | ||
}); | ||
}, | ||
success() { | ||
if (this.redirectUrl) { | ||
location.href = this.redirectUrl; | ||
return; | ||
} | ||
if (this.reload) { | ||
location.reload(); | ||
return; | ||
} | ||
this.$toast.success(__('Reset')); | ||
this.$emit('reset'); | ||
}, | ||
cancel() { | ||
this.resetting = false; | ||
} | ||
} | ||
} | ||
</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
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,20 @@ | ||
<?php | ||
|
||
namespace Statamic\Events; | ||
|
||
use Statamic\Contracts\Git\ProvidesCommitMessage; | ||
|
||
class BlueprintReset extends Event implements ProvidesCommitMessage | ||
{ | ||
public $blueprint; | ||
|
||
public function __construct($blueprint) | ||
{ | ||
$this->blueprint = $blueprint; | ||
} | ||
|
||
public function commitMessage() | ||
{ | ||
return __('Blueprint reset', [], config('statamic.git.locale')); | ||
} | ||
} |
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