-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🪟 🎉 Select dbt jobs with dropdown (#19502)
* Add wrapper for cloud dbt endpoint Also includes a cheeky little test usage which probably should have had a name starting with an underscore (I did not commit the test code which added the new variable's contents to `(window as any).availableJobs`, on grounds that it was very ugly, but I did want to have the import and call of the wrapper function hit the git history here). * Add dbt Cloud jobs via dropdown (WIP: breaks if no integration) Selecting job from dropdown adds it to saved jobs, but the new endpoint is unconditionally called even though it will always throw an error for users with no dbt Cloud integration configured. * Refactor to stop errors in non-dbt-integrated workspaces Well, I suppose throwing a runtime error for every connection which could support dbt Cloud jobs but is part of a workspace with no integration set up, but that doesn't exactly seem ideal. Instead, this pulls all logic out of the top-level card except for pulling the dbt Cloud integration information; then it delegates the rest to either of two fairly self-contained components, `NoDbtIntegration` or the new `DbtJobsForm`. The immediate benefit is that I have a nice component boundary in which I can unconditionally run dbt-Cloud-only logic to fetch available jobs. * Filter already-selected jobs out of dropdown * Use dbt's jobNames and read-only {account,job}Id in job list * Remove obsolete yup validations for dbt Cloud jobs Since the values are now supplied by dbt Cloud via API, the user no longer has to manually input anything; and this sudden lack of user input rather obviates the need to validate user input. * Add button loading state when saving dbt Cloud jobs
- Loading branch information
1 parent
ec7963d
commit 1dbad96
Showing
5 changed files
with
260 additions
and
135 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
airbyte-webapp/src/packages/cloud/lib/domain/dbtCloud/api.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { apiOverride } from "core/request/apiOverride"; | ||
|
||
/** | ||
* Get the available dbt Cloud jobs associated with the given workspace config. | ||
*/ | ||
export interface WorkspaceGetDbtJobsRequest { | ||
workspaceId: WorkspaceId; | ||
/** The config id associated with the dbt Cloud config, references the webhookConfigId in the core API. */ | ||
dbtConfigId: string; | ||
} | ||
|
||
/** | ||
* The available dbt Cloud jobs for the requested workspace config | ||
*/ | ||
export interface WorkspaceGetDbtJobsResponse { | ||
availableDbtJobs: DbtCloudJobInfo[]; | ||
} | ||
|
||
/** | ||
* A dbt Cloud job | ||
*/ | ||
export interface DbtCloudJobInfo { | ||
/** The account id associated with the job */ | ||
accountId: number; | ||
/** The the specific job id returned by the dbt Cloud API */ | ||
jobId: number; | ||
/** The human-readable name of the job returned by the dbt Cloud API */ | ||
jobName: string; | ||
} | ||
|
||
/** | ||
* @summary Calls the dbt Cloud `List Accounts` and `List jobs` APIs to get the list of available jobs for the dbt auth token associated with the requested workspace config. | ||
*/ | ||
export const webBackendGetAvailableDbtJobsForWorkspace = ( | ||
workspaceGetDbtJobsRequest: WorkspaceGetDbtJobsRequest, | ||
options?: SecondParameter<typeof apiOverride> | ||
) => { | ||
return apiOverride<WorkspaceGetDbtJobsResponse>( | ||
{ | ||
url: `/v1/web_backend/cloud_workspaces/get_available_dbt_jobs`, | ||
method: "post", | ||
headers: { "Content-Type": "application/json" }, | ||
data: workspaceGetDbtJobsRequest, | ||
}, | ||
options | ||
); | ||
}; | ||
|
||
/** | ||
* Workspace Id from OSS Airbyte instance | ||
*/ | ||
export type WorkspaceId = string; | ||
|
||
// eslint-disable-next-line | ||
type SecondParameter<T extends (...args: any) => any> = T extends (config: any, args: infer P) => any ? P : never; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./api"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.