Tweak blob url helper function names

This commit is contained in:
Sam Becker 2023-12-11 18:08:19 -06:00
parent a297910e7c
commit 22ecb16804
2 changed files with 9 additions and 9 deletions

View File

@ -2,7 +2,7 @@ import { Fragment } from 'react';
import AdminGrid from './AdminGrid'; import AdminGrid from './AdminGrid';
import Link from 'next/link'; import Link from 'next/link';
import ImageTiny from '@/components/ImageTiny'; import ImageTiny from '@/components/ImageTiny';
import { pathForBlobUrl } from '@/services/blob'; import { fileNameForBlobUrl } from '@/services/blob';
import FormWithConfirm from '@/components/FormWithConfirm'; import FormWithConfirm from '@/components/FormWithConfirm';
import { deleteBlobPhotoAction } from '@/photo/actions'; import { deleteBlobPhotoAction } from '@/photo/actions';
import DeleteButton from './DeleteButton'; import DeleteButton from './DeleteButton';
@ -20,12 +20,12 @@ export default function BlobUrls({
return ( return (
<AdminGrid {...{ title }} > <AdminGrid {...{ title }} >
{urls.map(url => { {urls.map(url => {
const href = pathForAdminUploadUrl(url); const addUploadPath = pathForAdminUploadUrl(url);
const fileName = url.split('/').pop(); const uploadFileName = fileNameForBlobUrl(url);
return <Fragment key={url}> return <Fragment key={url}>
<Link href={href}> <Link href={addUploadPath}>
<ImageTiny <ImageTiny
alt={`Photo: ${fileName}`} alt={`Upload: ${uploadFileName}`}
src={url} src={url}
aspectRatio={3.0 / 2.0} aspectRatio={3.0 / 2.0}
className={cc( className={cc(
@ -35,17 +35,17 @@ export default function BlobUrls({
/> />
</Link> </Link>
<Link <Link
href={href} href={addUploadPath}
className="break-all" className="break-all"
title={url} title={url}
> >
{pathForBlobUrl(url)} {uploadFileName}
</Link> </Link>
<div className={cc( <div className={cc(
'flex flex-nowrap', 'flex flex-nowrap',
'gap-2 sm:gap-3 items-center', 'gap-2 sm:gap-3 items-center',
)}> )}>
<AddButton href={href} /> <AddButton href={addUploadPath} />
<FormWithConfirm <FormWithConfirm
action={deleteBlobPhotoAction} action={deleteBlobPhotoAction}
confirmText="Are you sure you want to delete this upload?" confirmText="Are you sure you want to delete this upload?"

View File

@ -31,7 +31,7 @@ const REGEX_UPLOAD_ID = new RegExp(
'i', 'i',
); );
export const pathForBlobUrl = (url: string) => export const fileNameForBlobUrl = (url: string) =>
url.replace(`${BLOB_BASE_URL}/`, ''); url.replace(`${BLOB_BASE_URL}/`, '');
export const getExtensionFromBlobUrl = (url: string) => export const getExtensionFromBlobUrl = (url: string) =>