Skip to content

Commit

Permalink
Fix lost schedule when editing connection name and ensure connection …
Browse files Browse the repository at this point in the history
…name is not cleared in other connection updates (#13510)

* Update updateConnection calls to include connection name
Update updateConnection calls in ConnectionName component to include all required fields

* Ensure that edit connection name sends update once
  • Loading branch information
edmundito authored Jun 6, 2022
1 parent 4b266c1 commit ab735e2
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 18 deletions.
1 change: 1 addition & 0 deletions airbyte-webapp/src/components/EntityTable/hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const useSyncActions = (): {
namespaceDefinition: connection.namespaceDefinition,
namespaceFormat: connection.namespaceFormat,
operations: connection.operations,
name: connection.name,
status: connection.status === ConnectionStatus.active ? ConnectionStatus.inactive : ConnectionStatus.active,
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { faPenToSquare } from "@fortawesome/free-regular-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { ChangeEvent, useState } from "react";
import React, { ChangeEvent, useState } from "react";
import styled from "styled-components";

import { Input } from "components";
Expand Down Expand Up @@ -114,12 +114,14 @@ const ConnectionName: React.FC<Props> = ({ connection }) => {
}
};

const onEscape = () => {
const onEscape: React.KeyboardEventHandler<HTMLInputElement> = (event) => {
event.stopPropagation();
setEditingState(false);
setConnectionName(name);
};

const onEnter = async () => {
const onEnter: React.KeyboardEventHandler<HTMLInputElement> = async (event) => {
event.stopPropagation();
await updateConnectionAsync();
};

Expand All @@ -132,12 +134,15 @@ const ConnectionName: React.FC<Props> = ({ connection }) => {
if (connection.name !== connectionName) {
setLoading(true);
await updateConnection({
name: connectionName,
connectionId: connection.connectionId,
namespaceDefinition: connection.namespaceDefinition,
syncCatalog: connection.syncCatalog,
status: connection.status,
prefix: connection.prefix,
schedule: connection.schedule || null,
namespaceDefinition: connection.namespaceDefinition,
namespaceFormat: connection.namespaceFormat,
operations: connection.operations,
status: connection.status,
name: connectionName,
});
setLoading(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const EnabledControl: React.FC<EnabledControlProps> = ({ connection, disabled, f
namespaceFormat: connection.namespaceFormat,
prefix: connection.prefix,
operations: connection.operations,
name: connection.name,
status: connection.status === ConnectionStatus.active ? ConnectionStatus.inactive : ConnectionStatus.active,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export const ReplicationView: React.FC<ReplicationViewProps> = ({ onAfterSaveSch
status: initialConnection.status || "",
withRefreshedCatalog: activeUpdatingSchemaMode,
sourceCatalogId: connection?.catalogId,
name: connection?.name,
});

setSaved(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ const TransformationView: React.FC<TransformationViewProps> = ({ connection }) =
syncCatalog: connection.syncCatalog,
connectionId: connection.connectionId,
status: connection.status,
name: connection.name,
operations: operations,
});

Expand Down
18 changes: 6 additions & 12 deletions airbyte-webapp/src/utils/addEnterEscFuncForInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,19 @@ import * as React from "react";

export default function addEnterEscFuncForInput(WrapperComponent: React.FC) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return (props: any) => {
return ({ onEscape, onEnter, onKeyDown: onKeyDownProp, ...props }: any) => {
const onKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {
// Escape Key Event
if (event.key === "Escape") {
if (props.onEscape) {
props.onEscape(event);
}
if (event.key === "Escape" && onEscape) {
onEscape(event);
}

// Enter Key Event
if (event.key === "Enter") {
if (props.onEnter) {
props.onEnter(event);
}
if (event.key === "Enter" && onEnter) {
onEnter(event);
}

if (props.onKeyDown) {
props.onKeyDown(event);
}
onKeyDownProp?.(event);
};

return <WrapperComponent {...props} onKeyDown={onKeyDown} />;
Expand Down

0 comments on commit ab735e2

Please sign in to comment.