Skip to content
Open
Show file tree
Hide file tree
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
48 changes: 46 additions & 2 deletions frontend/common/stores/default-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ const defaultFlags = {
{
'key': 'base_url',
'label': 'Base URL',
'options': [
{ 'label': 'US', 'value': 'https://api2.amplitude.com' },
{ 'label': 'EU', 'value': 'https://api.eu.amplitude.com' },
{ 'label': 'Custom URL', 'value': 'custom' },
],
},
],
'image': '/static/images/integrations/amplitude.svg',
Expand Down Expand Up @@ -45,6 +50,15 @@ const defaultFlags = {
{
'key': 'base_url',
'label': 'Base URL',
'options': [
{ 'label': 'US1', 'value': 'https://api.datadoghw.com' },
{ 'label': 'US3', 'value': 'https://us3.datadoghq.com' },
{ 'label': 'US5', 'value': 'https://us5.datadoghq.com' },
{ 'label': 'EU1', 'value': 'https://app.datadoghq.eu' },
{ 'label': 'US1-FED', 'value': 'https://app.ddog-gov.com' },
{ 'label': 'AP1', 'value': 'https://ap1.datadoghq.com' },
{ 'label': 'Custom URL', 'value': 'custom' },
],
},
{
'hidden': true,
Expand Down Expand Up @@ -140,6 +154,15 @@ const defaultFlags = {
'description': 'Sends data on what flags served to each identity.',
'docs': 'https://docs.flagsmith.com/integrations/analytics/heap',
'fields': [
{
'key': 'base_url',
'label': 'Base URL',
'options': [
{ 'label': 'US', 'value': 'https://heapanalytics.com' },
{ 'label': 'EU', 'value': 'https://heapanalytics.eu' },
{ 'label': 'Custom URL', 'value': 'custom' },
],
},
{
'hidden': true,
'key': 'api_key',
Expand All @@ -163,6 +186,16 @@ const defaultFlags = {
'description': 'Sends data on what flags served to each identity.',
'docs': 'https://docs.flagsmith.com/integrations/analytics/mixpanel',
'fields': [
{
'key': 'base_url',
'label': 'Base URL',
'options': [
{ 'label': 'US', 'value': 'https://api.mixpanel.com' },
{ 'label': 'EU', 'value': 'https://api-eu.mixpanel.com' },
{ 'label': 'IN', 'value': 'https://api-in.mixpanel.com' },
{ 'label': 'Custom URL', 'value': 'custom' },
],
},
{
'hidden': true,
'key': 'api_key',
Expand All @@ -181,12 +214,23 @@ const defaultFlags = {
'fields': [
{
'key': 'base_url',
'label': 'New Relic Base URL',
'label': 'Base URL',
'options': [
{
'label': 'US',
'value': 'https://insights-collector.newrelic.com',
},
{
'label': 'EU',
'value': 'https://insights-collector.eu01.nr-data.net',
},
{ 'label': 'Custom URL', 'value': 'custom' },
],
},
{
'hidden': true,
'key': 'api_key',
'label': 'New Relic API Key',
'label': 'API Key',
},
{
'key': 'app_id',
Expand Down
24 changes: 22 additions & 2 deletions frontend/web/components/modals/CreateEditIntegrationModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
() => data || buildDefaultFormData(),
)
const [isLoading, setIsLoading] = useState<boolean>(false)
const [customUrlFields, setCustomUrlFields] = useState<Set<string>>(new Set())
const [error, setError] = useState<string | null>(null)
const [authorised, setAuthorised] = useState<boolean>(false)
const [selectedProjectId, setSelectedProjectId] = useState<
Expand Down Expand Up @@ -351,17 +352,36 @@
const selected = options.find(
(v: IntegrationFieldOption) => v.value === formData[field.key],
)
const isCustomUrl =
customUrlFields.has(field.key) ||
(!!formData[field.key] &&
!options.find((o) => o.value === formData[field.key]))
return (
<div className='full-width mb-2'>
<Select
onChange={(v: { value: string }) => update(field.key, v.value)}
onChange={(v: { value: string }) => {
if (v.value === 'custom') {
setCustomUrlFields((prev) => new Set(prev).add(field.key))
update(field.key, '')
} else {
setCustomUrlFields((prev) => {
const next = new Set(prev)
next.delete(field.key)
return next
})
update(field.key, v.value)
}
}}
options={options}
value={
selected
isCustomUrl

Check failure on line 377 in frontend/web/components/modals/CreateEditIntegrationModal.tsx

View workflow job for this annotation

GitHub Actions / Lint changed files

Do not nest ternary expressions
? { label: 'Custom URL', value: 'custom' }
: selected
? { label: selected.label, value: selected.value }
: { label: 'Please select' }
}
/>
{isCustomUrl && <div className='mt-2'>{renderFieldInput(field)}</div>}
</div>
)
}
Expand Down
Loading