Compare commits

..

7 Commits

Author SHA1 Message Date
Szilárd Dóró
378a6684b0 Merge pull request #1451 from nhost/changeset-release/main
chore: update versions
2023-01-02 11:33:20 +01:00
github-actions[bot]
1999ae09e6 chore: update versions 2023-01-02 09:47:28 +00:00
Szilárd Dóró
0fe48a0833 Merge pull request #1425 from nhost/fix/refresh-after-provisioning
fix(dashboard): provisioning status polling
2023-01-02 10:46:12 +01:00
Szilárd Dóró
52ccfdec89 Merge branch 'main' into fix/refresh-after-provisioning 2023-01-02 10:05:46 +01:00
Szilárd Dóró
8956d47bce fix(dashboard): start polling manually
reference issue: https://github.com/apollographql/apollo-client/issues/9819
2022-12-22 18:22:00 +01:00
Szilárd Dóró
dd0738d5f7 chore(dashboard): add changeset 2022-12-22 17:57:36 +01:00
Szilárd Dóró
11d77d6011 fix(dashboard): provisioning status polling 2022-12-22 17:53:07 +01:00
10 changed files with 65 additions and 25 deletions

View File

@@ -1,5 +1,11 @@
# @nhost/dashboard
## 0.7.13
### Patch Changes
- dd0738d5: fix(dashboard): provisioning status polling
## 0.7.12
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost/dashboard",
"version": "0.7.12",
"version": "0.7.13",
"private": true,
"scripts": {
"preinstall": "npx only-allow pnpm",
@@ -17,7 +17,7 @@
"build-storybook": "build-storybook"
},
"dependencies": {
"@apollo/client": "^3.6.2",
"@apollo/client": "^3.7.3",
"@codemirror/language": "^6.3.0",
"@emotion/cache": "^11.10.5",
"@emotion/react": "^11.10.5",

View File

@@ -32,9 +32,12 @@ export default function ConnectGithubModal({ close }: ConnectGithubModalProps) {
useState<ConnectGithubModalState>('CONNECTING');
const [selectedRepoId, setSelectedRepoId] = useState<string | null>(null);
const { data, loading, error } = useGetGithubRepositoriesQuery({
pollInterval: 2000,
});
const { data, loading, error, startPolling } =
useGetGithubRepositoriesQuery();
useEffect(() => {
startPolling(2000);
}, [startPolling]);
const handleSelectAnotherRepository = () => {
setSelectedRepoId(null);

View File

@@ -13,14 +13,17 @@ export function FunctionsLogsTerminalPage({ functionName }: any) {
const { currentApplication } = useCurrentWorkspaceAndApplication();
const [normalizedFunctionData, setNormalizedFunctionData] = useState(null);
const { data } = useGetFunctionLogQuery({
const { data, startPolling } = useGetFunctionLogQuery({
variables: {
subdomain: currentApplication.subdomain,
functionPaths: [functionName?.split('/').slice(1, 3).join('/')],
},
pollInterval: 3000,
});
useEffect(() => {
startPolling(3000);
}, [startPolling]);
useEffect(() => {
if (!data || data.getFunctionLogs.length === 0) {
return;

View File

@@ -9,6 +9,7 @@ import { updateOwnCache } from '@/utils/updateOwnCache';
import { useApolloClient } from '@apollo/client';
import { useUserData } from '@nhost/nextjs';
import { useRouter } from 'next/router';
import { useEffect } from 'react';
export function InviteAnnounce() {
const user = useUserData();
@@ -21,15 +22,18 @@ export function InviteAnnounce() {
useSubmitState();
// @FIX: We probably don't want to poll every ten seconds for possible invites. (We can change later depending on how it works in production.) Maybe just on the workspace page?
const { data, loading, error, refetch } =
const { data, loading, error, refetch, startPolling } =
useGetWorkspaceMemberInvitesToManageQuery({
variables: {
userId: user?.id,
},
pollInterval: 15000,
skip: !isPlatform,
});
useEffect(() => {
startPolling(15000);
}, [startPolling]);
if (loading) {
return null;
}

View File

@@ -8,9 +8,11 @@ import { useEffect } from 'react';
export default function SidebarWorkspaces() {
const user = nhost.auth.getUser();
const { data, loading, stopPolling } = useGetWorkspacesQuery({
pollInterval: 1000,
});
const { data, loading, startPolling, stopPolling } = useGetWorkspacesQuery();
useEffect(() => {
startPolling(1000);
}, [startPolling]);
// keep polling for workspaces until there is a workspace available.
// We do this because when a user signs up a workspace is created automatically

View File

@@ -18,12 +18,15 @@ export default function useProjectRedirectWhenReady(
options: UseProjectRedirectWhenReadyOptions = {},
) {
const { currentApplication } = useCurrentWorkspaceAndApplication();
const { data, client, ...rest } = useGetApplicationStateQuery({
pollInterval: 2000,
const { data, client, startPolling, ...rest } = useGetApplicationStateQuery({
...options,
variables: { ...options.variables, appId: currentApplication.id },
});
useEffect(() => {
startPolling(options.pollInterval || 2000);
}, [options.pollInterval, startPolling]);
useEffect(() => {
async function updateOwnCache() {
await client.refetchQueries({

View File

@@ -21,11 +21,12 @@ export function useCheckProvisioning() {
const [currentApplicationState, setCurrentApplicationState] =
useState<ApplicationStateMetadata>({ state: ApplicationStatus.Empty });
const isPlatform = useIsPlatform();
const { data, stopPolling, client } = useGetApplicationStateQuery({
variables: { appId: currentApplication.id },
pollInterval: 2000,
skip: !isPlatform,
});
const { data, startPolling, stopPolling, client } =
useGetApplicationStateQuery({
variables: { appId: currentApplication?.id },
skip: !isPlatform || !currentApplication?.id,
});
async function updateOwnCache() {
await client.refetchQueries({
@@ -35,6 +36,10 @@ export function useCheckProvisioning() {
const memoizedUpdateCache = useCallback(updateOwnCache, [client]);
useEffect(() => {
startPolling(2000);
}, [startPolling]);
useEffect(() => {
if (!data) {
return;
@@ -81,7 +86,13 @@ export function useCheckProvisioning() {
stopPolling();
memoizedUpdateCache();
}
}, [data, stopPolling, memoizedUpdateCache, currentApplication.id]);
}, [
data,
stopPolling,
memoizedUpdateCache,
currentApplication.id,
currentApplicationState.state,
]);
return currentApplicationState;
}

View File

@@ -1,22 +1,30 @@
import { useWorkspaceContext } from '@/context/workspace-context';
import { useGetUserAllWorkspacesQuery } from '@/generated/graphql';
import { useWithin } from '@/hooks/useWithin';
import { useEffect } from 'react';
export const useUserFirstWorkspace = () => {
const { workspaceContext } = useWorkspaceContext();
const { within } = useWithin();
const fetch = !!workspaceContext.slug || !within;
const { loading, error, data, stopPolling, client } =
const { loading, error, data, startPolling, stopPolling, client } =
useGetUserAllWorkspacesQuery({
pollInterval: 1000,
skip: fetch,
fetchPolicy: 'cache-first',
});
if (!!workspaceContext.slug || !within) {
useEffect(() => {
startPolling(1000);
}, [startPolling]);
useEffect(() => {
if (!workspaceContext.slug && within) {
return;
}
stopPolling();
}
}, [workspaceContext.slug, within, stopPolling]);
return {
loading,

2
pnpm-lock.yaml generated
View File

@@ -77,7 +77,7 @@ importers:
dashboard:
specifiers:
'@apollo/client': ^3.6.2
'@apollo/client': ^3.7.3
'@babel/core': ^7.20.2
'@codemirror/language': ^6.3.0
'@emotion/cache': ^11.10.5