Skip to content
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

Fix several minor data-connector bugs #3400

Merged
merged 4 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -191,18 +191,12 @@ export default function DataConnectorModalFooter({
useEffect(() => {
const dataConnectorId = createResult.data?.id;
if (dataConnectorId == null) return;
const shouldSaveCredentials = shouldSaveDataConnectorCredentials(
flatDataConnector.options,
cloudStorageState.saveCredentials,
validationResult?.isSuccess ?? false
);
if (!shouldSaveCredentials) return;

const options = flatDataConnector.options as CloudStorageDetailsOptions;
if (!schemata) return;
const sensitiveFieldNames = findSensitive(
schemata.find((s) => s.prefix === flatDataConnector.schema)
);
const options = flatDataConnector.options as CloudStorageDetailsOptions;
if (!options) return;
const dataConnectorSecretPatchList = sensitiveFieldNames
.map((name) => ({
name,
Expand All @@ -213,6 +207,13 @@ export default function DataConnectorModalFooter({
name: secret.name,
value: "" + secret.value,
}));
const shouldSaveCredentials = shouldSaveDataConnectorCredentials(
dataConnectorSecretPatchList,
cloudStorageState.saveCredentials,
validationResult?.isSuccess ?? false
);
if (!shouldSaveCredentials) return;

saveCredentials({
dataConnectorId,
dataConnectorSecretPatchList,
Expand Down Expand Up @@ -365,12 +366,12 @@ export default function DataConnectorModalFooter({
}

function shouldSaveDataConnectorCredentials(
flatDataConnectorOptions: CloudStorageDetailsOptions | undefined,
dataConnectorSecretPatchList: { name: string; value: string }[],
stateSaveCredentials: boolean,
validationSucceeded: boolean
) {
return !!(
flatDataConnectorOptions &&
dataConnectorSecretPatchList.length > 0 &&
stateSaveCredentials &&
validationSucceeded
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ function DataConnectorResultAlertContent({
</li>
) : null;
return (
<p className="mb-0">
<div className="mb-0">
{dataConnectorFragment}
{credentialSaveFragment && <ul>{credentialSaveFragment}</ul>}
{projectLinkFragment && <ul>{projectLinkFragment}</ul>}
</p>
</div>
);
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
@import "~bootstrap/scss/functions";
@import "~bootstrap/scss/variables";

.control {
cursor: pointer !important;
}
Expand All @@ -14,3 +17,7 @@
background-color: #e4e7ea80;
}
}

.zDropdown {
z-index: $zindex-dropdown !important;
}
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,14 @@ const selectClassNames: ClassNamesConfig<ResponseNamespace, false> = {
styles.control
),
dropdownIndicator: () => cx("pe-3"),
menu: () => cx("bg-white", "rounded-bottom", "border", "border-top-0"),
menu: () =>
cx(
"bg-white",
"rounded-bottom",
"border",
"border-top-0",
styles.zDropdown
),
menuList: () => cx("d-grid"),
option: ({ isFocused, isSelected }) =>
cx(
Expand Down
44 changes: 44 additions & 0 deletions tests/cypress/e2e/groupV2DataConnectorCredentials.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,50 @@ describe("Set up data connectors with credentials", () => {
cy.wait("@listDataConnectors");
});

it("do not store credentials if there are none", () => {
fixtures
.listDataConnectors({ namespace: "test-2-group-v2" })
.testCloudStorage({ success: true })
.postDataConnector({ namespace: "test-2-group-v2" })
.dataConnectorSecrets({
fixture: "dataConnector/data-connector-secrets-empty.json",
})
.patchDataConnectorSecrets({
content: [],
// No call to postCloudStorageSecrets is expected
shouldNotBeCalled: true,
});
cy.visit("/v2/groups/test-2-group-v2");
cy.wait("@readGroupV2");
// add data connector
cy.getDataCy("add-data-connector").should("be.visible").click();
cy.wait("@getStorageSchema");

// Pick a provider
cy.getDataCy("data-storage-s3").click();
cy.getDataCy("data-provider-Switch").click();
cy.getDataCy("data-connector-edit-next-button").click();

// // Fill out the details
cy.get("#sourcePath").type("bucket/my-source");
cy.get("#endpoint").clear().type("https://s3-zh.os.switch.ch");
cy.getDataCy("test-data-connector-button").click();
cy.getDataCy("add-data-connector-continue-button")
.contains("Continue")
.click();
cy.getDataCy("data-connector-edit-mount").within(() => {
cy.get("#name").type("example storage without credentials");
});
cy.getDataCy("data-connector-edit-update-button").click();
cy.wait("@postDataConnector");
cy.getDataCy("data-connector-edit-body").should(
"contain.text",
"The data connector test-2-group-v2/example-storage-without-credentials has been successfully added."
);
cy.getDataCy("data-connector-edit-close-button").click();
cy.wait("@listDataConnectors");
});

it("resets validation state when content changes", () => {
fixtures
.getStorageSchema({ fixture: "cloudStorage/storage-schema-s3.json" })
Expand Down
Loading