Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix page jump when session is invalid #562

Merged
merged 1 commit into from
May 23, 2023
Merged
Show file tree
Hide file tree
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
22 changes: 11 additions & 11 deletions app/pages/Schema/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Button, Popconfirm, Table, message, Popover, Form, Input, Dropdown, Menu, Tooltip } from 'antd';
import React, { useEffect, useMemo, useState } from 'react';
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { useI18n } from '@vesoft-inc/i18n';
import Icon from '@app/components/Icon';
import { trackPageView } from '@app/utils/stat';
Expand Down Expand Up @@ -102,23 +102,23 @@ const Schema = () => {
}
};

const handleSwitchSpace = async (space: string) => {
await switchSpace(space);
history.push(`/schema/tag/list`);
};
const getSpaces = async () => {
const viewSpaceDetail = useCallback(async (space: string) => {
const ok = await switchSpace(space);
ok && history.push(`/schema/tag/list`);
}, []);
const getSpaces = useCallback(async () => {
setLoading(true);
await getSpacesList();
setLoading(false);
};
}, []);

const handleCloneSpace = async (name: string, oldSpace: string) => {
const handleCloneSpace = useCallback(async (name: string, oldSpace: string) => {
const { code } = await cloneSpace(name, oldSpace);
if(code === 0) {
message.success(intl.get('schema.createSuccess'));
getSpaces();
}
};
}, []);
const columns = [
{
title: intl.get('schema.No'),
Expand All @@ -137,7 +137,7 @@ const Schema = () => {
<a
className={styles.cellBtn}
type="link"
onClick={() => handleSwitchSpace(data)}
onClick={() => viewSpaceDetail(data)}
data-track-category="navigation"
data-track-action="view_space_list"
data-track-label="from_space_list"
Expand Down Expand Up @@ -193,7 +193,7 @@ const Schema = () => {
<div className={styles.operation}>
<Button
className="primaryBtn"
onClick={() => handleSwitchSpace(space.Name)}
onClick={() => viewSpaceDetail(space.Name)}
data-track-category="navigation"
data-track-action="view_space_list"
data-track-label="from_space_list"
Expand Down
8 changes: 5 additions & 3 deletions app/stores/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,14 @@ export class SchemaStore {
updateVidType = async (space?: string) => {
const spaceVidType = await this.getSpaceVidType(space || this.currentSpace);
this.update({ spaceVidType });
return !!spaceVidType;
};

switchSpace = async (space: string) => {
this.update({ currentSpace: space, ...initialSchemaData });
localStorage.setItem('currentSpace', space);
await this.updateVidType(space);
const ok = await this.updateVidType(space);
return ok;
};

getSchemaInfo = async () => {
Expand All @@ -127,8 +129,8 @@ export class SchemaStore {
};

getSpaceVidType = async (space: string) => {
const { data } = await this.getSpaceInfo(space);
return data?.tables?.[0]?.['Vid Type'];
const { code, data } = await this.getSpaceInfo(space);
return code === 0 ? data?.tables?.[0]?.['Vid Type'] : null;
};

getSpaceCreateGQL = async (space: string) => {
Expand Down