Skip to content

Display new per-stream and global state to users when viewing connection settings #15020

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 6 commits into from
Jul 27, 2022
Merged
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 @@ -3,8 +3,22 @@ import { FormattedMessage, useIntl } from "react-intl";

import { H5, Card } from "components";

import { ConnectionState } from "core/request/AirbyteClient";
import { useGetConnectionState } from "hooks/services/useConnectionHook";

function formatState(
legacyState: ConnectionState["state"],
globalState: ConnectionState["globalState"],
streamState: ConnectionState["streamState"],
formatMessage: ReturnType<typeof useIntl>["formatMessage"]
) {
// This hierarchy assumes that for those connections which have both global and per-stream state, the global state contains a meaningful copy of any state which would also be saved per-stream
const formattedState = legacyState ?? globalState ?? streamState ?? null;
return formattedState
? JSON.stringify(formattedState, null, 2)
: formatMessage({ id: "tables.connectionState.noConnectionState" });
}

interface StateBlockProps {
connectionId: string;
}
Expand All @@ -13,11 +27,10 @@ export const StateBlock: React.FC<StateBlockProps> = ({ connectionId }) => {
const { formatMessage } = useIntl();
const state = useGetConnectionState(connectionId);

const stateString = useMemo(() => {
return state?.state
? JSON.stringify(state.state, null, 2)
: formatMessage({ id: "tables.connectionState.noConnectionState" });
}, [formatMessage, state.state]);
const stateString = useMemo(
() => formatState(state.state, state.globalState, state.streamState, formatMessage),
[formatMessage, state.state, state.globalState, state.streamState]
);

return (
<Card $withPadding>
Expand Down