datajunction-ui 0.0.1-a40.dev → 0.0.1-a42

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datajunction-ui",
3
- "version": "0.0.1-a40.dev",
3
+ "version": "0.0.1a42",
4
4
  "description": "DataJunction Metrics Platform UI",
5
5
  "module": "src/index.tsx",
6
6
  "repository": {
@@ -5,6 +5,7 @@ import { DJNodeColumns } from './DJNodeColumns';
5
5
  export default function Collapse({ collapsed, text, data }) {
6
6
  const [isCollapsed, setIsCollapsed] = React.useState(collapsed);
7
7
 
8
+ const limit = 5;
8
9
  return (
9
10
  <>
10
11
  <div className="collapse">
@@ -26,11 +27,11 @@ export default function Collapse({ collapsed, text, data }) {
26
27
  >
27
28
  {data.type !== 'metric'
28
29
  ? isCollapsed
29
- ? DJNodeColumns({ data: data, limit: 10 })
30
+ ? DJNodeColumns({ data: data, limit: limit })
30
31
  : DJNodeColumns({ data: data, limit: 100 })
31
32
  : DJNodeDimensions(data)}
32
33
  </div>
33
- {data.type !== 'metric' && data.column_names.length > 10 ? (
34
+ {data.type !== 'metric' && data.column_names.length > limit ? (
34
35
  <button
35
36
  className="collapse-button"
36
37
  onClick={() => setIsCollapsed(!isCollapsed)}
@@ -33,7 +33,11 @@ export function DJNodeColumns({ data, limit }) {
33
33
  };
34
34
  return data.column_names.slice(0, limit).map(col => (
35
35
  <div
36
- className={'custom-node-subheader node_type__' + data.type}
36
+ className={
37
+ 'custom-node-subheader node_type__' +
38
+ data.type +
39
+ (col.order <= 0 ? ' custom-node-emphasis' : '')
40
+ }
37
41
  key={`${data.name}.${col.name}`}
38
42
  >
39
43
  <div style={handleWrapperStyle}>
@@ -32,8 +32,10 @@ const getLayoutedElements = (
32
32
  const nodeHeightTracker = {};
33
33
 
34
34
  nodes.forEach(node => {
35
- nodeHeightTracker[node.id] =
36
- Math.min(node.data.column_names.length, 10) * 40 + 250;
35
+ const minColumnsLength = node.data.column_names.filter(
36
+ col => col.order > 0,
37
+ ).length;
38
+ nodeHeightTracker[node.id] = Math.min(minColumnsLength, 5) * 40 + 250;
37
39
  dagreGraph.setNode(node.id, {
38
40
  width: nodeWidth,
39
41
  height: nodeHeightTracker[node.id],
@@ -52,7 +54,7 @@ const getLayoutedElements = (
52
54
  node.sourcePosition = isHorizontal ? 'right' : 'bottom';
53
55
  node.position = {
54
56
  x: nodeWithPosition.x - nodeWidth / 2,
55
- y: nodeWithPosition.y - nodeHeightTracker[node.id] / 2,
57
+ y: nodeWithPosition.y - nodeHeightTracker[node.id] / 3,
56
58
  };
57
59
  node.width = nodeWidth;
58
60
  node.height = nodeHeightTracker[node.id];
@@ -93,7 +93,7 @@ describe('AddEditNodePage submission failed', () => {
93
93
  expect(mockDjClient.DataJunctionAPI.tagsNode).toBeCalled();
94
94
  expect(mockDjClient.DataJunctionAPI.tagsNode).toBeCalledWith(
95
95
  'default.num_repair_orders',
96
- [{ display_name: 'Purpose', name: 'purpose' }],
96
+ ['purpose'],
97
97
  );
98
98
  expect(mockDjClient.DataJunctionAPI.tagsNode).toReturnWith({
99
99
  json: { message: 'Some tags were not found' },
@@ -120,7 +120,7 @@ describe('AddEditNodePage submission succeeded', () => {
120
120
  expect(mockDjClient.DataJunctionAPI.tagsNode).toBeCalledTimes(1);
121
121
  expect(mockDjClient.DataJunctionAPI.tagsNode).toBeCalledWith(
122
122
  'default.num_repair_orders',
123
- [{ display_name: 'Purpose', name: 'purpose' }],
123
+ ['purpose'],
124
124
  );
125
125
 
126
126
  expect(mockDjClient.DataJunctionAPI.listMetricMetadata).toBeCalledTimes(
@@ -214,6 +214,11 @@ export function AddEditNodePage() {
214
214
  fields.forEach(field => {
215
215
  if (field === 'primary_key') {
216
216
  setFieldValue(field, primaryKey.join(', '));
217
+ } else if (field === 'tags') {
218
+ setFieldValue(
219
+ field,
220
+ data[field].map(tag => tag.name),
221
+ );
217
222
  } else {
218
223
  setFieldValue(field, data[field] || '', false);
219
224
  }
@@ -15,9 +15,20 @@ const NodeLineage = djNode => {
15
15
  col.attributes.some(attr => attr.attribute_type.name === 'primary_key'),
16
16
  )
17
17
  .map(col => col.name);
18
- const column_names = node.columns.map(col => {
19
- return { name: col.name, type: col.type };
20
- });
18
+ const column_names = node.columns
19
+ .map(col => {
20
+ return {
21
+ name: col.name,
22
+ type: col.type,
23
+ dimension: col.dimension !== null ? col.dimension.name : null,
24
+ order: primary_key.includes(col.name)
25
+ ? -1
26
+ : col.dimension !== null
27
+ ? 0
28
+ : 1,
29
+ };
30
+ })
31
+ .sort((a, b) => a.order - b.order);
21
32
  return {
22
33
  id: String(node.name),
23
34
  type: 'DJNode',
@@ -15,7 +15,7 @@ import NodesWithDimension from './NodesWithDimension';
15
15
  import NodeColumnLineage from './NodeLineageTab';
16
16
  import EditIcon from '../../icons/EditIcon';
17
17
  import AlertIcon from '../../icons/AlertIcon';
18
- import NodeDimensionsTab from "./NodeDimensionsTab";
18
+ import NodeDimensionsTab from './NodeDimensionsTab';
19
19
 
20
20
  export function NodePage() {
21
21
  const djClient = useContext(DJClientContext).DataJunctionAPI;
@@ -208,10 +208,12 @@
208
208
  }
209
209
  .custom-node-port {
210
210
  color: #636776;
211
- font-size: 20px;
211
+ font-size: 23px;
212
212
  text-align: center;
213
213
  }
214
-
214
+ .custom-node-emphasis {
215
+ border: 2px dashed #636776;
216
+ }
215
217
  .white_badge {
216
218
  background-color: #ffffff !important;
217
219
  display: inline-block;
@@ -1093,7 +1093,6 @@ pre {
1093
1093
  text-decoration: none;
1094
1094
  }
1095
1095
 
1096
-
1097
1096
  .dimensionsList {
1098
1097
  padding: 12px;
1099
1098
  opacity: 1;
package/dj.internal.db DELETED
File without changes