show bot versions on bot page

This commit is contained in:
Ilion Beyst 2022-09-10 18:57:38 +02:00
parent 3058028edc
commit 9e574f08ee
2 changed files with 64 additions and 14 deletions

View file

@ -91,6 +91,25 @@
Publish a new version by pushing a docker container to Publish a new version by pushing a docker container to
<code>registry.planetwars.dev/{bot["name"]}:latest</code>, or using the web editor. <code>registry.planetwars.dev/{bot["name"]}:latest</code>, or using the web editor.
</div> </div>
<div class="versions">
<h3>Versions</h3>
<ul class="version-list">
{#each versions.slice(0, 10) as version}
<li class="bot-version">
{dayjs(version["created_at"]).format("YYYY-MM-DD HH:mm")}
{#if version["container_digest"]}
<span class="container-digest">{version["container_digest"]}</span>
{:else}
<a href={`/code/${version["id"]}`}>view code</a>
{/if}
</li>
{/each}
</ul>
{#if versions.length == 0}
This bot does not have any versions yet.
{/if}
</div>
{/if} {/if}
<div class="matches"> <div class="matches">
@ -102,20 +121,6 @@
</div> </div>
{/if} {/if}
</div> </div>
<!-- <div class="versions">
<h4>Versions</h4>
<ul class="version-list">
{#each versions as version}
<li>
{dayjs(version["created_at"]).format("YYYY-MM-DD HH:mm")}
</li>
{/each}
</ul>
{#if versions.length == 0}
This bot does not have any versions yet.
{/if}
</div> -->
</div> </div>
<style lang="scss"> <style lang="scss">
@ -155,4 +160,14 @@
.versions { .versions {
margin: 30px 0; margin: 30px 0;
} }
.version-list {
padding: 0;
}
.bot-version {
display: flex;
justify-content: space-between;
padding: 4px 24px;
}
</style> </style>

View file

@ -0,0 +1,35 @@
<script lang="ts" context="module">
import { ApiClient } from "$lib/api_client";
export async function load({ params, fetch }) {
const apiClient = new ApiClient(fetch);
try {
const code = await apiClient.getText(`/api/code/${params["bundle_id"]}`);
return {
props: {
code,
},
};
} catch (error) {
return {
status: error.status,
error: error,
};
}
}
</script>
<script lang="ts">
export let code;
</script>
<pre class="bot-code">
{code}
</pre>
<style lang="scss">
.bot-code {
margin: 24px 12px;
}
</style>