ydb-embedded-ui 1.1.0 → 1.1.1

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.1.1](https://www.github.com/ydb-platform/ydb-embedded-ui/compare/v1.1.0...v1.1.1) (2022-04-19)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * add typecheck + fix type errors ([e6d9086](https://www.github.com/ydb-platform/ydb-embedded-ui/commit/e6d9086c46702a611f848c992377d18826ca2e23))
9
+ * **Node:** scroll to selected vdisk should not apply to undefined container ([7236a43](https://www.github.com/ydb-platform/ydb-embedded-ui/commit/7236a43655b935777abb5b8df228ae011ceb6bed))
10
+
3
11
  ## [1.1.0](https://www.github.com/ydb-platform/ydb-embedded-ui/compare/v1.0.4...v1.1.0) (2022-04-15)
4
12
 
5
13
 
@@ -20,7 +20,7 @@ import {
20
20
  FooterItemIconView,
21
21
  } from './constants';
22
22
  import i18n from './i18n';
23
- import {Lang} from 'utils/i18n';
23
+
24
24
  import {getLocalData, setLocalData} from './helpers';
25
25
  import {SetSlotsContext, SlotsProvider} from './AsideHeaderFooterSlot/SlotsContext';
26
26
  import {SlotName} from './AsideHeaderFooterSlot/AsideHeaderFooterSlot';
@@ -28,6 +28,7 @@ import {SlotName} from './AsideHeaderFooterSlot/AsideHeaderFooterSlot';
28
28
  import controlMenuButton from '../../assets/icons/control-menu-button.svg';
29
29
 
30
30
  import './AsideHeader.scss';
31
+ import {Lang} from '../../utils/i18n';
31
32
 
32
33
  const b = block('nv-aside-header');
33
34
 
@@ -43,7 +43,7 @@ function Authentication({authenticate, error}: any) {
43
43
  authenticate(login, pass);
44
44
  };
45
45
 
46
- const onEnterClick = (e: KeyboardEvent<HTMLInputElement>) => {
46
+ const onEnterClick = (e: KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) => {
47
47
  if (e.keyCode === 13) {
48
48
  onLoginClick();
49
49
  }
@@ -39,7 +39,6 @@ interface NodeProps {
39
39
 
40
40
  function Node(props: NodeProps) {
41
41
  const dispatch = useDispatch();
42
- const repaint = React.useState({})[1];
43
42
 
44
43
  const wasLoaded = useSelector((state: any) => state.node.wasLoaded);
45
44
  const loading = useSelector((state: any) => state.node.loading);
@@ -72,8 +71,6 @@ function Node(props: NodeProps) {
72
71
  return {activeTabVerified, nodeTabs};
73
72
  }, [activeTab, node]);
74
73
 
75
- const nodeContainerRef = React.useRef<HTMLDivElement | null>(null);
76
-
77
74
  React.useEffect(() => {
78
75
  const fetchData = () => dispatch(getNodeInfo(nodeId));
79
76
  fetchData();
@@ -148,7 +145,6 @@ function Node(props: NodeProps) {
148
145
  className={b('node-page-wrapper')}
149
146
  nodeId={nodeId}
150
147
  additionalNodesInfo={additionalNodesInfo}
151
- scrollContainer={nodeContainerRef.current}
152
148
  />
153
149
  );
154
150
  }
@@ -157,13 +153,6 @@ function Node(props: NodeProps) {
157
153
  }
158
154
  };
159
155
 
160
- const onRefChange = (ref: HTMLDivElement) => {
161
- if (!nodeContainerRef.current) {
162
- nodeContainerRef.current = ref;
163
- repaint({});
164
- }
165
- };
166
-
167
156
  if (loading && !wasLoaded) {
168
157
  return <Loader />;
169
158
  } else if (error) {
@@ -171,12 +160,10 @@ function Node(props: NodeProps) {
171
160
  } else {
172
161
  if (node) {
173
162
  return (
174
- <div className={`${b()} ${props.className}`}>
163
+ <div className={b(null, props.className)}>
175
164
  {renderTabs()}
176
165
 
177
- <div className={b('content')} ref={onRefChange}>
178
- {renderTabContent()}
179
- </div>
166
+ <div className={b('content')}>{renderTabContent()}</div>
180
167
  </div>
181
168
  );
182
169
  }
@@ -1,10 +1,13 @@
1
1
  @import '../../../styles/mixins.scss';
2
2
 
3
3
  .kv-node-structure {
4
+ position: relative;
5
+
4
6
  display: flex;
5
7
  overflow: auto;
6
8
  flex-direction: column;
7
9
  flex-shrink: 0;
10
+ @include flex-container();
8
11
  @include body2-typography();
9
12
 
10
13
  &__loader {
@@ -28,7 +28,6 @@ interface NodeStructureProps {
28
28
  nodeId: string;
29
29
  className?: string;
30
30
  additionalNodesInfo?: any;
31
- scrollContainer: Element | null;
32
31
  }
33
32
 
34
33
  const autofetcher = new AutoFetcher();
@@ -40,9 +39,7 @@ function NodeStructure(props: NodeStructureProps) {
40
39
 
41
40
  const loadingStructure = useSelector((state: any) => state.node.loadingStructure);
42
41
  const wasLoadedStructure = useSelector((state: any) => state.node.wasLoadedStructure);
43
- const nodeData = useSelector(
44
- (state: any) => state.node?.data?.SystemStateInfo?.[0]
45
- );
42
+ const nodeData = useSelector((state: any) => state.node?.data?.SystemStateInfo?.[0]);
46
43
 
47
44
  const nodeHref = useMemo(() => {
48
45
  return props.additionalNodesInfo?.getNodeRef
@@ -55,13 +52,15 @@ function NodeStructure(props: NodeStructureProps) {
55
52
  true,
56
53
  ).query;
57
54
 
55
+ const scrollContainerRef = useRef<HTMLDivElement>(null);
56
+ const scrollContainer = scrollContainerRef.current;
57
+
58
58
  const isReady = useRef(false);
59
59
 
60
60
  const scrolled = useRef(false);
61
61
 
62
62
  useEffect(() => {
63
63
  return () => {
64
- const {scrollContainer} = props;
65
64
  if (scrollContainer) {
66
65
  scrollContainer.scrollTo({
67
66
  behavior: 'smooth',
@@ -84,13 +83,12 @@ function NodeStructure(props: NodeStructureProps) {
84
83
  }, [props.nodeId, dispatch]);
85
84
 
86
85
  useEffect(() => {
87
- if (!_.isEmpty(nodeStructure) && props.scrollContainer) {
86
+ if (!_.isEmpty(nodeStructure) && scrollContainer) {
88
87
  isReady.current = true;
89
88
  }
90
- }, [nodeStructure, props.scrollContainer]);
89
+ }, [nodeStructure]);
91
90
 
92
91
  useEffect(() => {
93
- const {scrollContainer} = props;
94
92
  if (isReady.current && !scrolled.current && scrollContainer) {
95
93
  const element = document.getElementById(
96
94
  generateId({type: 'pdisk', id: pdiskIdFromUrl as string}),
@@ -105,7 +103,7 @@ function NodeStructure(props: NodeStructureProps) {
105
103
  const order = vDisk?.order;
106
104
 
107
105
  if (dataTable) {
108
- scrollToVdisk += (dataTable as HTMLElement).offsetTop + 40 * (order + 1);
106
+ scrollToVdisk += (dataTable as HTMLElement).offsetTop + 40 * order;
109
107
  }
110
108
  }
111
109
 
@@ -113,12 +111,12 @@ function NodeStructure(props: NodeStructureProps) {
113
111
  scrollContainer.scrollTo({
114
112
  behavior: 'smooth',
115
113
  // should subtract 20 to avoid sticking the element to tabs
116
- top: scrollToVdisk ? scrollToVdisk : element.offsetTop - 20,
114
+ top: scrollToVdisk ? scrollToVdisk : element.offsetTop,
117
115
  });
118
116
  scrolled.current = true;
119
117
  }
120
118
  }
121
- }, [nodeStructure, props.scrollContainer, pdiskIdFromUrl, vdiskIdFromUrl]);
119
+ }, [nodeStructure, pdiskIdFromUrl, vdiskIdFromUrl]);
122
120
 
123
121
  const renderStub = () => {
124
122
  return 'There is no information about node structure.';
@@ -147,7 +145,11 @@ function NodeStructure(props: NodeStructureProps) {
147
145
  return renderStructure();
148
146
  };
149
147
 
150
- return <div className={b(null, props.className)}>{renderContent()}</div>;
148
+ return (
149
+ <div className={b()} ref={scrollContainerRef}>
150
+ <div className={props.className}>{renderContent()}</div>
151
+ </div>
152
+ );
151
153
  }
152
154
 
153
155
  export default NodeStructure;
@@ -1,12 +1,12 @@
1
1
  import React from 'react';
2
2
  import cn from 'bem-cn-lite';
3
3
 
4
- import ProgressViewer from 'components/ProgressViewer/ProgressViewer';
5
- import {formatStorageValuesToGb, stringifyVdiskId} from 'utils';
6
- import {bytesToGB, bytesToSpeed} from 'utils/utils';
4
+ import ProgressViewer from '../../../components/ProgressViewer/ProgressViewer';
5
+ import {formatStorageValuesToGb, stringifyVdiskId} from '../../../utils';
6
+ import {bytesToGB, bytesToSpeed} from '../../../utils/utils';
7
7
  import EntityStatus from '../../../components/EntityStatus/EntityStatus';
8
8
  import {valueIsDefined} from './NodeStructure';
9
- import InfoViewer from 'components/InfoViewer/InfoViewer';
9
+ import InfoViewer from '../../../components/InfoViewer/InfoViewer';
10
10
 
11
11
  const b = cn('kv-node-structure');
12
12
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ydb-embedded-ui",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "files": [
5
5
  "dist"
6
6
  ],
@@ -52,6 +52,9 @@
52
52
  "test": "react-app-rewired test",
53
53
  "eject": "react-scripts eject",
54
54
  "prepublishOnly": "npm run package",
55
+ "typecheck": "npm run typecheck:server && npm run typecheck:ui",
56
+ "typecheck:server": "tsc -p src/server --noEmit",
57
+ "typecheck:ui": "tsc -p src/ui --noEmit",
55
58
  "prepare": "husky install"
56
59
  },
57
60
  "lint-staged": {
@@ -78,6 +81,7 @@
78
81
  "@commitlint/cli": "^15.0.0",
79
82
  "@commitlint/config-conventional": "^15.0.0",
80
83
  "@types/lodash": "^4.14.178",
84
+ "@types/react": "^17.0.44",
81
85
  "@types/react-dom": "^17.0.11",
82
86
  "@types/react-router": "^5.1.17",
83
87
  "@types/react-router-dom": "^5.3.2",
@@ -99,6 +103,6 @@
99
103
  "react-app-rewired": "^2.1.11",
100
104
  "react-dom": "^17.0.2",
101
105
  "stylelint": "^14.3.0",
102
- "typescript": "^4.5.4"
106
+ "typescript": "^4.5.5"
103
107
  }
104
108
  }