Skip to content

Commit d284083

Browse files
committed
Fix the logic on database modals
1 parent 7e89e1b commit d284083

File tree

6 files changed

+64
-61
lines changed

6 files changed

+64
-61
lines changed

resources/assets/scripts/components/server/components/database/CreateDatabaseModal.vue

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,56 @@
11
<template>
2-
<div>
2+
<Modal :isVisible="isVisible" :dismissable="!showSpinner" v-on:close="closeModal">
33
<MessageBox class="alert error mb-6" :message="errorMessage" v-show="errorMessage.length"/>
44
<h2 class="font-medium text-neutral-900 mb-6">Create a new database</h2>
55
<div class="mb-6">
66
<label class="input-label" for="grid-database-name">Database name</label>
7-
<input id="grid-database-name" type="text" class="input" name="database_name" required
8-
v-model="database"
9-
v-validate="{ alpha_dash: true, max: 100 }"
10-
:class="{ error: errors.has('database_name') }"
7+
<input
8+
id="grid-database-name" type="text" class="input" name="database_name" required
9+
v-model="database"
10+
v-validate="{ alpha_dash: true, max: 100 }"
11+
:class="{ error: errors.has('database_name') }"
1112
>
1213
<p class="input-help error" v-show="errors.has('database_name')">{{ errors.first('database_name') }}</p>
1314
</div>
1415
<div class="mb-6">
1516
<label class="input-label" for="grid-database-remote">Allow connections from</label>
16-
<input id="grid-database-remote" type="text" class="input" name="remote" required
17-
v-model="remote"
18-
v-validate="{ regex: /^[0-9%.]{1,15}$/ }"
19-
:class="{ error: errors.has('remote') }"
17+
<input
18+
id="grid-database-remote" type="text" class="input" name="remote" required
19+
v-model="remote"
20+
v-validate="{ regex: /^[0-9%.]{1,15}$/ }"
21+
:class="{ error: errors.has('remote') }"
2022
>
2123
<p class="input-help error" v-show="errors.has('remote')">{{ errors.first('remote') }}</p>
2224
</div>
2325
<div class="text-right">
24-
<button class="btn btn-secondary btn-sm mr-2" v-on:click.once="$emit('close')">Cancel</button>
25-
<button class="btn btn-primary btn-sm"
26-
:disabled="errors.any() || !canSubmit || showSpinner"
27-
v-on:click="submit"
26+
<button class="btn btn-secondary btn-sm mr-2" v-on:click.once="closeModal">Cancel</button>
27+
<button
28+
class="btn btn-primary btn-sm"
29+
:disabled="errors.any() || !canSubmit || showSpinner"
30+
v-on:click="submit"
2831
>
2932
<span class="spinner white" v-bind:class="{ hidden: !showSpinner }">&nbsp;</span>
3033
<span :class="{ hidden: showSpinner }">
31-
Create
32-
</span>
34+
Create
35+
</span>
3336
</button>
3437
</div>
35-
</div>
38+
</Modal>
3639
</template>
3740

3841
<script lang="ts">
3942
import Vue from 'vue';
4043
import MessageBox from "@/components/MessageBox.vue";
4144
import {createDatabase} from "@/api/server/createDatabase";
45+
import Modal from "@/components/core/Modal.vue";
4246
4347
export default Vue.extend({
4448
name: 'CreateDatabaseModal',
45-
components: {MessageBox},
49+
components: {Modal, MessageBox},
50+
51+
props: {
52+
isVisible: { type: Boolean, default: false },
53+
},
4654
4755
data: function () {
4856
return {
@@ -83,6 +91,14 @@
8391
this.loading = false;
8492
this.showSpinner = false;
8593
});
94+
},
95+
96+
/**
97+
* Closes the modal and resets the entry field.
98+
*/
99+
closeModal: function () {
100+
this.showSpinner = false;
101+
this.$emit('close');
86102
}
87103
},
88104
});

resources/assets/scripts/components/server/components/database/DatabaseRow.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232
</div>
3333
</div>
3434
<DeleteDatabaseModal
35-
:database="database"
36-
:show="showDeleteModal"
37-
v-on:close="showDeleteModal = false"
35+
:database="database"
36+
:isVisible="showDeleteModal"
37+
v-on:close="showDeleteModal = false"
3838
/>
3939
</div>
4040
</template>

resources/assets/scripts/components/server/components/database/DeleteDatabaseModal.vue

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,22 @@
11
<template>
2-
<Modal v-on:close="closeModal" :show="show" :dismissable="!showSpinner">
3-
<transition name="modal">
4-
<div>
5-
<h2 class="font-medium text-neutral-900 mb-6">Delete this database?</h2>
6-
<p class="text-neutral-900 text-sm">This action
7-
<strong>cannot</strong> be undone. This will permanetly delete the
8-
<strong>{{database.name}}</strong> database and remove all associated data.</p>
9-
<div class="mt-6">
10-
<label class="input-label">Confirm database name</label>
11-
<input type="text" class="input" v-model="nameConfirmation"/>
12-
</div>
13-
<div class="mt-6 text-right">
14-
<button class="btn btn-sm btn-secondary mr-2" v-on:click="closeModal">Cancel</button>
15-
<button class="btn btn-sm btn-red" :disabled="disabled" v-on:click="deleteDatabase">
16-
<span class="spinner white" v-bind:class="{ hidden: !showSpinner }">&nbsp;</span>
17-
<span :class="{ hidden: showSpinner }">
18-
Confirm Deletion
19-
</span>
20-
</button>
21-
</div>
22-
</div>
23-
</transition>
2+
<Modal v-on:close="closeModal" :isVisible="isVisible" :dismissable="!showSpinner">
3+
<h2 class="font-medium text-neutral-900 mb-6">Delete this database?</h2>
4+
<p class="text-neutral-900 text-sm">This action
5+
<strong>cannot</strong> be undone. This will permanetly delete the
6+
<strong>{{database.name}}</strong> database and remove all associated data.</p>
7+
<div class="mt-6">
8+
<label class="input-label">Confirm database name</label>
9+
<input type="text" class="input" v-model="nameConfirmation"/>
10+
</div>
11+
<div class="mt-6 text-right">
12+
<button class="btn btn-sm btn-secondary mr-2" v-on:click="closeModal">Cancel</button>
13+
<button class="btn btn-sm btn-red" :disabled="disabled" v-on:click="deleteDatabase">
14+
<span class="spinner white" v-bind:class="{ hidden: !showSpinner }">&nbsp;</span>
15+
<span :class="{ hidden: showSpinner }">
16+
Confirm Deletion
17+
</span>
18+
</button>
19+
</div>
2420
</Modal>
2521
</template>
2622

@@ -33,14 +29,8 @@
3329
name: 'DeleteDatabaseModal',
3430
components: {Modal},
3531
props: {
36-
show: {
37-
type: Boolean,
38-
default: false,
39-
},
40-
database: {
41-
type: Object as () => ServerDatabase,
42-
required: true
43-
},
32+
isVisible: {type: Boolean, default: false },
33+
database: { type: Object as () => ServerDatabase, required: true },
4434
},
4535
4636
data: function () {

resources/assets/scripts/components/server/components/filemanager/modals/CreateFolderModal.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<Modal :isVisible="visible" v-on:close="onModalClose" :showCloseIcon="false" :dismissable="!isLoading">
2+
<Modal :isVisible="visible" v-on:close="onModalClose" :isVisibleCloseIcon="false" :dismissable="!isLoading">
33
<div>
44
<label class="input-label">
55
Directory Name

resources/assets/scripts/components/server/components/filemanager/modals/RenameModal.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<Modal :isVisible="isVisible" v-on:close="closeModal" :showCloseIcon="false" :dismissable="!isLoading">
2+
<Modal :isVisible="isVisible" v-on:close="closeModal" :isVisibleCloseIcon="false" :dismissable="!isLoading">
33
<MessageBox
44
class="alert error mb-8"
55
title="Error"

resources/assets/scripts/components/server/subpages/Databases.vue

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,18 @@
1818
<div>
1919
<button class="btn btn-primary btn-lg" v-on:click="showCreateModal = true">Create new database</button>
2020
</div>
21-
<Modal :isVisible="showCreateModal" v-on:close="showCreateModal = false">
22-
<CreateDatabaseModal
23-
v-on:close="showCreateModal = false"
24-
v-on:database="handleModalCallback"
25-
v-if="showCreateModal"
26-
/>
27-
</modal>
21+
<CreateDatabaseModal
22+
:isVisible="showCreateModal"
23+
v-on:database="handleModalCallback"
24+
v-on:close="showCreateModal = false"
25+
/>
2826
</div>
2927
</div>
3028
</template>
3129

3230
<script lang="ts">
3331
import Vue from 'vue';
3432
import {filter, map} from 'lodash';
35-
import Modal from '@/components/core/Modal.vue';
3633
import CreateDatabaseModal from './../components/database/CreateDatabaseModal.vue';
3734
import Icon from "@/components/core/Icon.vue";
3835
import {ServerDatabase} from "@/api/server/types";
@@ -46,7 +43,7 @@
4643
4744
export default Vue.extend({
4845
name: 'ServerDatabases',
49-
components: {DatabaseRow, CreateDatabaseModal, Modal, Icon},
46+
components: {DatabaseRow, CreateDatabaseModal, Icon},
5047
5148
data: function (): DataStructure {
5249
return {

0 commit comments

Comments
 (0)