-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into sessions-global-in
- Loading branch information
Showing
22 changed files
with
598 additions
and
10 deletions.
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
frontend/src/lib/integrations/IntegrationScopesWarning.tsx
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,65 @@ | ||
import api from 'lib/api' | ||
import { LemonBanner } from 'lib/lemon-ui/LemonBanner' | ||
import { Link } from 'lib/lemon-ui/Link' | ||
import { useMemo } from 'react' | ||
|
||
import { HogFunctionInputSchemaType, IntegrationType } from '~/types' | ||
|
||
export function IntegrationScopesWarning({ | ||
integration, | ||
schema, | ||
}: { | ||
integration: IntegrationType | ||
schema?: HogFunctionInputSchemaType | ||
}): JSX.Element { | ||
const getScopes = useMemo((): string[] => { | ||
const scopes: any[] = [] | ||
const possibleScopeLocation = [integration.config.scope, integration.config.scopes] | ||
|
||
possibleScopeLocation.map((scope) => { | ||
if (typeof scope === 'string') { | ||
scopes.push(scope.split(' ')) | ||
scopes.push(scope.split(',')) | ||
} | ||
if (typeof scope === 'object') { | ||
scopes.push(scope) | ||
} | ||
}) | ||
return scopes | ||
.filter((scope: any) => typeof scope === 'object') | ||
.reduce((a, b) => (a.length > b.length ? a : b), []) | ||
}, [integration.config]) | ||
|
||
const requiredScopes = schema?.requiredScopes?.split(' ') || [] | ||
const missingScopes = requiredScopes.filter((scope: string) => !getScopes.includes(scope)) | ||
|
||
if (missingScopes.length === 0 || getScopes.length === 0) { | ||
return <></> | ||
} | ||
return ( | ||
<div className="p-2"> | ||
<LemonBanner | ||
type="error" | ||
action={{ | ||
children: 'Reconnect', | ||
disableClientSideRouting: true, | ||
to: api.integrations.authorizeUrl({ | ||
kind: integration.kind, | ||
next: window.location.pathname, | ||
}), | ||
}} | ||
> | ||
<span>Required scopes are missing: [{missingScopes.join(', ')}].</span> | ||
{integration.kind === 'hubspot' ? ( | ||
<span> | ||
Note that some features may not be available on your current HubSpot plan. Check out{' '} | ||
<Link to="https://developers.hubspot.com/beta-docs/guides/apps/authentication/scopes"> | ||
this page | ||
</Link>{' '} | ||
for more details. | ||
</span> | ||
) : null} | ||
</LemonBanner> | ||
</div> | ||
) | ||
} |
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
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
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
Oops, something went wrong.