-
Notifications
You must be signed in to change notification settings - Fork 6
feat!: support for data connectors on user and group namespaces #3315
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
ciyer
merged 9 commits into
build/data-connectors
from
ciyer/storage-to-data-connectors
Sep 30, 2024
Merged
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d3efa1b
feat: data-connectors support on group and user namespace pages
ciyer 351d1d7
Update client/src/features/usersV2/show/UserShow.tsx
ciyer 0e58bbb
confirm data connector deletion
ciyer 5e0760d
removed block of tests that was accidentally copied
ciyer e876667
fixed hook dependencies
ciyer 0e33652
Revert "fixed hook dependencies" -- it caused problems for testing th…
ciyer 5098295
fix formatting
ciyer fab9496
use existing slug and namespace components
ciyer 6572869
separate out data-connector api
ciyer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
189 changes: 189 additions & 0 deletions
189
client/src/features/dataConnectorsV2/components/DataConnectorActions.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,189 @@ | ||
/*! | ||
* Copyright 2024 - Swiss Data Science Center (SDSC) | ||
* A partnership between École Polytechnique Fédérale de Lausanne (EPFL) and | ||
* Eidgenössische Technische Hochschule Zürich (ETHZ). | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import cx from "classnames"; | ||
import { useCallback, useEffect, useState } from "react"; | ||
import { Lock, Pencil, Trash, XLg } from "react-bootstrap-icons"; | ||
import { | ||
Button, | ||
Col, | ||
DropdownItem, | ||
Modal, | ||
ModalBody, | ||
ModalFooter, | ||
ModalHeader, | ||
Row, | ||
} from "reactstrap"; | ||
|
||
import { Loader } from "../../../components/Loader"; | ||
import DataConnectorModal from "./DataConnectorModal"; | ||
import type { DataConnectorRead } from "../../projectsV2/api/data-connectors.api"; | ||
import { useDeleteDataConnectorsByDataConnectorIdMutation } from "../../projectsV2/api/projectV2.enhanced-api"; | ||
import DataConnectorCredentialsModal from "./DataConnectorCredentialsModal"; | ||
import { ButtonWithMenuV2 } from "../../../components/buttons/Button"; | ||
|
||
interface DataConnectorDeleteModalProps { | ||
dataConnector: DataConnectorRead; | ||
isOpen: boolean; | ||
onDelete: () => void; | ||
toggleModal: () => void; | ||
} | ||
function DataConnectorDeleteModal({ | ||
ciyer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
dataConnector, | ||
onDelete, | ||
toggleModal, | ||
isOpen, | ||
}: DataConnectorDeleteModalProps) { | ||
const [deleteDataConnector, { isLoading, isSuccess }] = | ||
useDeleteDataConnectorsByDataConnectorIdMutation(); | ||
|
||
useEffect(() => { | ||
if (isSuccess) { | ||
onDelete(); | ||
} | ||
}, [isSuccess, onDelete]); | ||
const onDeleteDataCollector = () => { | ||
deleteDataConnector({ | ||
dataConnectorId: dataConnector.id, | ||
}); | ||
}; | ||
|
||
return ( | ||
<Modal size="lg" isOpen={isOpen} toggle={toggleModal} centered> | ||
<ModalHeader className="text-danger" toggle={toggleModal}> | ||
Delete data connector | ||
</ModalHeader> | ||
<ModalBody> | ||
<Row> | ||
<Col> | ||
<p> | ||
Are you sure you want to delete this data connector? It will | ||
affect all projects that use it. | ||
</p> | ||
<p className="mb-0"> | ||
Data connector: <code>{dataConnector.name}</code> | ||
</p> | ||
</Col> | ||
</Row> | ||
</ModalBody> | ||
<ModalFooter> | ||
<div className="d-flex justify-content-end"> | ||
<Button color="outline-danger" onClick={toggleModal}> | ||
<XLg className={cx("bi", "me-1")} /> | ||
Cancel | ||
</Button> | ||
<Button | ||
color="danger" | ||
className={cx("float-right", "ms-2")} | ||
data-cy="delete-data-connector-modal-button" | ||
type="submit" | ||
onClick={onDeleteDataCollector} | ||
> | ||
{isLoading ? ( | ||
<> | ||
<Loader className="me-1" inline size={16} /> | ||
Deleting data connector | ||
</> | ||
) : ( | ||
<> | ||
<Trash className={cx("bi", "me-1")} /> | ||
Remove data connector | ||
</> | ||
)} | ||
</Button> | ||
</div> | ||
</ModalFooter> | ||
</Modal> | ||
); | ||
} | ||
export default function DataConnectorActions({ | ||
dataConnector, | ||
toggleView, | ||
}: { | ||
dataConnector: DataConnectorRead; | ||
toggleView: () => void; | ||
}) { | ||
const [isCredentialsOpen, setCredentialsOpen] = useState(false); | ||
const [isDeleteOpen, setIsDeleteOpen] = useState(false); | ||
const [isEditOpen, setIsEditOpen] = useState(false); | ||
const onDelete = useCallback(() => { | ||
setIsDeleteOpen(false); | ||
toggleView(); | ||
}, [toggleView]); | ||
const toggleCredentials = useCallback(() => { | ||
setCredentialsOpen((open) => !open); | ||
}, []); | ||
const toggleDelete = useCallback(() => { | ||
setIsDeleteOpen((open) => !open); | ||
}, []); | ||
const toggleEdit = useCallback(() => { | ||
setIsEditOpen((open) => !open); | ||
}, []); | ||
|
||
const defaultAction = ( | ||
<Button | ||
className="text-nowrap" | ||
color="outline-primary" | ||
data-cy="data-connector-edit" | ||
onClick={toggleEdit} | ||
size="sm" | ||
> | ||
<Pencil className={cx("bi", "me-1")} /> | ||
Edit | ||
</Button> | ||
); | ||
|
||
return ( | ||
<> | ||
<ButtonWithMenuV2 | ||
color="outline-primary" | ||
default={defaultAction} | ||
preventPropagation | ||
size="sm" | ||
> | ||
<DropdownItem | ||
data-cy="data-connector-credentials" | ||
onClick={toggleCredentials} | ||
> | ||
<Lock className={cx("bi", "me-1")} /> | ||
Credentials | ||
</DropdownItem> | ||
<DropdownItem data-cy="data-connector-delete" onClick={toggleDelete}> | ||
<Trash className={cx("bi", "me-1")} /> | ||
Remove | ||
</DropdownItem> | ||
</ButtonWithMenuV2> | ||
<DataConnectorCredentialsModal | ||
dataConnector={dataConnector} | ||
setOpen={setCredentialsOpen} | ||
isOpen={isCredentialsOpen} | ||
/> | ||
<DataConnectorDeleteModal | ||
dataConnector={dataConnector} | ||
isOpen={isDeleteOpen} | ||
onDelete={onDelete} | ||
toggleModal={toggleDelete} | ||
/> | ||
<DataConnectorModal | ||
dataConnector={dataConnector} | ||
isOpen={isEditOpen} | ||
namespace={dataConnector.namespace} | ||
toggle={toggleEdit} | ||
/> | ||
</> | ||
); | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.