ydb-embedded-ui 1.5.1 → 1.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ### [1.5.2](https://github.com/ydb-platform/ydb-embedded-ui/compare/v1.5.1...v1.5.2) (2022-05-26)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **Tenant:** always update diagnostics tabs for root ([db03266](https://github.com/ydb-platform/ydb-embedded-ui/commit/db03266fd7dd6e4588c1db0d109bdfaa8f693e2d))
9
+ * **Tenant:** don't use HistoryAPI and redux-location-state together ([c1bc562](https://github.com/ydb-platform/ydb-embedded-ui/commit/c1bc5621e3ead44b1b84e592f8d7106bbc918e37))
10
+
3
11
  ### [1.5.1](https://github.com/ydb-platform/ydb-embedded-ui/compare/v1.5.0...v1.5.1) (2022-05-25)
4
12
 
5
13
 
@@ -3,7 +3,7 @@ import qs from 'qs';
3
3
  import cn from 'bem-cn-lite';
4
4
  import {Link} from 'react-router-dom';
5
5
  import {useDispatch, useSelector} from 'react-redux';
6
- import {useHistory, useLocation} from 'react-router';
6
+ import {useLocation} from 'react-router';
7
7
 
8
8
  import {Switch, Tabs} from '@yandex-cloud/uikit';
9
9
 
@@ -34,8 +34,10 @@ import {TenantGeneralTabsIds, TenantTabsGroups} from '../TenantPages';
34
34
  import {GeneralPagesIds, DATABASE_PAGES, TABLE_PAGES, DIR_PAGES} from './DiagnosticsPages';
35
35
  //@ts-ignore
36
36
  import {enableAutorefresh, disableAutorefresh} from '../../../store/reducers/schema';
37
+ import {setTopLevelTab, setDiagnosticsTab} from '../../../store/reducers/tenant';
37
38
 
38
39
  import './Diagnostics.scss';
40
+
39
41
  interface DiagnosticsProps {
40
42
  type: string;
41
43
  additionalTenantInfo?: any;
@@ -51,16 +53,17 @@ function Diagnostics(props: DiagnosticsProps) {
51
53
  currentSchema: currentItem = {},
52
54
  autorefresh,
53
55
  } = useSelector((state: any) => state.schema);
56
+ const {
57
+ diagnosticsTab = GeneralPagesIds.overview,
58
+ } = useSelector((state: any) => state.tenant);
54
59
 
55
60
  const location = useLocation();
56
61
 
57
- const history = useHistory();
58
-
59
62
  const queryParams = qs.parse(location.search, {
60
63
  ignoreQueryPrefix: true,
61
64
  });
62
65
 
63
- const {name: tenantName, generalTab = GeneralPagesIds.overview} = queryParams;
66
+ const {name: tenantName} = queryParams;
64
67
 
65
68
  const isDatabase = currentSchemaPath === tenantName;
66
69
 
@@ -76,25 +79,20 @@ function Diagnostics(props: DiagnosticsProps) {
76
79
  pages = TABLE_PAGES;
77
80
  }
78
81
  return pages;
79
- }, [props.type]);
82
+ }, [props.type, isDatabase]);
80
83
 
81
84
  const forwardToDiagnosticTab = (tab: GeneralPagesIds) => {
82
- history.push(
83
- createHref(routes.tenant, undefined, {
84
- ...queryParams,
85
- [TenantTabsGroups.generalTab]: tab,
86
- }),
87
- );
85
+ dispatch(setDiagnosticsTab(tab));
88
86
  };
89
87
  const activeTab = useMemo(() => {
90
- if (pages.find((el) => el.id === generalTab)) {
91
- return generalTab;
88
+ if (pages.find((el) => el.id === diagnosticsTab)) {
89
+ return diagnosticsTab;
92
90
  } else {
93
91
  const newPage = pages[0].id;
94
92
  forwardToDiagnosticTab(newPage);
95
93
  return newPage;
96
94
  }
97
- }, [pages, generalTab]);
95
+ }, [pages, diagnosticsTab]);
98
96
 
99
97
  const onAutorefreshToggle = (value: boolean) => {
100
98
  if (value) {
@@ -105,12 +103,7 @@ function Diagnostics(props: DiagnosticsProps) {
105
103
  };
106
104
 
107
105
  const forwardToGeneralTab = (tab: TenantGeneralTabsIds) => {
108
- history.push(
109
- createHref(routes.tenant, undefined, {
110
- ...queryParams,
111
- [TenantTabsGroups.general]: tab,
112
- }),
113
- );
106
+ dispatch(setTopLevelTab(tab));
114
107
  };
115
108
 
116
109
  const renderTabContent = () => {
@@ -118,7 +111,7 @@ function Diagnostics(props: DiagnosticsProps) {
118
111
 
119
112
  const tenantNameString = tenantName as string;
120
113
 
121
- switch (generalTab) {
114
+ switch (diagnosticsTab) {
122
115
  case GeneralPagesIds.overview: {
123
116
  return (
124
117
  <DetailedOverview
@@ -36,6 +36,7 @@ import {
36
36
  PaneVisibilityToggleButtons,
37
37
  } from '../utils/paneVisibilityToggleHelpers';
38
38
  import {setShowPreview} from '../../../store/reducers/schema';
39
+ import {setTopLevelTab} from '../../../store/reducers/tenant';
39
40
 
40
41
  import './ObjectSummary.scss';
41
42
 
@@ -222,12 +223,7 @@ function ObjectSummary(props: ObjectSummaryProps) {
222
223
 
223
224
  const onOpenPreview = () => {
224
225
  dispatch(setShowPreview(true));
225
- history.push(
226
- createHref(routes.tenant, undefined, {
227
- ...queryParams,
228
- [TenantTabsGroups.general]: TenantGeneralTabsIds.query,
229
- }),
230
- );
226
+ dispatch(setTopLevelTab(TenantGeneralTabsIds.query));
231
227
  };
232
228
 
233
229
  const renderCommonInfoControls = () => {
@@ -1,5 +1,4 @@
1
1
  import {useDispatch} from 'react-redux';
2
- import {useHistory} from 'react-router';
3
2
 
4
3
  import {NavigationTree} from 'ydb-ui-components';
5
4
 
@@ -26,7 +25,6 @@ export function SchemaTree(props: SchemaTreeProps) {
26
25
  } = props;
27
26
 
28
27
  const dispatch = useDispatch();
29
- const history = useHistory();
30
28
 
31
29
  const fetchPath = (path: string) => window.api.getSchema(
32
30
  {path},
@@ -55,7 +53,7 @@ export function SchemaTree(props: SchemaTreeProps) {
55
53
  collapsed: false,
56
54
  }}
57
55
  fetchPath={fetchPath}
58
- getActions={getActions(dispatch, history, handleActivePathUpdate)}
56
+ getActions={getActions(dispatch, handleActivePathUpdate)}
59
57
  activePath={currentPath}
60
58
  onActivePathUpdate={handleActivePathUpdate}
61
59
  cache={false}
@@ -1,13 +1,11 @@
1
- import qs from 'qs';
2
1
  import {Dispatch} from 'react';
3
- import {History} from 'history';
4
2
  import type {NavigationTreeNodeType} from 'ydb-ui-components';
5
3
 
6
- import routes, {createHref} from '../../../routes';
7
4
  import {changeUserInput} from '../../../store/reducers/executeQuery';
8
5
  import {setShowPreview} from '../../../store/reducers/schema';
6
+ import {setTopLevelTab} from '../../../store/reducers/tenant';
9
7
  import createToast from '../../../utils/createToast';
10
- import {TenantGeneralTabsIds, TenantTabsGroups} from '../TenantPages';
8
+ import {TenantGeneralTabsIds} from '../TenantPages';
11
9
 
12
10
  const createTableTemplate = (path: string) => {
13
11
  return `CREATE TABLE \`${path}/my_table\`
@@ -36,29 +34,16 @@ VALUES ( );`;
36
34
 
37
35
  export const getActions = (
38
36
  dispatch: Dispatch<any>,
39
- history: History<unknown>,
40
37
  setActivePath: (path: string) => void,
41
38
  ) =>
42
39
  (path: string, type: NavigationTreeNodeType) => {
43
- const queryParams = qs.parse(location.search, {
44
- ignoreQueryPrefix: true,
45
- });
46
-
47
40
  const switchTabToQuery = () => {
48
- history.push(
49
- createHref(routes.tenant, undefined, {
50
- ...queryParams,
51
- [TenantTabsGroups.general]: TenantGeneralTabsIds.query,
52
- }),
53
- );
41
+ dispatch(setTopLevelTab(TenantGeneralTabsIds.query));
54
42
  };
55
43
 
56
44
  const onCreateTableClick = () => {
57
45
  dispatch(changeUserInput({input: createTableTemplate(path)}));
58
46
  switchTabToQuery();
59
- // here and in the other handlers this should be called after switching tab:
60
- // redux-location-state catches the history.push event from the tab switching
61
- // before active path updates in url, preventing its update at all
62
47
  setActivePath(path);
63
48
  };
64
49
 
@@ -3,6 +3,8 @@ import '../../services/api';
3
3
  import _ from 'lodash';
4
4
 
5
5
  const FETCH_TENANT = createRequestActionTypes('tenant', 'FETCH_TENANT');
6
+ const SET_TOP_LEVEL_TAB = 'tenant/SET_TOP_LEVEL_TAB';
7
+ const SET_DIAGNOSTICS_TAB = 'tenant/SET_DIAGNOSTICS_TAB';
6
8
 
7
9
  const tenantReducer = (state = {loading: false, tenant: {}}, action) => {
8
10
  switch (action.type) {
@@ -41,6 +43,20 @@ const tenantReducer = (state = {loading: false, tenant: {}}, action) => {
41
43
  };
42
44
  }
43
45
 
46
+ case SET_TOP_LEVEL_TAB: {
47
+ return {
48
+ ...state,
49
+ topLevelTab: action.data,
50
+ };
51
+ }
52
+
53
+ case SET_DIAGNOSTICS_TAB: {
54
+ return {
55
+ ...state,
56
+ diagnosticsTab: action.data,
57
+ };
58
+ }
59
+
44
60
  default:
45
61
  return state;
46
62
  }
@@ -73,4 +89,18 @@ export const getTenantInfo = ({path}) => {
73
89
  });
74
90
  };
75
91
 
92
+ export function setTopLevelTab(tab) {
93
+ return {
94
+ type: SET_TOP_LEVEL_TAB,
95
+ data: tab,
96
+ };
97
+ }
98
+
99
+ export function setDiagnosticsTab(tab) {
100
+ return {
101
+ type: SET_DIAGNOSTICS_TAB,
102
+ data: tab,
103
+ };
104
+ }
105
+
76
106
  export default tenantReducer;
@@ -42,6 +42,12 @@ const paramSetup = {
42
42
  stateKey: 'tablets.typeFilter',
43
43
  type: 'array',
44
44
  },
45
+ general: {
46
+ stateKey: 'tenant.topLevelTab',
47
+ },
48
+ generalTab: {
49
+ stateKey: 'tenant.diagnosticsTab',
50
+ },
45
51
  },
46
52
  };
47
53
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ydb-embedded-ui",
3
- "version": "1.5.1",
3
+ "version": "1.5.2",
4
4
  "files": [
5
5
  "dist"
6
6
  ],