Skip to content

Commit

Permalink
Disallow deleting jobs while an update is pending (#19617)
Browse files Browse the repository at this point in the history
* Clean up type definitions

Also removes the "Error" from the `{setV,v}alidationErrorMessage`
variables to pave the way for success feedback.

* Show success message and clear form on successful dbt cloud token submission

* Always clear form error state and message in sync

* Disallow deleting jobs while an update is pending
  • Loading branch information
ambirdsall committed Nov 21, 2022
1 parent 3eea315 commit bab76fb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions airbyte-webapp/src/packages/cloud/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
"settings.integrationSettings.dbtCloudSettings.form.singleTenantUrl": "Single-tenant URL",
"settings.integrationSettings.dbtCloudSettings.form.testConnection": "Test connection",
"settings.integrationSettings.dbtCloudSettings.form.submit": "Save changes",
"settings.integrationSettings.dbtCloudSettings.form.success": "Service Token saved successfully",
"settings.generalSettings": "General Settings",
"settings.generalSettings.changeWorkspace": "Change Workspace",
"settings.generalSettings.form.name.label": "Workspace name",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Field, FieldProps, Form, Formik } from "formik";
import React, { useState } from "react";
import { FormattedMessage } from "react-intl";
import { FormattedMessage, useIntl } from "react-intl";

import { LabeledInput } from "components/LabeledInput";
import { Button } from "components/ui/Button";
Expand All @@ -11,6 +11,7 @@ import { Content, SettingsCard } from "pages/SettingsPage/pages/SettingsComponen
import styles from "./DbtCloudSettingsView.module.scss";

export const DbtCloudSettingsView: React.FC = () => {
const { formatMessage } = useIntl();
const { mutate: submitDbtCloudIntegrationConfig, isLoading } = useSubmitDbtCloudIntegrationConfig();
const [hasValidationError, setHasValidationError] = useState(false);
const [validationMessage, setValidationMessage] = useState("");
Expand All @@ -21,15 +22,21 @@ export const DbtCloudSettingsView: React.FC = () => {
initialValues={{
serviceToken: "",
}}
onSubmit={({ serviceToken }) => {
onSubmit={({ serviceToken }, { resetForm }) => {
setHasValidationError(false);
setValidationMessage("");
return submitDbtCloudIntegrationConfig(serviceToken, {
onError: (e) => {
setHasValidationError(true);

setValidationMessage(e.message.replace("Internal Server Error: ", ""));
},
onSuccess: () => setValidationMessage(""),
onSuccess: () => {
setValidationMessage(
formatMessage({ id: "settings.integrationSettings.dbtCloudSettings.form.success" })
);
resetForm();
},
});
}}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ const DbtJobsList = ({ jobs, remove, dirty, isLoading }: DbtJobsListProps) => {
<FormattedMessage id="connection.dbtCloudJobs.explanation" />
</Text>
{jobs.map((job, i) => (
<JobsListItem key={i} job={job} removeJob={() => remove(i)} />
<JobsListItem key={i} job={job} removeJob={() => remove(i)} isLoading={isLoading} />
))}
</>
) : (
Expand Down Expand Up @@ -184,8 +184,9 @@ const DbtJobsList = ({ jobs, remove, dirty, isLoading }: DbtJobsListProps) => {
interface JobsListItemProps {
job: DbtCloudJob;
removeJob: () => void;
isLoading: boolean;
}
const JobsListItem = ({ job, removeJob }: JobsListItemProps) => {
const JobsListItem = ({ job, removeJob, isLoading }: JobsListItemProps) => {
const { formatMessage } = useIntl();
// TODO if `job.jobName` is undefined, that means we failed to match any of the
// dbt-Cloud-supplied jobs with the saved job. This means one of two things has
Expand Down Expand Up @@ -218,6 +219,7 @@ const JobsListItem = ({ job, removeJob }: JobsListItemProps) => {
size="lg"
className={styles.jobListItemDelete}
onClick={removeJob}
disabled={isLoading}
aria-label={formatMessage({ id: "connection.dbtCloudJobs.job.deleteButton" })}
>
<FontAwesomeIcon icon={faXmark} height="21" width="21" />
Expand Down

0 comments on commit bab76fb

Please sign in to comment.