Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 41 additions & 4 deletions src/components/storage/browse/FileDetailsSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,20 @@ export function FileDetailsSheet({
return;
}
setLoading(true);
Promise.all([getFileById(fileId), getFileUrl(fileId)])
.then(([fileData, urlData]) => {
setFile(fileData);
setUrl(urlData.result);
setFile(null);
setUrl(null);
Promise.allSettled([getFileById(fileId), getFileUrl(fileId)])
.then(([fileResult, urlResult]) => {
if (fileResult.status === 'fulfilled') {
setFile(fileResult.value);
} else {
setFile(null);
}
if (urlResult.status === 'fulfilled') {
setUrl(urlResult.value.result);
} else {
setUrl(null);
}
})
.finally(() => setLoading(false));
}, [fileId, open]);
Expand All @@ -67,6 +77,12 @@ export function FileDetailsSheet({
toast({ title: 'Storage', description: 'URL copied to clipboard' });
};

const copyUri = async () => {
if (!file?.uri) return;
await navigator.clipboard.writeText(file.uri);
toast({ title: 'Storage', description: 'URI copied to clipboard' });
};

return (
<Sheet open={open} onOpenChange={onOpenChange}>
<SheetContent className="sm:max-w-lg overflow-y-auto">
Expand Down Expand Up @@ -141,6 +157,27 @@ export function FileDetailsSheet({
</p>
</div>

{file.uri && (
<div>
<span className="text-sm text-muted-foreground">
Conduit URI
</span>
<div className="flex items-start gap-2 mt-0.5">
<p className="text-sm font-mono break-all flex-1">
{file.uri}
</p>
<Button
variant="ghost"
size="icon"
className="shrink-0 h-7 w-7"
onClick={copyUri}
>
<Copy className="h-3.5 w-3.5" />
</Button>
</div>
</div>
)}

{url && (
<div>
<span className="text-sm text-muted-foreground">URL</span>
Expand Down
38 changes: 36 additions & 2 deletions src/components/storage/settings/settingsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ export const SettingsForm = ({
<div className={'flex items-center gap-2'}>
Google{' '}
{data.google &&
data.google.serviceAccountKeyPath !== '' &&
(data.google.serviceAccountKeyPath !== '' ||
(data.google.serviceAccountKeyJson ?? '') !== '') &&
watch('provider') !== 'google' && <Cog />}
</div>
</SelectItem>
Expand Down Expand Up @@ -288,14 +289,47 @@ export const SettingsForm = ({
name="google.serviceAccountKeyPath"
render={({ field }) => (
<FormItem>
<FormLabel>Service Account Key Path</FormLabel>
<FormLabel>
Service Account Key Path
<p className={'text-xs text-muted-foreground'}>
Path to the service account JSON file. Leave both path
and JSON empty to use Application Default Credentials.
</p>
</FormLabel>
<FormControl>
<Input
disabled={!edit}
title={' Service Account Key Path'}
placeholder={'Enter a value'}
className={'text-accent-foreground'}
{...field}
value={field.value ?? ''}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={control}
name="google.serviceAccountKeyJson"
render={({ field }) => (
<FormItem>
<FormLabel>
Service Account Key JSON
<p className={'text-xs text-muted-foreground'}>
Inline service account JSON. Do not use if path is
provided.
</p>
</FormLabel>
<FormControl>
<PasswordInput
disabled={!edit}
title={'Service Account Key JSON'}
placeholder={'Enter JSON'}
className={'text-accent-foreground'}
{...field}
value={field.value ?? ''}
/>
</FormControl>
<FormMessage />
Expand Down
3 changes: 2 additions & 1 deletion src/components/storage/settings/zod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ export const BaseSchema = z.object({
});

const GoogleSchema = z.object({
serviceAccountKeyPath: z.string().min(5),
serviceAccountKeyPath: z.string().optional().or(z.literal('')).default(''),
serviceAccountKeyJson: z.string().optional().or(z.literal('')).default(''),
});

const AzureSchema = z.object({
Expand Down
4 changes: 3 additions & 1 deletion src/lib/models/storage/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ export type ConduitFile = {
container: string;
size: number;
isPublic?: boolean;
url: string;
url?: string;
uri?: string;
sourceUrl?: string;
mimeType: string;
createdAt: string | Date;
updatedAt: string | Date;
Expand Down
1 change: 1 addition & 0 deletions src/lib/models/storage/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type AuthorizationProps = {

type GoogleSettings = {
serviceAccountKeyPath: string;
serviceAccountKeyJson: string;
};

type AzureSettings = {
Expand Down
Loading