Skip to content

Conversation

@SuveenE
Copy link
Collaborator

@SuveenE SuveenE commented Oct 10, 2024

We can delay merging this as this might complicate the testing process.

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This pull request adds support for platform-specific integration allowances, introducing a new 'allowed_integrations' property to the platform table and corresponding functionality to fetch and display allowed integrations.

  • Added 'allowed_integrations' field to platform table in src/database/database.types.ts
  • Implemented getAllowedIntegrationsByPlatformName function in src/database/supabase.ts to fetch allowed integrations
  • Updated src/entrypoints/popup/App.tsx to fetch, filter, and display allowed integrations based on platform name
  • Introduced state management for allowed integrations and platform name in the App component
  • Modified UI to show platform name and filter displayed integrations based on the allowed list

3 file(s) reviewed, 5 comment(s)
Edit PR Review Bot Settings

): Promise<string[]> {
const { data, error } = await supabase
.from("platform")
.select("allowed_integrations")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Using .single() assumes only one result. Ensure this is always true for platform names

Comment on lines +40 to +41
const [allowedIntegrations, setAllowedIntegrations] = useState<string[]>([]);
const [platformName, setPlatformName] = useState<string>("");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Consider using a more specific type for allowedIntegrations, such as Array

Comment on lines +43 to +56
useEffect(() => {
const fetchAllowedIntegrations = async () => {
try {
const platformDetails: PlatformDetails = await getPlatformDetails();
setPlatformName(platformDetails.platform);
const allowed = await getAllowedIntegrationsByPlatformName(
platformDetails.platform,
);
setAllowedIntegrations(allowed);
} catch (error) {
console.error("Error fetching allowed integrations:", error);
}
};

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Add a cleanup function to the useEffect to cancel the async operation if the component unmounts before it completes

.filter(
(integration) =>
integration.values?.some((value) =>
value.toLowerCase().includes(searchTerm.toLowerCase()),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: This type assertion might be unsafe. Consider using a type guard or refactoring to ensure type safety

integration.values[0] as keyof typeof integrationEnum.Values,
),
)
.sort((a, b) => a.values[0].localeCompare(b.values[0]));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Ensure platformName is properly sanitized before rendering to prevent XSS attacks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants