mirror of https://github.com/kortix-ai/suna.git
Merge pull request #931 from escapade-mckv/integrations-ui
oauth fetch bug fix
This commit is contained in:
commit
293695b82c
|
@ -122,13 +122,10 @@ export const PipedreamConnector: React.FC<PipedreamConnectorProps> = ({
|
|||
setNewProfileName('');
|
||||
toast.success('Profile created and connected successfully!');
|
||||
|
||||
// Auto-proceed based on mode
|
||||
if (mode === 'profile-only') {
|
||||
// Complete immediately with empty tools array
|
||||
onComplete(newProfile.profile_id, [], app.name, app.name_slug);
|
||||
onOpenChange(false);
|
||||
} else {
|
||||
// Proceed to tools step
|
||||
proceedToTools();
|
||||
}
|
||||
} catch (error) {
|
||||
|
@ -150,7 +147,6 @@ export const PipedreamConnector: React.FC<PipedreamConnectorProps> = ({
|
|||
|
||||
if (server?.available_tools) {
|
||||
setTools(server.available_tools);
|
||||
// Auto-select all tools by default
|
||||
setSelectedTools(new Set(server.available_tools.map(tool => tool.name)));
|
||||
}
|
||||
} catch (error) {
|
||||
|
@ -166,7 +162,6 @@ export const PipedreamConnector: React.FC<PipedreamConnectorProps> = ({
|
|||
toast.error('Please select at least one tool');
|
||||
return;
|
||||
}
|
||||
|
||||
setIsCompletingConnection(true);
|
||||
try {
|
||||
onComplete(selectedProfileId, Array.from(selectedTools), app.name, app.name_slug);
|
||||
|
|
|
@ -7,7 +7,6 @@ import { TriggerConfigDialog } from './trigger-config-dialog';
|
|||
import { TriggerProvider } from './types';
|
||||
import { Dialog } from '@/components/ui/dialog';
|
||||
import {
|
||||
useOAuthIntegrations,
|
||||
useInstallOAuthIntegration,
|
||||
useUninstallOAuthIntegration,
|
||||
useOAuthCallbackHandler
|
||||
|
@ -37,8 +36,6 @@ export const OneClickIntegrations: React.FC<OneClickIntegrationsProps> = ({
|
|||
agentId
|
||||
}) => {
|
||||
const [configuringSchedule, setConfiguringSchedule] = useState(false);
|
||||
|
||||
const { data: integrationStatus, isLoading, error } = useOAuthIntegrations(agentId);
|
||||
const { data: triggers = [] } = useAgentTriggers(agentId);
|
||||
const installMutation = useInstallOAuthIntegration();
|
||||
const uninstallMutation = useUninstallOAuthIntegration();
|
||||
|
@ -106,9 +103,6 @@ export const OneClickIntegrations: React.FC<OneClickIntegrationsProps> = ({
|
|||
if (provider === 'schedule') {
|
||||
return triggers.find(trigger => trigger.trigger_type === 'schedule');
|
||||
}
|
||||
return integrationStatus?.integrations.find(integration =>
|
||||
integration.provider === provider
|
||||
);
|
||||
};
|
||||
|
||||
const isProviderInstalled = (provider: ProviderKey) => {
|
||||
|
@ -123,22 +117,6 @@ export const OneClickIntegrations: React.FC<OneClickIntegrationsProps> = ({
|
|||
return integration?.trigger_id;
|
||||
};
|
||||
|
||||
if (error) {
|
||||
return (
|
||||
<div className="p-4 border border-destructive/20 bg-destructive/5 rounded-lg">
|
||||
<div className="flex items-center space-x-3">
|
||||
<AlertCircle className="h-5 w-5 text-destructive" />
|
||||
<div>
|
||||
<h3 className="text-lg font-semibold text-destructive">Error Loading Integrations</h3>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
{error instanceof Error ? error.message : 'Failed to load integrations'}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const scheduleProvider: TriggerProvider = {
|
||||
provider_id: 'schedule',
|
||||
name: 'Schedule',
|
||||
|
@ -153,7 +131,6 @@ export const OneClickIntegrations: React.FC<OneClickIntegrationsProps> = ({
|
|||
<div className="flex flex-wrap gap-3">
|
||||
{Object.entries(OAUTH_PROVIDERS).map(([providerId, config]) => {
|
||||
const provider = providerId as ProviderKey;
|
||||
const integration = getIntegrationForProvider(provider);
|
||||
const isInstalled = isProviderInstalled(provider);
|
||||
const isLoading = installMutation.isPending || uninstallMutation.isPending ||
|
||||
(provider === 'schedule' && (createTriggerMutation.isPending || deleteTriggerMutation.isPending));
|
||||
|
|
|
@ -39,22 +39,6 @@ const getAccessToken = async () => {
|
|||
return session.access_token;
|
||||
};
|
||||
|
||||
const fetchOAuthIntegrations = async (agentId: string): Promise<OAuthIntegrationStatus> => {
|
||||
const accessToken = await getAccessToken();
|
||||
const response = await fetch(`${API_URL}/integrations/status/${agentId}`, {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': `Bearer ${accessToken}`
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error('Failed to fetch OAuth integrations');
|
||||
}
|
||||
|
||||
return response.json();
|
||||
};
|
||||
|
||||
const initiateOAuthInstall = async (request: OAuthInstallRequest): Promise<OAuthInstallResponse> => {
|
||||
const accessToken = await getAccessToken();
|
||||
const response = await fetch(`${API_URL}/integrations/install`, {
|
||||
|
@ -90,14 +74,6 @@ const uninstallOAuthIntegration = async (triggerId: string): Promise<void> => {
|
|||
}
|
||||
};
|
||||
|
||||
export const useOAuthIntegrations = (agentId: string) => {
|
||||
return useQuery({
|
||||
queryKey: ['oauth-integrations', agentId],
|
||||
queryFn: () => fetchOAuthIntegrations(agentId),
|
||||
enabled: !!agentId,
|
||||
});
|
||||
};
|
||||
|
||||
export const useInstallOAuthIntegration = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
|
|
Loading…
Reference in New Issue