mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-03 06:56:15 +00:00
#591 - sites [wip]
This commit is contained in:
@ -27,12 +27,10 @@ type SourceControlForm = {
|
||||
};
|
||||
|
||||
export default function ConnectSourceControl({
|
||||
providers,
|
||||
defaultProvider,
|
||||
onProviderAdded,
|
||||
children,
|
||||
}: {
|
||||
providers: string[];
|
||||
defaultProvider?: string;
|
||||
onProviderAdded?: () => void;
|
||||
children: ReactNode;
|
||||
@ -83,7 +81,7 @@ export default function ConnectSourceControl({
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectGroup>
|
||||
{providers.map((provider) => (
|
||||
{page.props.configs.source_control_providers.map((provider) => (
|
||||
<SelectItem key={provider} value={provider}>
|
||||
{provider}
|
||||
</SelectItem>
|
||||
|
@ -0,0 +1,50 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import axios from 'axios';
|
||||
import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
|
||||
import React from 'react';
|
||||
import { SelectTriggerProps } from '@radix-ui/react-select';
|
||||
import { SourceControl } from '@/types/source-control';
|
||||
import ConnectSourceControl from '@/pages/source-controls/components/connect-source-control';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { WifiIcon } from 'lucide-react';
|
||||
|
||||
export default function SourceControlSelect({
|
||||
value,
|
||||
onValueChange,
|
||||
...props
|
||||
}: {
|
||||
value: string;
|
||||
onValueChange: (value: string) => void;
|
||||
} & SelectTriggerProps) {
|
||||
const query = useQuery<SourceControl[]>({
|
||||
queryKey: ['sourceControl'],
|
||||
queryFn: async () => {
|
||||
return (await axios.get(route('source-controls.json'))).data;
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
<div className="flex items-center gap-2">
|
||||
<Select value={value} onValueChange={onValueChange} disabled={query.isFetching}>
|
||||
<SelectTrigger {...props}>
|
||||
<SelectValue placeholder={query.isFetching ? 'Loading...' : 'Select a provider'} />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectGroup>
|
||||
{query.isSuccess &&
|
||||
query.data.map((sourceControl: SourceControl) => (
|
||||
<SelectItem key={`db-${sourceControl.name}`} value={sourceControl.id.toString()}>
|
||||
{sourceControl.name}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectGroup>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<ConnectSourceControl onProviderAdded={() => query.refetch()}>
|
||||
<Button variant="outline">
|
||||
<WifiIcon />
|
||||
</Button>
|
||||
</ConnectSourceControl>
|
||||
</div>
|
||||
);
|
||||
}
|
@ -3,17 +3,14 @@ import { Head, usePage } from '@inertiajs/react';
|
||||
import Container from '@/components/container';
|
||||
import Heading from '@/components/heading';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import React from 'react';
|
||||
import ConnectSourceControl from '@/pages/source-controls/components/connect-source-control';
|
||||
import { DataTable } from '@/components/data-table';
|
||||
import { columns } from '@/pages/source-controls/components/columns';
|
||||
import { SourceControl } from '@/types/source-control';
|
||||
import { Configs } from '@/types';
|
||||
import { Configs, PaginatedData } from '@/types';
|
||||
|
||||
type Page = {
|
||||
sourceControls: {
|
||||
data: SourceControl[];
|
||||
};
|
||||
sourceControls: PaginatedData<SourceControl>;
|
||||
configs: Configs;
|
||||
};
|
||||
|
||||
@ -27,12 +24,12 @@ export default function SourceControls() {
|
||||
<div className="flex items-start justify-between">
|
||||
<Heading title="Source Controls" description="Here you can manage all of the source control connectinos" />
|
||||
<div className="flex items-center gap-2">
|
||||
<ConnectSourceControl providers={page.props.configs.source_control_providers}>
|
||||
<ConnectSourceControl>
|
||||
<Button>Connect</Button>
|
||||
</ConnectSourceControl>
|
||||
</div>
|
||||
</div>
|
||||
<DataTable columns={columns} data={page.props.sourceControls.data} />
|
||||
<DataTable columns={columns} paginatedData={page.props.sourceControls} />
|
||||
</Container>
|
||||
</SettingsLayout>
|
||||
);
|
||||
|
Reference in New Issue
Block a user