aboutsummaryrefslogtreecommitdiff
path: root/packages/client/src/views/RepositoryCommit.vue
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2021-07-06 14:55:58 +0200
committerHampusM <hampus@hampusmat.com>2021-07-06 14:55:58 +0200
commitc2dc7906e47a05cecc6350fd6a3d6f6f955a3423 (patch)
tree0f3895eb00783943a13d27235dfd88bcda5a844c /packages/client/src/views/RepositoryCommit.vue
parent49e6ae50447130ba6e2efd2b561f1b1dcc033099 (diff)
Frontend uses shared types
Diffstat (limited to 'packages/client/src/views/RepositoryCommit.vue')
-rw-r--r--packages/client/src/views/RepositoryCommit.vue20
1 files changed, 13 insertions, 7 deletions
diff --git a/packages/client/src/views/RepositoryCommit.vue b/packages/client/src/views/RepositoryCommit.vue
index 50ec9ad..f0dec4a 100644
--- a/packages/client/src/views/RepositoryCommit.vue
+++ b/packages/client/src/views/RepositoryCommit.vue
@@ -16,18 +16,18 @@
<td class="commit-info-title">
Date
</td>
- <td>{{ commit["date"] }}</td>
+ <td>{{ commit.pretty_date }}</td>
</tr>
<tr>
<td class="commit-info-title">
Message
</td>
- <td>{{ commit["message"] }}</td>
+ <td>{{ commit.message }}</td>
</tr>
</tbody>
</table>
<div
- v-for="(patch, index) in commit['diff']" :key="index"
+ v-for="(patch, index) in commit.diff" :key="index"
class="commit-patch">
<div class="commit-patch-header">
<span>{{ (patch.to === "/dev/null") ? patch.from : patch.to }} </span>
@@ -53,6 +53,7 @@
import { defineComponent, Ref, ref } from "vue";
import { format } from "date-fns";
import fetchData from "../util/fetch";
+import { Commit } from "shared_types";
import BaseBreadcrumb from "../components/BaseBreadcrumb.vue";
import CommitPatch from "../components/CommitPatch.vue";
@@ -60,6 +61,10 @@ import Loading from "vue-loading-overlay";
import BaseErrorMessage from "../components/BaseErrorMessage.vue";
import { getParam } from "../util/util";
+interface PrettyDateCommit extends Commit {
+ pretty_date: string
+}
+
export default defineComponent({
name: "RepositoryCommit",
components: {
@@ -69,16 +74,17 @@ export default defineComponent({
BaseErrorMessage
},
setup() {
- const commit = ref(null);
+ const commit: Ref<PrettyDateCommit | null> = ref(null);
const is_loading: Ref<boolean> = ref(true);
const fetch_failed: Ref<string> = ref("");
const fetchCommit = async(repository: string, commit_id: string) => {
- const commit_data = await fetchData(`repos/${repository}/log/${commit_id}`, fetch_failed, is_loading, "commit");
+ const commit_data: Commit = await fetchData(`repos/${repository}/log/${commit_id}`, fetch_failed, is_loading, "commit");
if(commit_data) {
- commit_data.date = format(new Date(commit_data.date * 1000), "yyyy-MM-dd hh:mm");
- commit.value = commit_data;
+ const pretty_commit = commit_data as PrettyDateCommit;
+ pretty_commit.pretty_date = format(new Date(commit_data.date * 1000), "yyyy-MM-dd hh:mm");
+ commit.value = pretty_commit;
}
};