Skip to content

Commit

Permalink
fix(wren-ui): allow back to previous steps for onboarding and improve (
Browse files Browse the repository at this point in the history
  • Loading branch information
fredalai authored Apr 23, 2024
1 parent d1ed527 commit 337f837
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
4 changes: 2 additions & 2 deletions wren-ui/src/components/pages/setup/ConnectDataSource.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ export default function ConnectDataSource(props: Props) {
</DataSource>
</Col>
<Col className="text-right" span={12}>
Learn more information in {current.label}{' '}
Learn more information in the {current.label}{' '}
<Link
href={current.guide}
target="_blank"
rel="noopener noreferrer"
>
the setup guide
setup guide
</Link>
.
</Col>
Expand Down
2 changes: 1 addition & 1 deletion wren-ui/src/components/pages/setup/SelectModels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default function SelectModels(props: Props) {
understand your data.
<br />
<Link
href="https://docs.getwren.ai/guides/modeling/models"
href="https://docs.getwren.ai/guide/modeling/overview"
target="_blank"
rel="noopener noreferrer"
>
Expand Down
23 changes: 20 additions & 3 deletions wren-ui/src/hooks/useCheckOnboarding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,20 @@ const redirectRoute = {

export const useWithOnboarding = () => {
const router = useRouter();
const { data, loading } = useOnboardingStatusQuery({
fetchPolicy: 'network-only',
});
const { data, loading, refetch } = useOnboardingStatusQuery();

const onboardingStatus = data?.onboardingStatus?.status;

useEffect(() => {
// do not refetch onboarding status when onboarding page
if (router.pathname.startsWith(Path.Onboarding)) {
return;
}

// refetch onboarding status when the route changes
refetch();
}, [router.pathname]);

useEffect(() => {
if (onboardingStatus) {
const newPath = redirectRoute[onboardingStatus];
Expand All @@ -30,6 +39,14 @@ export const useWithOnboarding = () => {
return;
}

// allow return back to previous steps
if (
router.pathname.startsWith(Path.Onboarding) &&
onboardingStatus !== OnboardingStatus.ONBOARDING_FINISHED
) {
return;
}

router.push(newPath);
return;
}
Expand Down
4 changes: 3 additions & 1 deletion wren-ui/src/hooks/useCombineFieldOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ export default function useCombineFieldOptions(props: Props) {

const [baseModel, setBaseModel] = useState<string>(model || '');

const { data } = useListModelsQuery();
const { data } = useListModelsQuery({
fetchPolicy: 'cache-and-network',
});

const allModels = useMemo(() => {
if (!data) return [];
Expand Down

0 comments on commit 337f837

Please sign in to comment.