Skip to content

Commit

Permalink
[data_source] - refactor: remove DataSourceDetailsModal component
Browse files Browse the repository at this point in the history
 - DataSourceDetailsModal component removed to simplify data source management flow
 - Various related hooks and states for showing the modal have been cleaned up
 - Adjusted ManagedDataSourceView to reflect the removal of the modal
 - Data source management now relies on the ConnectorPermissionsModal for permissions management exclusively
  • Loading branch information
Jules authored and Jules committed Aug 9, 2024
1 parent ca9c5ff commit 35f88a8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 146 deletions.
100 changes: 0 additions & 100 deletions front/components/data_source/DataSourceDetailsModal.tsx

This file was deleted.

45 changes: 2 additions & 43 deletions front/pages/w/[wId]/builder/data-sources/[name]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import { useContext, useEffect, useMemo, useRef, useState } from "react";

import ConnectorPermissionsModal from "@app/components/ConnectorPermissionsModal";
import { PermissionTree } from "@app/components/ConnectorPermissionsTree";
import DataSourceDetailsModal from "@app/components/data_source/DataSourceDetailsModal";
import ConnectorSyncingChip from "@app/components/data_source/DataSourceSyncChip";
import { subNavigationBuild } from "@app/components/navigation/config";
import AppLayout from "@app/components/sparkle/AppLayout";
Expand Down Expand Up @@ -1000,8 +999,6 @@ function ManagedDataSourceView({
const sendNotification = useContext(SendNotificationsContext);

const [showPermissionModal, setShowPermissionModal] = useState(false);
const [showDataSourceDetailsModal, setShowDataSourceDetailsModal] =
useState(false);

const connectorProvider = dataSource.connectorProvider;
if (!connectorProvider) {
Expand Down Expand Up @@ -1096,7 +1093,6 @@ function ManagedDataSourceView({
};

const {
displayDataSourceDetailsModal,
displayManagePermissionButton,
addDataButtonLabel,
displaySettingsButton,
Expand All @@ -1123,19 +1119,6 @@ function ManagedDataSourceView({
<span>{postPermissionsUpdateMessage}</span>
</Dialog>
)}
<DataSourceDetailsModal
dataSource={dataSource}
visible={showDataSourceDetailsModal}
onClose={() => {
setShowDataSourceDetailsModal(false);
}}
onClick={() => {
void handleUpdatePermissions().then(() => {
postPermissionsUpdateMessage &&
setPostPermissionsUpdateDialogIsOpen(true);
});
}}
/>
<ConnectorPermissionsModal
owner={owner}
connector={connector}
Expand Down Expand Up @@ -1164,24 +1147,6 @@ function ManagedDataSourceView({
})()}
icon={CONNECTOR_CONFIGURATIONS[connectorProvider].logoComponent}
/>
{isAdmin && displayManagePermissionButton ? (
<Button
className="ml-auto"
label="Manage permissions"
variant="tertiary"
icon={LockIcon}
disabled={readOnly || !isAdmin}
onClick={() => {
if (displayDataSourceDetailsModal) {
setShowDataSourceDetailsModal(true);
} else {
void handleUpdatePermissions();
}
}}
/>
) : (
<></>
)}
{isBuilder && displaySettingsButton ? (
<Link
className="ml-auto"
Expand Down Expand Up @@ -1217,22 +1182,16 @@ function ManagedDataSourceView({
label={addDataButtonLabel}
variant="primary"
icon={ListCheckIcon}
disabled={readOnly || !isAdmin}
disabled={readOnly}
onClick={() => {
if (
!displayManagePermissionButton &&
displayDataSourceDetailsModal
) {
setShowDataSourceDetailsModal(true);
} else if (displayManagePermissionButton) {
if (displayManagePermissionButton) {
setShowPermissionModal(true);
} else {
void handleUpdatePermissions();
}
}}
/>
)}

{guideLink && (
<Button
label="Read our guide"
Expand Down
7 changes: 4 additions & 3 deletions front/pages/w/[wId]/builder/data-sources/managed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ function getTableColumns(): ColumnDef<RowData, unknown>[] {
),
},
{
header: "Manage",
id: "manage",
cell: (info: Info) => {
const original = info.row.original;
const disabled = original.isLoading || !original.isAdmin;
Expand All @@ -700,17 +700,18 @@ function getTableColumns(): ColumnDef<RowData, unknown>[] {
</DataTable.Cell>
);
} else {
if (original.isAdmin) {
return (
<DataTable.Cell className="relative">
<Button
variant="secondary"
icon={Cog6ToothIcon}
disabled={disabled}
onClick={original.buttonOnClick}
label={original.isAdmin ? "Manage" : "View"}
label="Manage"
/>
</DataTable.Cell>
);
}
}
},
},
Expand Down

0 comments on commit 35f88a8

Please sign in to comment.