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 lost schedule when editing connection name and ensure connection name is not cleared in other connection updates #13510

Merged
merged 2 commits into from
Jun 6, 2022
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
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