Skip to content

feat: proper listing of project data connectors #3528

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Mar 21, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ import {
import { Loader } from "../../../../components/Loader";
import { RtkOrNotebooksError } from "../../../../components/errors/RtkErrorAlert";

import { useGetDataConnectorsByDataConnectorIdQuery } from "../../../dataConnectorsV2/api/data-connectors.api";
import {
useGetDataConnectorsByDataConnectorIdQuery,
useGetProjectsByProjectIdInaccessibleDataConnectorLinksQuery,
} from "../../../dataConnectorsV2/api/data-connectors.api";
import DataConnectorBoxListDisplay from "../../../dataConnectorsV2/components/DataConnectorsBoxListDisplay";
import PermissionsGuard from "../../../permissionsV2/PermissionsGuard";
import type {
Expand All @@ -43,6 +46,7 @@ import { useGetProjectsByProjectIdDataConnectorLinksQuery } from "../../../proje
import useProjectPermissions from "../../utils/useProjectPermissions.hook";

import ProjectConnectDataConnectorsModal from "./ProjectConnectDataConnectorsModal";
import { InfoAlert } from "../../../../components/Alert";

interface DataConnectorListDisplayProps {
project: Project;
Expand All @@ -56,22 +60,45 @@ export default function ProjectDataConnectorsBox({
projectId: project.id,
});

if (isLoading) return <DataConnectorLoadingBoxContent />;
const {
data: dataGetInaccessible,
error: errorGetInaccessible,
isLoading: isLoadingGetInaccessible,
} = useGetProjectsByProjectIdInaccessibleDataConnectorLinksQuery({
projectId: project.id,
});

if (isLoading || isLoadingGetInaccessible)
return <DataConnectorLoadingBoxContent />;

if (error || data == null) {
return <RtkOrNotebooksError error={error} dismissible={false} />;
}

return <ProjectDataConnectorBoxContent data={data} project={project} />;
if (errorGetInaccessible || dataGetInaccessible == null) {
return (
<RtkOrNotebooksError error={errorGetInaccessible} dismissible={false} />
);
}

return (
<ProjectDataConnectorBoxContent
data={data}
project={project}
inaccessibleDataConnectors={dataGetInaccessible?.count}
/>
);
}

interface ProjectDataConnectorBoxContentProps
extends DataConnectorListDisplayProps {
data: GetProjectsByProjectIdDataConnectorLinksApiResponse;
inaccessibleDataConnectors?: number;
}
function ProjectDataConnectorBoxContent({
data,
project,
inaccessibleDataConnectors,
}: ProjectDataConnectorBoxContentProps) {
const [isModalOpen, setModalOpen] = useState(false);
const toggleOpen = useCallback(() => {
Expand All @@ -83,7 +110,7 @@ function ProjectDataConnectorBoxContent({
<ProjectDataConnectorBoxHeader
projectId={project.id}
toggleOpen={toggleOpen}
totalConnectors={data.length}
totalConnectors={data.length + (inaccessibleDataConnectors || 0)}
/>
<CardBody>
{data.length === 0 && (
Expand All @@ -92,6 +119,15 @@ function ProjectDataConnectorBoxContent({
cloud storage to read and write custom data.
</p>
)}
{inaccessibleDataConnectors != null &&
inaccessibleDataConnectors > 0 && (
<InfoAlert timeout={0} dismissible={false} className={cx("mb-3")}>
<p className="mb-0">
You are missing access to {inaccessibleDataConnectors} data
connector(s) in this project.
</p>
</InfoAlert>
)}
{data != null && data.length > 0 && (
<ListGroup flush>
{data.map((dc) => (
Expand Down
46 changes: 45 additions & 1 deletion client/src/features/dataConnectorsV2/api/data-connectors.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,22 @@ const injectedRtkApi = api.injectEndpoints({
method: "DELETE",
}),
}),
getProjectsByProjectIdDataConnectorLinks: build.query<
GetProjectsByProjectIdDataConnectorLinksApiResponse,
GetProjectsByProjectIdDataConnectorLinksApiArg
>({
query: (queryArg) => ({
url: `/projects/${queryArg.projectId}/data_connector_links`,
}),
}),
getProjectsByProjectIdInaccessibleDataConnectorLinks: build.query<
GetProjectsByProjectIdInaccessibleDataConnectorLinksApiResponse,
GetProjectsByProjectIdInaccessibleDataConnectorLinksApiArg
>({
query: (queryArg) => ({
url: `/projects/${queryArg.projectId}/inaccessible_data_connector_links`,
}),
}),
}),
overrideExisting: false,
});
Expand Down Expand Up @@ -206,6 +222,18 @@ export type DeleteDataConnectorsByDataConnectorIdSecretsApiArg = {
/** the ID of the data connector */
dataConnectorId: Ulid;
};
export type GetProjectsByProjectIdDataConnectorLinksApiResponse =
/** status 200 List of data connector to project links */ DataConnectorToProjectLinksList;
export type GetProjectsByProjectIdDataConnectorLinksApiArg = {
/** the ID of the project */
projectId: Ulid;
};
export type GetProjectsByProjectIdInaccessibleDataConnectorLinksApiResponse =
/** status 200 List of data connector to project links */ InaccessibleDataConnectorLinks;
export type GetProjectsByProjectIdInaccessibleDataConnectorLinksApiArg = {
/** the ID of the project */
projectId: Ulid;
};
export type Ulid = string;
export type DataConnectorName = string;
export type Slug = string;
Expand Down Expand Up @@ -248,7 +276,17 @@ export type RCloneOption = {
/** if true, only values from 'examples' can be used */
exclusive?: boolean;
/** data type of option value. RClone has more options but they map to the ones listed here. */
datatype?: "int" | "bool" | "string" | "Time";
type?:
| "int"
| "bool"
| "string"
| "Time"
| "Duration"
| "MultiEncoder"
| "SizeSuffix"
| "SpaceSepList"
| "CommaSepList"
| "Tristate";
};
export type CloudStorageCore = {
storage_type: StorageType;
Expand Down Expand Up @@ -418,6 +456,10 @@ export type DataConnectorSecretPatch = {
value: SecretValueNullable;
};
export type DataConnectorSecretPatchList = DataConnectorSecretPatch[];
export type InaccessibleDataConnectorLinks = {
/** The number of data links the user does not have access to */
count?: number;
};
export const {
useGetDataConnectorsQuery,
usePostDataConnectorsMutation,
Expand All @@ -432,4 +474,6 @@ export const {
useGetDataConnectorsByDataConnectorIdSecretsQuery,
usePatchDataConnectorsByDataConnectorIdSecretsMutation,
useDeleteDataConnectorsByDataConnectorIdSecretsMutation,
useGetProjectsByProjectIdDataConnectorLinksQuery,
useGetProjectsByProjectIdInaccessibleDataConnectorLinksQuery,
} = injectedRtkApi;
100 changes: 97 additions & 3 deletions client/src/features/dataConnectorsV2/api/data-connectors.openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,70 @@
},
"tags": ["data_connectors"]
}
},
"/projects/{project_id}/data_connector_links": {
"parameters": [
{
"in": "path",
"name": "project_id",
"required": true,
"schema": {
"$ref": "#/components/schemas/Ulid"
},
"description": "the ID of the project"
}
],
"get": {
"summary": "Get all links from data connectors to a given project",
"responses": {
"200": {
"description": "List of data connector to project links",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/DataConnectorToProjectLinksList"
}
}
}
},
"default": {
"$ref": "#/components/responses/Error"
}
},
"tags": ["projects"]
}
},
"/projects/{project_id}/inaccessible_data_connector_links": {
"parameters": [
{
"in": "path",
"name": "project_id",
"required": true,
"schema": {
"$ref": "#/components/schemas/Ulid"
},
"description": "the ID of the project"
}
],
"get": {
"summary": "Get the number of links that the user does not have access to in a project",
"responses": {
"200": {
"description": "List of data connector to project links",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/InaccessibleDataConnectorLinks"
}
}
}
},
"default": {
"$ref": "#/components/responses/Error"
}
},
"tags": ["projects"]
}
}
},
"components": {
Expand Down Expand Up @@ -902,10 +966,21 @@
"type": "boolean",
"description": "if true, only values from 'examples' can be used"
},
"datatype": {
"type": {
"type": "string",
"description": "data type of option value. RClone has more options but they map to the ones listed here.",
"enum": ["int", "bool", "string", "Time"]
"enum": [
"int",
"bool",
"string",
"Time",
"Duration",
"MultiEncoder",
"SizeSuffix",
"SpaceSepList",
"CommaSepList",
"Tristate"
]
}
}
},
Expand All @@ -921,9 +996,17 @@
"type": "string",
"minLength": 1,
"maxLength": 99,
"pattern": "^(?!.*\\.git$|.*\\.atom$|.*[\\-._][\\-._].*)[a-zA-Z0-9][a-zA-Z0-9\\-_.]*$",
"pattern": "^(?!.*\\.git$|.*\\.atom$|.*[\\-._][\\-._].*)[a-z0-9][a-z0-9\\-_.]*$",
"example": "a-slug-example"
},
"OneOrTwoSlugs": {
"description": "A command-line/url friendly name for a single slug or two slugs separated by /",
"type": "string",
"minLength": 1,
"maxLength": 200,
"pattern": "^(?!.*\\.git$|.*\\.atom$|.*[\\-._][\\-._].*)[a-z0-9][a-z0-9\\-_.]*(?<!\\.git)(?<!\\.atom)(?:/[a-z0-9][a-z0-9\\-_.]*){0,1}$",
"example": "user1/project-1"
},
"CreationDate": {
"description": "The date and time the resource was created (in UTC and ISO-8601 format)",
"type": "string",
Expand Down Expand Up @@ -1073,6 +1156,17 @@
}
},
"required": ["error"]
},
"InaccessibleDataConnectorLinks": {
"description": "Information about inaccessible data connector links",
"type": "object",
"properties": {
"count": {
"type": "integer",
"minimum": 0,
"description": "The number of data links the user does not have access to"
}
}
}
},
"responses": {
Expand Down