-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🪟 🎨 Add FCP enrollment banner on source/destination item page (#7082)
- Loading branch information
Showing
7 changed files
with
114 additions
and
14 deletions.
There are no files selected for viewing
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
72 changes: 72 additions & 0 deletions
72
...e-webapp/src/packages/cloud/components/experiments/FreeConnectorProgram/lib/model.test.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,72 @@ | ||
import { mockConnection } from "test-utils"; | ||
import { mockDestinationDefinition } from "test-utils/mock-data/mockDestination"; | ||
import { mockSourceDefinition } from "test-utils/mock-data/mockSource"; | ||
|
||
import { DestinationDefinitionRead, SourceDefinitionRead, WebBackendConnectionRead } from "core/request/AirbyteClient"; | ||
|
||
import { | ||
isConnectionEligibleForFCP, | ||
isDestinationDefinitionEligibleForFCP, | ||
isSourceDefinitionEligibleForFCP, | ||
} from "./model"; | ||
|
||
const deprecatedConnection: WebBackendConnectionRead = { ...mockConnection, status: "deprecated" }; | ||
const alphaSource: SourceDefinitionRead = { ...mockSourceDefinition, releaseStage: "alpha" }; | ||
const betaSource: SourceDefinitionRead = { ...mockSourceDefinition, releaseStage: "beta" }; | ||
const gaSource: SourceDefinitionRead = { | ||
...mockSourceDefinition, | ||
releaseStage: "generally_available", | ||
}; | ||
const customSource: SourceDefinitionRead = { ...mockSourceDefinition, releaseStage: "custom" }; | ||
const alphaDestination: DestinationDefinitionRead = { ...mockDestinationDefinition, releaseStage: "alpha" }; | ||
const betaDestination: DestinationDefinitionRead = { ...mockDestinationDefinition, releaseStage: "beta" }; | ||
const gaDestination: DestinationDefinitionRead = { | ||
...mockDestinationDefinition, | ||
releaseStage: "generally_available", | ||
}; | ||
const customDestination: DestinationDefinitionRead = { ...mockDestinationDefinition, releaseStage: "custom" }; | ||
|
||
describe(`${isConnectionEligibleForFCP.name}`, () => { | ||
it("returns true for an alpha source and GA destination", () => { | ||
expect(isConnectionEligibleForFCP(mockConnection, alphaSource, gaDestination)).toBe(true); | ||
}); | ||
it("returns true for a GA source and alpha destination", () => { | ||
expect(isConnectionEligibleForFCP(mockConnection, gaSource, alphaDestination)).toBe(true); | ||
}); | ||
it("returns false for a deprecated connection", () => { | ||
expect(isConnectionEligibleForFCP(deprecatedConnection, alphaSource, alphaDestination)).toBe(false); | ||
}); | ||
it("returns false for a custom source", () => { | ||
expect(isConnectionEligibleForFCP(deprecatedConnection, customSource, alphaDestination)).toBe(false); | ||
}); | ||
}); | ||
|
||
describe(`${isSourceDefinitionEligibleForFCP.name}`, () => { | ||
it("returns true for an alpha destination", () => { | ||
expect(isSourceDefinitionEligibleForFCP(alphaSource)).toBe(true); | ||
}); | ||
it("returns true for an beta destination", () => { | ||
expect(isSourceDefinitionEligibleForFCP(betaSource)).toBe(true); | ||
}); | ||
it("returns false for an GA destination", () => { | ||
expect(isSourceDefinitionEligibleForFCP(gaSource)).toBe(false); | ||
}); | ||
it("returns false for a custom destination", () => { | ||
expect(isSourceDefinitionEligibleForFCP(customSource)).toBe(false); | ||
}); | ||
}); | ||
|
||
describe(`${isDestinationDefinitionEligibleForFCP.name}`, () => { | ||
it("returns true for an alpha destination", () => { | ||
expect(isDestinationDefinitionEligibleForFCP(alphaDestination)).toBe(true); | ||
}); | ||
it("returns true for an beta destination", () => { | ||
expect(isDestinationDefinitionEligibleForFCP(betaDestination)).toBe(true); | ||
}); | ||
it("returns false for an GA destination", () => { | ||
expect(isDestinationDefinitionEligibleForFCP(gaDestination)).toBe(false); | ||
}); | ||
it("returns false for a custom destination", () => { | ||
expect(isDestinationDefinitionEligibleForFCP(customDestination)).toBe(false); | ||
}); | ||
}); |
26 changes: 24 additions & 2 deletions
26
airbyte-webapp/src/packages/cloud/components/experiments/FreeConnectorProgram/lib/model.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 |
---|---|---|
@@ -1,3 +1,25 @@ | ||
import { ReleaseStage } from "core/request/AirbyteClient"; | ||
import { DestinationDefinitionRead, SourceDefinitionRead, WebBackendConnectionRead } from "core/request/AirbyteClient"; | ||
|
||
export const freeReleaseStages: ReleaseStage[] = ["alpha", "beta"]; | ||
export const freeReleaseStages = ["alpha", "beta"]; | ||
|
||
export const isConnectionEligibleForFCP = ( | ||
connection: WebBackendConnectionRead, | ||
sourceDefinition: SourceDefinitionRead, | ||
destinationDefinition: DestinationDefinitionRead | ||
): boolean => { | ||
return !!( | ||
connection.status !== "deprecated" && | ||
sourceDefinition.releaseStage && | ||
destinationDefinition.releaseStage && | ||
(freeReleaseStages.includes(sourceDefinition.releaseStage) || | ||
freeReleaseStages.includes(destinationDefinition.releaseStage)) | ||
); | ||
}; | ||
|
||
export const isSourceDefinitionEligibleForFCP = (sourceDefinition: SourceDefinitionRead): boolean => { | ||
return !!(sourceDefinition.releaseStage && freeReleaseStages.includes(sourceDefinition.releaseStage)); | ||
}; | ||
|
||
export const isDestinationDefinitionEligibleForFCP = (destinationDefinition: DestinationDefinitionRead): boolean => { | ||
return !!(destinationDefinition.releaseStage && freeReleaseStages.includes(destinationDefinition.releaseStage)); | ||
}; |
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
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