-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add referral source to cloud on data plane (#3096)
* cloud auth referral source * minor clarity * k * minor modification to be best practice * typing * Update ReferralSourceSelector.tsx * Update ReferralSourceSelector.tsx --------- Co-authored-by: hagen-danswer <[email protected]>
- Loading branch information
1 parent
fdc4811
commit 22189f0
Showing
14 changed files
with
176 additions
and
21 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,12 +14,12 @@ | |
|
||
def test_multi_tenant_access_control(reset_multitenant: None) -> None: | ||
# Create Tenant 1 and its Admin User | ||
TenantManager.create("tenant_dev1", "[email protected]") | ||
TenantManager.create("tenant_dev1", "[email protected]", "Data Plane Registration") | ||
test_user1: DATestUser = UserManager.create(name="test1", email="[email protected]") | ||
assert UserManager.verify_role(test_user1, UserRole.ADMIN) | ||
|
||
# Create Tenant 2 and its Admin User | ||
TenantManager.create("tenant_dev2", "[email protected]") | ||
TenantManager.create("tenant_dev2", "[email protected]", "Data Plane Registration") | ||
test_user2: DATestUser = UserManager.create(name="test2", email="[email protected]") | ||
assert UserManager.verify_role(test_user2, UserRole.ADMIN) | ||
|
||
|
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 |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
|
||
# Test flow from creating tenant to registering as a user | ||
def test_tenant_creation(reset_multitenant: None) -> None: | ||
TenantManager.create("tenant_dev", "[email protected]") | ||
TenantManager.create("tenant_dev", "[email protected]", "Data Plane Registration") | ||
test_user: DATestUser = UserManager.create(name="test", email="[email protected]") | ||
|
||
assert UserManager.verify_role(test_user, UserRole.ADMIN) | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
"use client"; | ||
|
||
import { useState } from "react"; | ||
import { | ||
Select, | ||
SelectContent, | ||
SelectItem, | ||
SelectTrigger, | ||
SelectValue, | ||
} from "@/components/ui/select"; | ||
import { Label } from "@/components/admin/connectors/Field"; | ||
|
||
interface ReferralSourceSelectorProps { | ||
defaultValue?: string; | ||
} | ||
|
||
const ReferralSourceSelector: React.FC<ReferralSourceSelectorProps> = ({ | ||
defaultValue, | ||
}) => { | ||
const [referralSource, setReferralSource] = useState(defaultValue); | ||
|
||
const referralOptions = [ | ||
{ value: "search", label: "Search Engine (Google/Bing)" }, | ||
{ value: "friend", label: "Friend/Colleague" }, | ||
{ value: "linkedin", label: "LinkedIn" }, | ||
{ value: "twitter", label: "Twitter" }, | ||
{ value: "hackernews", label: "HackerNews" }, | ||
{ value: "reddit", label: "Reddit" }, | ||
{ value: "youtube", label: "YouTube" }, | ||
{ value: "podcast", label: "Podcast" }, | ||
{ value: "blog", label: "Article/Blog" }, | ||
{ value: "ads", label: "Advertisements" }, | ||
{ value: "other", label: "Other" }, | ||
]; | ||
|
||
const handleChange = (value: string) => { | ||
setReferralSource(value); | ||
const cookies = require("js-cookie"); | ||
cookies.set("referral_source", value, { | ||
expires: 365, | ||
path: "/", | ||
sameSite: "strict", | ||
}); | ||
}; | ||
|
||
return ( | ||
<div className="w-full max-w-sm gap-y-2 flex flex-col mx-auto"> | ||
<Label className="text-text-950" small={false}> | ||
How did you hear about us? | ||
</Label> | ||
<Select value={referralSource} onValueChange={handleChange}> | ||
<SelectTrigger | ||
id="referral-source" | ||
className="w-full border-gray-300 rounded-md shadow-sm focus:border-indigo-500 focus:ring-indigo-500" | ||
> | ||
<SelectValue placeholder="Select an option" /> | ||
</SelectTrigger> | ||
<SelectContent className="max-h-60 overflow-y-auto"> | ||
{referralOptions.map((option) => ( | ||
<SelectItem | ||
key={option.value} | ||
value={option.value} | ||
className="py-2 px-3 hover:bg-indigo-100 cursor-pointer" | ||
> | ||
{option.label} | ||
</SelectItem> | ||
))} | ||
</SelectContent> | ||
</Select> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ReferralSourceSelector; |
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.