Skip to content

Commit

Permalink
Merge pull request #387 from metrico/fix/tab_at_window_resize
Browse files Browse the repository at this point in the history
Fix: tab at window resize
  • Loading branch information
jacovinus authored Dec 22, 2023
2 parents 1b7a99d + fd4078d commit bdce195
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/main/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@ui/main",
"private": true,
"version": "0.27.8",
"version": "0.28.2",
"type": "module",
"scripts": {
"dev": "VITE_APP_VERSION=$npm_package_version vite",
Expand Down
4 changes: 2 additions & 2 deletions packages/main/plugins/Cardinality/Totals.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ const TOTALS_VALUES = {
value: (val: string | number | null | undefined) => `${val ?? 0 }`,
},
quota: {
text: "Quota",
value : (val: string | number ) => `${val}`
text: "Quota Limit",
value : (val: string | number ) => val === 0 ? 'Unlimited' : `${val}`
}
};
export const Totals: React.FC<TotalsProps> = ({
Expand Down
5 changes: 4 additions & 1 deletion packages/main/sections/Queries/QueryItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import {
filterLocal,
getStoredQueries,
setStoredQuery,
setLocalTabsState,
getLocalTabsState
} from "./helpers";
import { useIdRefs } from "./hooks";

Expand Down Expand Up @@ -52,7 +54,7 @@ const QueryItem = (props: any) => {
const isQueryOpen = useState(true);
const idRefs = useIdRefs(name);
const theme = useTheme();
const [tabsValue, setTabsValue] = useState(0);
const [tabsValue, setTabsValue] = useState(getLocalTabsState(name, id));

const onAddQuery = () => {
const panelData = setNewPanelData(panelSelected, data, idRefs);
Expand Down Expand Up @@ -96,6 +98,7 @@ const QueryItem = (props: any) => {
};

const onTabChange = (e: React.SyntheticEvent, tabValue: number) => {
setLocalTabsState(name, id, tabValue);
setTabsValue(() => tabValue);
};
const { activeTabs, isActiveTabs } = useActiveTabs(`Query Item`);
Expand Down
32 changes: 32 additions & 0 deletions packages/main/sections/Queries/helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,35 @@ export const dataViewAction = (panel: any, data: any) => {
return setRightDataView(data);
}
};

export const setLocalTabsState = (
panel: string,
queryId: string,
value: number
) => {
try {
const localTabs = JSON.parse(
localStorage.getItem("localTabsState") || "{}"
);
const panelState = localTabs[panel] || {};

panelState[queryId] = value;
localTabs[panel] = panelState;

localStorage.setItem("localTabsState", JSON.stringify(localTabs));
} catch (e) {
console.log(e);
}
};

export const getLocalTabsState = (panel: string, queryId: string) => {
try {
const tabsState = JSON.parse(
localStorage.getItem("localTabsState") || "{}"
);
return tabsState[panel]?.[queryId] || 0;
} catch (e) {
console.log(e);
return 0;
}
};

0 comments on commit bdce195

Please sign in to comment.