From ac037c773ef5f15372c6999445a2efe00034c0c0 Mon Sep 17 00:00:00 2001
From: Zephyrrus <krisztian1997@gmail.com>
Date: Mon, 29 Jun 2020 20:02:47 +0300
Subject: fix: Remove hero and hero body and use sections and containers
 instead

Hero is meant to be used as a full-width banner to showcare or present somethign, not to contain the entire content of the webpage
---
 src/site/pages/dashboard/admin/user/_id.vue | 72 ++++++++++++++---------------
 1 file changed, 35 insertions(+), 37 deletions(-)

(limited to 'src/site/pages/dashboard/admin/user/_id.vue')

diff --git a/src/site/pages/dashboard/admin/user/_id.vue b/src/site/pages/dashboard/admin/user/_id.vue
index 7703b1c..2a56c34 100644
--- a/src/site/pages/dashboard/admin/user/_id.vue
+++ b/src/site/pages/dashboard/admin/user/_id.vue
@@ -2,50 +2,48 @@
 	.underline { text-decoration: underline; }
 </style>
 <template>
-	<section class="hero is-fullheight dashboard">
-		<div class="hero-body">
-			<div class="container">
-				<div class="columns">
-					<div class="column is-narrow">
-						<Sidebar />
-					</div>
-					<div class="column">
-						<h2 class="subtitle">User details</h2>
-						<hr>
-
-						<b-field label="User Id"
-							horizontal>
-							<span>{{ user.id }}</span>
-						</b-field>
+	<section class="section is-fullheight dashboard">
+		<div class="container">
+			<div class="columns">
+				<div class="column is-narrow">
+					<Sidebar />
+				</div>
+				<div class="column">
+					<h2 class="subtitle">User details</h2>
+					<hr>
 
-						<b-field label="Username"
-							horizontal>
-							<span>{{ user.username }}</span>
-						</b-field>
+					<b-field label="User Id"
+						horizontal>
+						<span>{{ user.id }}</span>
+					</b-field>
 
-						<b-field label="Enabled"
-							horizontal>
-							<span>{{ user.enabled }}</span>
-						</b-field>
+					<b-field label="Username"
+						horizontal>
+						<span>{{ user.username }}</span>
+					</b-field>
 
-						<b-field label="Registered"
-							horizontal>
-							<span><timeago :since="user.createdAt" /></span>
-						</b-field>
+					<b-field label="Enabled"
+						horizontal>
+						<span>{{ user.enabled }}</span>
+					</b-field>
 
-						<b-field label="Files"
-							horizontal>
-							<span>{{ files.length }}</span>
-						</b-field>
+					<b-field label="Registered"
+						horizontal>
+						<span><timeago :since="user.createdAt" /></span>
+					</b-field>
 
-						<div class="mb2 mt2 text-center">
-							<button class="button is-danger"
-								@click="promptDisableUser">Disable user</button>
-						</div>
+					<b-field label="Files"
+						horizontal>
+						<span>{{ files.length }}</span>
+					</b-field>
 
-						<Grid v-if="files.length"
-							:files="files" />
+					<div class="mb2 mt2 text-center">
+						<button class="button is-danger"
+							@click="promptDisableUser">Disable user</button>
 					</div>
+
+					<Grid v-if="files.length"
+						:files="files" />
 				</div>
 			</div>
 		</div>
-- 
cgit v1.2.3


From 92be4504ccb8f6d918013e5c33870858cd22376a Mon Sep 17 00:00:00 2001
From: Zephyrrus <krisztian1997@gmail.com>
Date: Sat, 4 Jul 2020 03:26:35 +0300
Subject: feat: refactor most of the album components to use store for
 presentation and actions

---
 src/site/pages/dashboard/admin/user/_id.vue | 1 +
 1 file changed, 1 insertion(+)

(limited to 'src/site/pages/dashboard/admin/user/_id.vue')

diff --git a/src/site/pages/dashboard/admin/user/_id.vue b/src/site/pages/dashboard/admin/user/_id.vue
index 2a56c34..8c73037 100644
--- a/src/site/pages/dashboard/admin/user/_id.vue
+++ b/src/site/pages/dashboard/admin/user/_id.vue
@@ -85,6 +85,7 @@ export default {
 	methods: {
 		promptDisableUser() {
 			this.$buefy.dialog.confirm({
+				type: 'is-danger',
 				message: 'Are you sure you want to disable the account of the user that uploaded this file?',
 				onConfirm: () => this.disableUser()
 			});
-- 
cgit v1.2.3


From fb0bc57542a44dcc94149f393d8a4ff0c2e7902b Mon Sep 17 00:00:00 2001
From: Zephyrrus <krisztian1997@gmail.com>
Date: Tue, 7 Jul 2020 02:02:59 +0300
Subject: feat: try fixing THE SHITTY WATERFALL

---
 src/site/pages/dashboard/admin/user/_id.vue | 45 ++++++++++++++++++-----------
 1 file changed, 28 insertions(+), 17 deletions(-)

(limited to 'src/site/pages/dashboard/admin/user/_id.vue')

diff --git a/src/site/pages/dashboard/admin/user/_id.vue b/src/site/pages/dashboard/admin/user/_id.vue
index 8c73037..1755b89 100644
--- a/src/site/pages/dashboard/admin/user/_id.vue
+++ b/src/site/pages/dashboard/admin/user/_id.vue
@@ -9,40 +9,51 @@
 					<Sidebar />
 				</div>
 				<div class="column">
-					<h2 class="subtitle">User details</h2>
+					<h2 class="subtitle">
+						User details
+					</h2>
 					<hr>
 
-					<b-field label="User Id"
+					<b-field
+						label="User Id"
 						horizontal>
 						<span>{{ user.id }}</span>
 					</b-field>
 
-					<b-field label="Username"
+					<b-field
+						label="Username"
 						horizontal>
 						<span>{{ user.username }}</span>
 					</b-field>
 
-					<b-field label="Enabled"
+					<b-field
+						label="Enabled"
 						horizontal>
 						<span>{{ user.enabled }}</span>
 					</b-field>
 
-					<b-field label="Registered"
+					<b-field
+						label="Registered"
 						horizontal>
 						<span><timeago :since="user.createdAt" /></span>
 					</b-field>
 
-					<b-field label="Files"
+					<b-field
+						label="Files"
 						horizontal>
 						<span>{{ files.length }}</span>
 					</b-field>
 
 					<div class="mb2 mt2 text-center">
-						<button class="button is-danger"
-							@click="promptDisableUser">Disable user</button>
+						<button
+							class="button is-danger"
+							@click="promptDisableUser">
+							Disable user
+						</button>
 					</div>
 
-					<Grid v-if="files.length"
+					<Grid
+						v-if="files.length"
 						:files="files" />
 				</div>
 			</div>
@@ -57,14 +68,14 @@ import Grid from '~/components/grid/Grid.vue';
 export default {
 	components: {
 		Sidebar,
-		Grid
+		Grid,
 	},
 	middleware: ['auth', 'admin'],
 	data() {
 		return {
 			options: {},
 			files: null,
-			user: null
+			user: null,
 		};
 	},
 	async asyncData({ $axios, route }) {
@@ -72,13 +83,13 @@ export default {
 			const response = await $axios.$get(`/admin/users/${route.params.id}`);
 			return {
 				files: response.files ? response.files : null,
-				user: response.user ? response.user : null
+				user: response.user ? response.user : null,
 			};
 		} catch (error) {
 			console.error(error);
 			return {
 				files: null,
-				user: null
+				user: null,
 			};
 		}
 	},
@@ -87,15 +98,15 @@ export default {
 			this.$buefy.dialog.confirm({
 				type: 'is-danger',
 				message: 'Are you sure you want to disable the account of the user that uploaded this file?',
-				onConfirm: () => this.disableUser()
+				onConfirm: () => this.disableUser(),
 			});
 		},
 		async disableUser() {
 			const response = await this.$axios.$post('admin/users/disable', {
-				id: this.user.id
+				id: this.user.id,
 			});
 			this.$buefy.toast.open(response.message);
-		}
-	}
+		},
+	},
 };
 </script>
-- 
cgit v1.2.3


From fd3f6de51a082dcd72c2ef557747e031ef7b9c4a Mon Sep 17 00:00:00 2001
From: Zephyrrus <krisztian1997@gmail.com>
Date: Thu, 9 Jul 2020 02:24:40 +0300
Subject: refactor: refactor most of the admin pages to use the store instead
 of internal states

---
 src/site/pages/dashboard/admin/user/_id.vue | 66 ++++++++++++++++-------------
 1 file changed, 37 insertions(+), 29 deletions(-)

(limited to 'src/site/pages/dashboard/admin/user/_id.vue')

diff --git a/src/site/pages/dashboard/admin/user/_id.vue b/src/site/pages/dashboard/admin/user/_id.vue
index 1755b89..7814468 100644
--- a/src/site/pages/dashboard/admin/user/_id.vue
+++ b/src/site/pages/dashboard/admin/user/_id.vue
@@ -41,20 +41,27 @@
 					<b-field
 						label="Files"
 						horizontal>
-						<span>{{ files.length }}</span>
+						<span>{{ user.files.length }}</span>
 					</b-field>
 
 					<div class="mb2 mt2 text-center">
-						<button
-							class="button is-danger"
+						<b-button
+							v-if="user.enabled"
+							type="is-danger"
 							@click="promptDisableUser">
 							Disable user
-						</button>
+						</b-button>
+						<b-button
+							v-if="!user.enabled"
+							type="is-success"
+							@click="promptEnableUser">
+							Enable user
+						</b-button>
 					</div>
 
 					<Grid
-						v-if="files.length"
-						:files="files" />
+						v-if="user.files.length"
+						:files="user.files" />
 				</div>
 			</div>
 		</div>
@@ -62,6 +69,7 @@
 </template>
 
 <script>
+import { mapState } from 'vuex';
 import Sidebar from '~/components/sidebar/Sidebar.vue';
 import Grid from '~/components/grid/Grid.vue';
 
@@ -70,42 +78,42 @@ export default {
 		Sidebar,
 		Grid,
 	},
-	middleware: ['auth', 'admin'],
+	middleware: ['auth', 'admin', ({ route, store }) => {
+		try {
+			store.dispatch('admin/fetchUser', route.params.id);
+		} catch (e) {
+			// eslint-disable-next-line no-console
+			console.error(e);
+		}
+	}],
 	data() {
 		return {
 			options: {},
-			files: null,
-			user: null,
 		};
 	},
-	async asyncData({ $axios, route }) {
-		try {
-			const response = await $axios.$get(`/admin/users/${route.params.id}`);
-			return {
-				files: response.files ? response.files : null,
-				user: response.user ? response.user : null,
-			};
-		} catch (error) {
-			console.error(error);
-			return {
-				files: null,
-				user: null,
-			};
-		}
-	},
+	computed: mapState({
+		user: (state) => state.admin.user,
+	}),
 	methods: {
 		promptDisableUser() {
 			this.$buefy.dialog.confirm({
 				type: 'is-danger',
-				message: 'Are you sure you want to disable the account of the user that uploaded this file?',
+				message: 'Are you sure you want to disable the account of this user?',
 				onConfirm: () => this.disableUser(),
 			});
 		},
-		async disableUser() {
-			const response = await this.$axios.$post('admin/users/disable', {
-				id: this.user.id,
+		promptEnableUser() {
+			this.$buefy.dialog.confirm({
+				type: 'is-danger',
+				message: 'Are you sure you want to enable the account of this user?',
+				onConfirm: () => this.enableUser(),
 			});
-			this.$buefy.toast.open(response.message);
+		},
+		disableUser() {
+			this.$handler.executeAction('admin/disableUser', this.user.id);
+		},
+		enableUser() {
+			this.$handler.executeAction('admin/enableUser', this.user.id);
 		},
 	},
 };
-- 
cgit v1.2.3


From 90001c2df56d58e69fd199a518ae7f3e4ed327fc Mon Sep 17 00:00:00 2001
From: Zephyrrus <krisztian1997@gmail.com>
Date: Thu, 24 Dec 2020 10:40:50 +0200
Subject: chore: remove trailing commas

---
 src/site/pages/dashboard/admin/user/_id.vue | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

(limited to 'src/site/pages/dashboard/admin/user/_id.vue')

diff --git a/src/site/pages/dashboard/admin/user/_id.vue b/src/site/pages/dashboard/admin/user/_id.vue
index 7814468..484d986 100644
--- a/src/site/pages/dashboard/admin/user/_id.vue
+++ b/src/site/pages/dashboard/admin/user/_id.vue
@@ -76,7 +76,7 @@ import Grid from '~/components/grid/Grid.vue';
 export default {
 	components: {
 		Sidebar,
-		Grid,
+		Grid
 	},
 	middleware: ['auth', 'admin', ({ route, store }) => {
 		try {
@@ -88,25 +88,25 @@ export default {
 	}],
 	data() {
 		return {
-			options: {},
+			options: {}
 		};
 	},
 	computed: mapState({
-		user: (state) => state.admin.user,
+		user: (state) => state.admin.user
 	}),
 	methods: {
 		promptDisableUser() {
 			this.$buefy.dialog.confirm({
 				type: 'is-danger',
 				message: 'Are you sure you want to disable the account of this user?',
-				onConfirm: () => this.disableUser(),
+				onConfirm: () => this.disableUser()
 			});
 		},
 		promptEnableUser() {
 			this.$buefy.dialog.confirm({
 				type: 'is-danger',
 				message: 'Are you sure you want to enable the account of this user?',
-				onConfirm: () => this.enableUser(),
+				onConfirm: () => this.enableUser()
 			});
 		},
 		disableUser() {
@@ -114,7 +114,7 @@ export default {
 		},
 		enableUser() {
 			this.$handler.executeAction('admin/enableUser', this.user.id);
-		},
-	},
+		}
+	}
 };
 </script>
-- 
cgit v1.2.3

