Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.
Merged
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
24 changes: 12 additions & 12 deletions extensions/pvaPublish/src/components/pvaDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,17 @@ export const PVADialog: FC = () => {
if (tenantId) {
// get environments for tenant id
const url = `${BASE_URL}/environments`;
const fetchEnvs = async () => {
const fetchEnvs = async (headers) => {
setFetchingEnvironments(true);
const res = await fetch(url, { method: 'GET', headers: pvaHeaders });
const res = await fetch(url, { method: 'GET', headers });
const envs = await res.json();
setFetchingEnvironments(false);
setEnvs(envs);
if (envs?.length) {
setEnv(envs[0].id);
}
};
fetchEnvs();
fetchEnvs(pvaHeaders);
}
}, [tenantId, token, pvaHeaders]);

Expand All @@ -119,10 +119,9 @@ export const PVADialog: FC = () => {
useEffect(() => {
if (env) {
// get bots for environment
const url = `${BASE_URL}/environments/${encodeURIComponent(env)}/bots`;
const fetchBots = async () => {
const fetchBots = async (url, headers) => {
setFetchingBots(true);
const res = await fetch(url, { method: 'GET', headers: pvaHeaders });
const res = await fetch(url, { method: 'GET', headers });
const bots = await res.json();
setFetchingBots(false);
setBots(bots);
Expand All @@ -132,7 +131,8 @@ export const PVADialog: FC = () => {
setBot(undefined);
}
};
fetchBots();
const url = `${BASE_URL}/environments/${encodeURIComponent(env)}/bots`;
fetchBots(url, pvaHeaders);
}
}, [env, pvaHeaders]);

Expand All @@ -145,7 +145,7 @@ export const PVADialog: FC = () => {
}, [env, bot, tenantId]);

const onSave = useCallback(() => {
savePublishConfig({ botId: (bot || {}).id, envId: env, tenantId, deleteMissingComponents: true });
savePublishConfig({ botId: bot?.id, envId: env, tenantId, deleteMissingComponents: true });
closeDialog();
}, [env, bot, tenantId]);

Expand Down Expand Up @@ -186,7 +186,7 @@ export const PVADialog: FC = () => {
);
}
}
}, [loggedIn, fetchingEnvironments, envs]);
}, [loggedIn, fetchingEnvironments, envs, onSelectEnv]);

const botPicker = useMemo(() => {
if (loggedIn && !fetchingEnvironments && env) {
Expand Down Expand Up @@ -221,7 +221,7 @@ export const PVADialog: FC = () => {
);
}
}
}, [loggedIn, fetchingEnvironments, env, fetchingBots, bots]);
}, [loggedIn, fetchingEnvironments, env, fetchingBots, bots, onSelectBot]);

const loginSplash = useMemo(() => {
if (!loggedIn) {
Expand Down Expand Up @@ -281,7 +281,7 @@ export const PVADialog: FC = () => {
</Stack>
);
}
}, [loggedIn, loggingIn]);
}, [loggedIn, loggingIn, login]);

const buttonBar = useMemo(() => {
if (loggedIn) {
Expand All @@ -305,7 +305,7 @@ export const PVADialog: FC = () => {
</div>
);
}
}, [configIsValid, loggedIn]);
}, [configIsValid, loggedIn, onBack, onSave]);

return (
<div style={root}>
Expand Down