Skip to content

Commit

Permalink
Added downloads for admins on release pages
Browse files Browse the repository at this point in the history
  • Loading branch information
james-pre committed Oct 31, 2024
1 parent 3fb7a6e commit 96f7364
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
1 change: 0 additions & 1 deletion src/pages/download.astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
import { AccountType } from '@blankstorm/api';
import Asset from '../components/Asset.astro';
import Main from '../layouts/Main.astro';
import { repositoryAPIRequest, type Release } from '../repository';
Expand Down
10 changes: 8 additions & 2 deletions src/pages/releases/[version].astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,36 @@
import ReleaseView from '../../components/Release.astro';
import Main from '../../layouts/Main.astro';
import { repositoryAPIRequest, type Release } from '../../repository';
import { currentUser } from '../../utils';
let error: string | Error, release: Release;
const { version } = Astro.params;
const fetch_url = '/releases' + (version == 'latest' ? '' : '/tags/' + version);
try {
const result = await repositoryAPIRequest(fetch_url);
release = version == 'latest' ? result[0] : result;
} catch (err) {
error = err;
}
const account = await currentUser(Astro.cookies);
const include_downloads = !!account?.type;
---

<Main title={`Release ${release?.name || ''}`}>
<Main title={`Release ${release?.name || ''}`} {account}>
{
error ? (
<span data-fetch-url={fetch_url}>
<br />
Failed to fetch release{typeof error == 'string' && ': ' + error}
</span>
) : (
<ReleaseView {release} />
<ReleaseView {release} {include_downloads} />
)
}
</Main>
8 changes: 7 additions & 1 deletion src/pages/releases/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import ReleaseView from '../../components/Release.astro';
import Main from '../../layouts/Main.astro';
import { repo_url, repositoryAPIRequest, type Release } from '../../repository';
import { currentUser } from '../../utils';
let error: string | Error | undefined,
releases: Release[] = [];
Expand All @@ -12,6 +13,11 @@ try {
} catch (err) {
error = err;
}
const account = await currentUser(Astro.cookies);
const include_downloads = !!account?.type;
---

<Main title="Releases">
Expand All @@ -26,7 +32,7 @@ try {
.
</span>
) : (
releases.map((release: Release) => <ReleaseView {release} />)
releases.map((release: Release) => <ReleaseView {release} {include_downloads} />)
)
}
</Main>

0 comments on commit 96f7364

Please sign in to comment.