-
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 dark-mode-bridge
- Loading branch information
Showing
27 changed files
with
444 additions
and
142 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
interface CustomerProps { | ||
image: string | ||
alt: string | ||
className?: string | ||
} | ||
|
||
interface LogoProps { | ||
src: string | ||
alt: string | ||
className?: string | ||
} | ||
|
||
const Logo = ({ src, alt, className = '' }: LogoProps): JSX.Element => ( | ||
<img className={`bg-transparent w-full px-3 py-3 h-10 ${className}`} src={src} alt={alt} /> | ||
) | ||
|
||
export const CustomerLogo = ({ image, alt, className = '' }: CustomerProps): JSX.Element => { | ||
return ( | ||
<li className="flex items-center justify-center w-full"> | ||
<Logo className={className} src={image} alt={alt} /> | ||
</li> | ||
) | ||
} |
63 changes: 63 additions & 0 deletions
63
frontend/src/lib/components/ReverseProxyChecker/reverseProxyCheckerLogic.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,63 @@ | ||
import { expectLogic } from 'kea-test-utils' | ||
|
||
import { useMocks } from '~/mocks/jest' | ||
import { initKeaTests } from '~/test/init' | ||
|
||
import { reverseProxyCheckerLogic } from './reverseProxyCheckerLogic' | ||
|
||
const hasReverseProxyValues = [['https://proxy.example.com'], [null]] | ||
const doesNotHaveReverseProxyValues = [[null], [null]] | ||
|
||
const useMockedValues = (results: (string | null)[][]): void => { | ||
useMocks({ | ||
post: { | ||
'/api/projects/:team/query': () => [ | ||
200, | ||
{ | ||
results, | ||
}, | ||
], | ||
}, | ||
}) | ||
} | ||
|
||
describe('reverseProxyCheckerLogic', () => { | ||
let logic: ReturnType<typeof reverseProxyCheckerLogic.build> | ||
|
||
beforeEach(() => { | ||
initKeaTests() | ||
localStorage.clear() | ||
logic = reverseProxyCheckerLogic() | ||
}) | ||
|
||
afterEach(() => { | ||
logic.unmount() | ||
}) | ||
|
||
it('should not have a reverse proxy set - when no data', async () => { | ||
useMockedValues([]) | ||
|
||
logic.mount() | ||
await expectLogic(logic).toFinishAllListeners().toMatchValues({ | ||
hasReverseProxy: false, | ||
}) | ||
}) | ||
|
||
it('should not have a reverse proxy set - when data with no lib_custom_api_host values', async () => { | ||
useMockedValues(doesNotHaveReverseProxyValues) | ||
|
||
logic.mount() | ||
await expectLogic(logic).toFinishAllListeners().toMatchValues({ | ||
hasReverseProxy: false, | ||
}) | ||
}) | ||
|
||
it('should have a reverse proxy set', async () => { | ||
useMockedValues(hasReverseProxyValues) | ||
|
||
logic.mount() | ||
await expectLogic(logic).toFinishAllListeners().toMatchValues({ | ||
hasReverseProxy: true, | ||
}) | ||
}) | ||
}) |
49 changes: 49 additions & 0 deletions
49
frontend/src/lib/components/ReverseProxyChecker/reverseProxyCheckerLogic.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,49 @@ | ||
import { afterMount, kea, path, reducers } from 'kea' | ||
import { loaders } from 'kea-loaders' | ||
import api from 'lib/api' | ||
|
||
import { HogQLQuery, NodeKind } from '~/queries/schema' | ||
import { hogql } from '~/queries/utils' | ||
|
||
import type { reverseProxyCheckerLogicType } from './reverseProxyCheckerLogicType' | ||
|
||
const CHECK_INTERVAL_MS = 1000 * 60 * 60 // 1 hour | ||
|
||
export const reverseProxyCheckerLogic = kea<reverseProxyCheckerLogicType>([ | ||
path(['components', 'ReverseProxyChecker', 'reverseProxyCheckerLogic']), | ||
loaders({ | ||
hasReverseProxy: [ | ||
false as boolean | null, | ||
{ | ||
loadHasReverseProxy: async () => { | ||
const query: HogQLQuery = { | ||
kind: NodeKind.HogQLQuery, | ||
query: hogql`SELECT properties.$lib_custom_api_host AS lib_custom_api_host | ||
FROM events | ||
WHERE timestamp >= now() - INTERVAL 1 DAY | ||
AND timestamp <= now() | ||
ORDER BY timestamp DESC | ||
limit 10`, | ||
} | ||
|
||
const res = await api.query(query) | ||
return !!res.results?.find((x) => !!x[0]) | ||
}, | ||
}, | ||
], | ||
}), | ||
reducers({ | ||
lastCheckedTimestamp: [ | ||
0, | ||
{ persist: true }, | ||
{ | ||
loadHasReverseProxySuccess: () => Date.now(), | ||
}, | ||
], | ||
}), | ||
afterMount(({ actions, values }) => { | ||
if (values.lastCheckedTimestamp < Date.now() - CHECK_INTERVAL_MS) { | ||
actions.loadHasReverseProxy() | ||
} | ||
}), | ||
]) |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.