Skip to content

Commit

Permalink
[front/components/data_source] - refactor: streamline connection edit…
Browse files Browse the repository at this point in the history
… button display logic

 - Simplify the conditional rendering of the 'Edit Connection' button to only show when setup is complete and the user is the owner
 - Update avatar to use dynamic imageUrl for dataSourceOwner instead of a hardcoded image link

[front/components/data_source] - refactor: reorganize conditional logic for rendering elements

 - Move the condition checking if the data source is set up and the user is the owner to a more appropriate place in the code structure to improve readability and maintainability
  • Loading branch information
Jules authored and Jules committed Aug 8, 2024
1 parent 168bd4b commit ca9c5ff
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions front/components/data_source/DataSourceEdition.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -310,20 +310,7 @@ export function DataSourceEditionModal({
)}

<div className="mt-4 flex items-center justify-center">
{isSetup ? (
isDataSourceOwner ? (
<Button
label="Edit Connection"
onClick={() =>
void router.push(
`/w/${owner.sId}/builder/data-sources/${dataSourceIntegration.dataSourceName}`
)
}
/>
) : (
<></>
)
) : (
{!isSetup && (
<Button
variant="primary"
size="md"
Expand All @@ -340,10 +327,7 @@ export function DataSourceEditionModal({
<div className="flex flex-col gap-2 border-t pb-4 pt-4">
<Page.SectionHeader title="Connection Owner" />
<div className="flex items-center gap-2">
<Avatar
visual="https://dust.tt/static/droidavatar/Droid_Black_2.jpg"
size="sm"
/>
<Avatar visual={dataSourceOwner?.imageUrl} size="sm" />
<div>
<span className="font-bold">
{isDataSourceOwner
Expand Down Expand Up @@ -406,6 +390,18 @@ export function DataSourceEditionModal({
</div>
</div>
)}
{isSetup && isDataSourceOwner && (
<div className="flex items-center justify-center">
<Button
label="Edit Connection"
onClick={() =>
void router.push(
`/w/${owner.sId}/builder/data-sources/${dataSourceIntegration.dataSourceName}`
)
}
/>
</div>
)}
<Dialog
title="Are you sure?"
isOpen={showConfirmDialog}
Expand Down

0 comments on commit ca9c5ff

Please sign in to comment.