Skip to content

Commit

Permalink
fix: reintroduce LoadingButton component to fix creation modal subm…
Browse files Browse the repository at this point in the history
…ission

This PR addresses the issue where the removal of `LoadingButton` since Nova 4.28 prevented submission in the creation modal. The component has been restored under a new name, resolving issue #92.
  • Loading branch information
alancolant committed Nov 20, 2023
1 parent 05e2ad9 commit 92b1577
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dist/js/tool.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions resources/js/components/CreateTokenModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@
{{ __("Cancel") }}
</LinkButton>

<LoadingButton
<SanctumLoadingButton
ref="confirmButton"
:processing="false"
:disabled="false"
component="DefaultButton"
type="submit"
>
{{ __("Create New Token") }}
</LoadingButton>
</SanctumLoadingButton>
</div>
</ModalFooter>
</form>
Expand Down
53 changes: 53 additions & 0 deletions resources/js/components/SanctumLoadingButton.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<template>
<component v-bind="{ size, align, ...$attrs }" :is="component" ref="button">
<span :class="{ invisible: processing || loading }">
<slot />
</span>

<span
v-if="processing || loading"
class="absolute"
style="top: 50%; left: 50%; transform: translate(-50%, -50%)"
>
<Loader class="text-white" width="32" />
</span>
</component>
</template>

<script>
export default {
props: {
size: {
type: String,
default: 'lg',
},
align: {
type: String,
default: 'center',
validator: v => ['left', 'center'].includes(v),
},
loading: {
type: Boolean,
default: false,
},
processing: {
type: Boolean,
default: false,
},
component: {
type: String,
default: 'DefaultButton',
},
},
methods: {
focus() {
this.$refs.button.focus()
},
},
}
</script>
4 changes: 4 additions & 0 deletions resources/js/tool.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import CreatedTokenModal from "./components/CreatedTokenModal";
import DeleteTokenModal from "./components/DeleteTokenModal";
import NoTokens from "./components/NoTokens";
import TokenRow from "./components/TokenRow";
import SanctumLoadingButton from "./components/SanctumLoadingButton.vue";

Nova.booting((app, _store) => {
app.component("SanctumTokens", SanctumTokens);
Expand All @@ -12,4 +13,7 @@ Nova.booting((app, _store) => {
app.component("DeleteTokenModal", DeleteTokenModal);
app.component("NoTokens", NoTokens);
app.component("TokenRow", TokenRow);

// Fix because it was deleted from laravel nova core since 3.28
app.component("SanctumLoadingButton", SanctumLoadingButton);
});

0 comments on commit 92b1577

Please sign in to comment.