@kumologica/sdk 3.0.27-beta8 → 3.1.0-alpha2

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.
@@ -337,11 +337,26 @@ RED.tabs = (function () {
337
337
  }
338
338
  }
339
339
 
340
+ function getTabsMaxWidthAvailable() {
341
+ const workspaceWidth = $('#main-container').width();
342
+
343
+ const paletteWidth = $('#palette').is(':hidden')? 0 : $('#palette').width();
344
+ const sidebarWidth = $('#sidebar').is(':hidden')? 0 : $('#sidebar').width();
345
+ const sidebarShortcuts = $('#sidebar-shortcuts').width();
346
+ const occupied = paletteWidth + sidebarWidth + sidebarShortcuts;
347
+
348
+ return workspaceWidth - occupied;
349
+ }
350
+
340
351
  function updateTabWidths() {
341
352
  if (options.vertical) {
342
353
  return;
343
354
  }
344
355
  var tabs = ul.find('li.red-ui-tab');
356
+
357
+ // Update the width of the tabs container
358
+ $('#workspace').find('.red-ui-tabs').width(getTabsMaxWidthAvailable());
359
+
345
360
  var width = wrapper.width();
346
361
  var tabCount = tabs.size();
347
362
  var tabWidth;
@@ -371,7 +386,7 @@ RED.tabs = (function () {
371
386
  currentTabWidth = (100 * tabWidth) / width + '%';
372
387
  currentActiveTabWidth = currentTabWidth + '%';
373
388
  if (options.scrollable) {
374
- tabWidth = Math.max(tabWidth, 60);
389
+ tabWidth = Math.max(tabWidth, 150); // minimum width for the tab
375
390
  currentTabWidth = tabWidth + 'px';
376
391
  currentActiveTabWidth = 0;
377
392
  var listWidth = Math.max(
@@ -1391,7 +1391,6 @@ RED.editor = (function () {
1391
1391
  }
1392
1392
 
1393
1393
  function resetEditor(){
1394
- // console.log('[editor] reset the editor')
1395
1394
  editStack.pop();
1396
1395
  RED.sidebar.nodeinfo.emptyTab();
1397
1396
  RED.actions.invoke('core:hide-sidebar');
@@ -1689,8 +1688,11 @@ RED.editor = (function () {
1689
1688
  }
1690
1689
 
1691
1690
  function showEditDialog(node) {
1691
+ if (RED.sidebar.isDragging()){
1692
+ return;
1693
+ }
1694
+
1692
1695
  let editing_node;
1693
- // console.log('[editor] showEditDialog. Node=', node);
1694
1696
  if (Object.keys(node).length === 0 && node.constructor === Object){
1695
1697
  resetEditor();
1696
1698
  return;
@@ -2869,8 +2871,6 @@ RED.editor = (function () {
2869
2871
  }
2870
2872
  if (options.mode === 'ace/mode/markdown') {
2871
2873
  $(el).addClass('node-text-editor-container-toolbar');
2872
- console.log('[editor] options', options);
2873
-
2874
2874
  if (options.toolbar === false ){
2875
2875
  // do not show the toolbar
2876
2876
  } else {
@@ -3,7 +3,6 @@ RED.sidebar = (function () {
3
3
  var sidebar_tabs = RED.tabs.create({
4
4
  id: 'sidebar-tabs',
5
5
  onchange: function (tab) {
6
- // console.log('[sidebar] - onChange | tab=', tab);
7
6
  $('#editor-stack').hide();
8
7
  $('#sidebar-content').children().hide();
9
8
  $('#sidebar-footer').children().hide();
@@ -111,89 +110,38 @@ RED.sidebar = (function () {
111
110
  RED.menu.removeItem('menu-item-view-menu-' + id);
112
111
  }
113
112
 
114
- var sidebarSeparator = {};
115
- sidebarSeparator.dragging = false;
113
+ // Dragable sidebar logic
114
+ let sidebarDragging = false;
115
+ let sidebarWidthP0 = null;
116
+ let delta = 0;
116
117
 
117
118
  $('#sidebar-separator').draggable({
118
119
  axis: 'x',
119
120
  start: function (event, ui) {
120
- if (!startingPointSeparator){
121
- startingPointSeparator = ui.position.left;
122
- }
123
- sidebarSeparator.closing = false;
124
- sidebarSeparator.opening = false;
125
- var winWidth = $(window).width();
126
- sidebarSeparator.start = ui.position.left;
127
- sidebarSeparator.workspaceWidth = $('#workspace').width();
128
- sidebarSeparator.workspaceRight = parseInt($('#workspace').css('right'));
129
- sidebarSeparator.dragging = true;
130
-
131
- if (!RED.menu.isSelected('menu-item-sidebar')) {
132
- sidebarSeparator.opening = true;
133
- var newChartRight = 7;
134
- $('#sidebar').addClass('closing');
135
- $('#workspace').css('right', newChartRight);
136
- $('#editor-stack').css('right', newChartRight + 1);
137
- $('#sidebar').width(0);
138
-
139
- RED.menu.setSelected('menu-item-sidebar', true);
140
- RED.events.emit('sidebar:resize');
141
- }
142
- sidebarSeparator.width = $('#sidebar').width();
143
- // console.log('Sidebar start point=', sidebarSeparator.start);
121
+ sidebarDragging = true;
122
+ sidebarWidthP0 = $('#sidebar').width();
123
+ delta = 0;
144
124
  },
145
125
  drag: function (event, ui) {
146
- let d = ui.position.left - sidebarSeparator.start;
147
- // sidebar should be original + the distance
148
- // sidebarSeparator.width = sidebarSeparator.width - d ;
149
- // newSidebarWidth = sidebarSeparator.width + 50;
150
- // console.log(ui.position.left);
151
- // console.log(`distance: ${d} -> new right for worspace: ${sidebarSeparator.workspaceRight - d}`);
152
-
153
- // if (sidebarSeparator.opening) {
154
- // newSidebarWidth -= 3;
155
- // }
156
-
157
- const MIN_SIDEBAR_WIDTH = 435;
158
- let desiredSidebarWidth = sidebarSeparator.width - d;
159
- let desiredWorkspaceRight = sidebarSeparator.workspaceRight - d;
160
-
161
- if (desiredSidebarWidth > 435){
162
- // console.log(`Recalibrating sidebar width!!`)
163
- $('#sidebar').width(desiredSidebarWidth);
164
- $('#workspace').css('right', desiredWorkspaceRight);
165
- } else{
166
- // console.log('STOP THIS NOW!!!! IT IS TOO NARROW!!!');
167
- $('#sidebar').width(433);
168
- let sidebarWidth= $('#sidebar').width();
169
- $('#workspace').css('right', 491);
170
- // console.log('Window width=',$(window).width());
171
- // let sidebarFinalPoint = $(window).width() - MIN_SIDEBAR_WIDTH - 50;
172
- // console.log(`Sidebar final point: ${startingPointSeparator}`);
173
- ui.position.left = startingPointSeparator; //$(window).width() - MIN_SIDEBAR_WIDTH - 50; // 11:width separator, 50: size icons
174
- // console.log(`sidebar width after dragging end is: ${ sidebarWidth }`)
175
- $('#sidebar').removeAttr('width');
126
+ let d = ui.position.left;
127
+ delta = sidebarWidthP0 - d;
128
+ $('#sidebar').width(delta);
129
+ if ($('#sidebar').width() > maxWidthSidebar()){
130
+ $('#sidebar').width(maxWidthSidebar());
176
131
  }
132
+ event.stopImmediatePropagation();
177
133
  RED.events.emit('sidebar:resize');
178
134
  },
179
135
  stop: function (event, ui) {
180
- sidebarSeparator.dragging = false;
181
- if (sidebarSeparator.closing) {
182
- // console.log('sidebar-> stop: closing...')
183
- $('#sidebar').removeClass('closing');
184
- RED.menu.setSelected('menu-item-sidebar', false);
185
- if ($('#sidebar').width() < 435) {
186
- $('#sidebar').width(435);
187
- $('#workspace').css('right', 491);
188
- // $('#editor-stack').css('right', 188);
189
- }
190
- }
191
- //$('#sidebar-separator').css('left', 'auto');
192
- //$('#sidebar-separator').css('right', $('#sidebar').width() + 2 + 'px');
136
+ setTimeout(function() {
137
+ sidebarDragging = false;
138
+ },1000);
193
139
  RED.events.emit('sidebar:resize');
194
140
  },
195
141
  });
196
142
 
143
+
144
+
197
145
  var sidebarControls = $(
198
146
  '<div class="sidebar-control-right"><i class="fa fa-chevron-right"</div>'
199
147
  ).appendTo($('#sidebar-separator'));
@@ -201,37 +149,19 @@ RED.sidebar = (function () {
201
149
  sidebarControls.hide();
202
150
  RED.menu.toggleSelected('menu-item-sidebar');
203
151
  });
204
- $('#sidebar-separator').on('mouseenter', function () {
205
- if (!sidebarSeparator.dragging) {
206
- if (RED.menu.isSelected('menu-item-sidebar')) {
207
- sidebarControls
208
- .find('i')
209
- .addClass('fa-chevron-right')
210
- .removeClass('fa-chevron-left');
211
- } else {
212
- sidebarControls
213
- .find('i')
214
- .removeClass('fa-chevron-right')
215
- .addClass('fa-chevron-left');
216
- }
217
- sidebarControls.toggle('slide', { direction: 'right' }, 200);
218
- }
219
- });
220
- $('#sidebar-separator').on('mouseleave', function () {
221
- if (!sidebarSeparator.dragging) {
222
- sidebarControls.hide();
223
- }
224
- });
225
152
 
226
- function maximizeSidebar(){
153
+ function maxWidthSidebar() {
227
154
  const totalWidth = $('#main-container').width();
228
155
  const shortcutsWidth = 50;
229
156
  const paletteWidth = $('#palette').width();
230
157
  const sidebarSeparatorWidth = $('#sidebar-separator').width()
231
158
 
232
- const targetWidth = totalWidth - shortcutsWidth - paletteWidth - sidebarSeparatorWidth;
159
+ return totalWidth - shortcutsWidth - paletteWidth - sidebarSeparatorWidth;
160
+ }
161
+
162
+ function maximizeSidebar(){
163
+ const targetWidth = maxWidthSidebar();
233
164
  $('#sidebar').width(targetWidth);
234
- $('#sidebar-separator').css('left', paletteWidth);
235
165
 
236
166
  // Hack: Make sure the workspace if reset before maximizing the sidebar. This is because when dragging the sidebar the workspace width is also modified
237
167
  $('#workspace').css('right', 491);
@@ -242,7 +172,7 @@ RED.sidebar = (function () {
242
172
  const offsetWidth = 435;
243
173
 
244
174
  $('#sidebar').width(offsetWidth);
245
- $('#sidebar-separator').css('left', '');
175
+ // $('#sidebar-separator').css('left', '');
246
176
  RED.events.emit('sidebar:resize');
247
177
  }
248
178
 
@@ -251,7 +181,6 @@ RED.sidebar = (function () {
251
181
  }
252
182
 
253
183
  function toggleSidebar(state) {
254
- // console.log(`[sidebar] toggling the sidebar to: ${state} ...`);
255
184
  let checkIfscrollWorkspaceRequired = false;
256
185
  if (!state) {
257
186
  // Hide the sidebar and sidebar-separator
@@ -283,11 +212,13 @@ RED.sidebar = (function () {
283
212
  // `);
284
213
  if (nodeSelectedPosX - initialScrollLeft + safeDistNodeSidebar > sidebarPosLeftX ){
285
214
  let targetScrollLeft = nodeSelectedPosX - sidebarPosLeftX + safeDistNodeSidebar;
286
- // console.log(`[sidebar] TargetScrollLeft: (${targetScrollLeft})...`);
287
215
  $('#chart').animate( { scrollLeft: targetScrollLeft})
288
216
  }
289
217
  }
290
-
218
+ }
219
+
220
+ function isSidebarDragging() {
221
+ return sidebarDragging;
291
222
  }
292
223
 
293
224
  function showSidebar(id) {
@@ -317,12 +248,11 @@ RED.sidebar = (function () {
317
248
  });
318
249
 
319
250
  //hide the sidebar-separator
320
- $('#sidebar-separator').hide();
251
+ // $('#sidebar-separator').hide();
321
252
 
322
253
  }
323
254
 
324
255
  function selectTab(index){
325
- // console.log('[sidebar] selectTab clicked with index=', index);
326
256
  let selectedTab = $('#sidebar-shortcuts').find('.sidebar-shortcuts-icons').children()[index];
327
257
  // Click only if has not been selected
328
258
  // console.log('[sidebar] selectedTab.hasClass(selected)=', selectedTab.hasClass('selected'));
@@ -345,14 +275,9 @@ RED.sidebar = (function () {
345
275
  toggleSidebar(true);
346
276
 
347
277
  //show the sidebar-separator
348
- let sidebarSeparator = $('#sidebar-separator');
349
- sidebarSeparator.show();
350
-
351
- // resize the workspace to adjust to the left of the sidebar separator
352
- let sidebarSepatorToRight = sidebarSeparator.position().left;
353
- let mainContainerWidth = $('#main-container').width();
354
- let targetRightPosToWorkspace = mainContainerWidth - sidebarSepatorToRight - 1;
355
- $('#workspace').css('right', targetRightPosToWorkspace);
278
+ // let sidebarSeparator = $('#sidebar-separator');
279
+ // sidebarSeparator.show();
280
+
356
281
  // Select internally the tab
357
282
  if (e && e.hasOwnProperty('selectIndex')){
358
283
  selectTab(e.selectIndex);
@@ -360,8 +285,12 @@ RED.sidebar = (function () {
360
285
  });
361
286
 
362
287
  RED.actions.add('core:hide-sidebar', function(){
363
- toggleSidebar(false);
364
- deselectAll();
288
+ if (!sidebarDragging){
289
+ toggleSidebar(false);
290
+ deselectAll();
291
+ }else {
292
+ console.log('[sidebar] Ignoring hide-sidebar as dragging is still enabled')
293
+ }
365
294
  });
366
295
 
367
296
  // RED.popover.tooltip(
@@ -406,6 +335,7 @@ RED.sidebar = (function () {
406
335
  restore: restoreSidebar,
407
336
  deselectAll: deselectAll,
408
337
  selectTab: selectTab,
409
- isSidebarVisible: isSidebarVisible
338
+ isSidebarVisible: isSidebarVisible,
339
+ isDragging: isSidebarDragging,
410
340
  };
411
341
  })();
@@ -234,7 +234,20 @@ RED.sidebar.git = (function(){
234
234
  const result = await git.push('origin', currentBranch);
235
235
  RED.notify(`Changes pushed successfully`, 'success', undefined, 800);
236
236
  } catch(e) {
237
- RED.notify(`<strong>Error</strong>: ${e.message}`, 'error');
237
+ let notification = RED.notify(`<strong>Error</strong>: ${e.message}`, {
238
+ type: 'error',
239
+ modal: true,
240
+ fixed: true,
241
+ buttons: [
242
+ {
243
+ text: "Cancel",
244
+ click: function() {
245
+ notification.close();
246
+ }
247
+ }
248
+ ]
249
+ });
250
+
238
251
  } finally {
239
252
  resetPushButton();
240
253
  checkGitStatus();
@@ -30,7 +30,7 @@ RED.tray = (function () {
30
30
 
31
31
  function resize() {}
32
32
  function showTray(options) {
33
- console.log('[tray] showTray. options=', options);
33
+ // console.log('[tray] showTray. options=', options);
34
34
 
35
35
  $('#editor-stack').empty();
36
36
 
@@ -343,7 +343,7 @@ RED.tray = (function () {
343
343
 
344
344
 
345
345
  if (stack.length === 0) {
346
- console.log('[tray] Emiting event: (editor:open) ...')
346
+ // console.log('[tray] Emiting event: (editor:open) ...')
347
347
  RED.events.emit('editor:open');
348
348
  showTray(options);
349
349
  } else if (stack.length > 0 && options.title.startsWith('_')) {
@@ -2002,7 +2002,7 @@ RED.view = (function () {
2002
2002
  RED.editor.edit(selection);
2003
2003
  }else{
2004
2004
  // User has clicked on the canvas or link
2005
- // console.log('[view] Selection has not changed. Ignore');
2005
+ console.log('[view] Selection has not changed. Ignore');
2006
2006
  // Just close the sidebar
2007
2007
  RED.editor.resetEditor();
2008
2008
  }
@@ -96,9 +96,16 @@
96
96
  }
97
97
 
98
98
  .kumo-section-title {
99
+ border-top: 1px solid lightgrey;
100
+ padding-top: 7px;
99
101
  margin-top: 7px;
100
- margin-left: 5px;
102
+ margin-left: 10px;
101
103
  margin-bottom: 4px;
104
+ color: #605d5d;
105
+ font-weight: bold;
106
+ letter-spacing: 0.1em;
107
+ text-transform: uppercase;
108
+ font-size: x-small;
102
109
  }
103
110
 
104
111
  .kumo-section-tips {
@@ -152,7 +159,7 @@
152
159
  width: auto;
153
160
  right: -1000px;
154
161
  bottom: 0;
155
- background: #fff;
162
+ background: #f3f3f3;
156
163
  border-left: 1px solid $secondary-border-color;
157
164
  border-bottom: 1px solid $primary-border-color;
158
165
  box-sizing: content-box;
@@ -226,7 +233,7 @@
226
233
  border-left: 1px solid lightgrey;
227
234
  border-right: 1px solid lightgrey;
228
235
  border-top: 1px solid lightgrey;
229
- border-bottom: 1px solid white;
236
+ border-bottom: 1px solid #f3f3f3;
230
237
  border-radius: 4px 4px 0px 0px;
231
238
  }
232
239
  }
@@ -30,7 +30,8 @@
30
30
  min-width:435px;
31
31
  background: #fff;
32
32
  z-index: 10;
33
- @include component-border;
33
+ border-left: 1px solid #ddd;
34
+ // @include component-border;
34
35
  }
35
36
 
36
37
  #sidebar-views {
@@ -96,24 +97,23 @@
96
97
  }
97
98
 
98
99
  #sidebar-separator {
99
- position: absolute;
100
- top: 0px;
101
- right: 485px;
102
- bottom: 10px;
103
- width: 7px;
100
+ position: sticky !important;
101
+ left: 0 !important;
104
102
  z-index: 11;
105
103
  background: $background-color url(images/grip.png) no-repeat 50% 50%;
106
104
  cursor: col-resize;
107
- border-left:1px solid #bbb;
105
+ border-left:4px solid #f3f3f3;
108
106
  height: 100%;
107
+ &:hover{
108
+ border-left:4px solid #2979ff;
109
+ }
109
110
  }
110
111
 
111
112
  .sidebar-closed > #sidebar {
112
113
  display: none;
113
114
  }
114
115
  .sidebar-closed > #sidebar-separator {
115
- //right: 0px !important;
116
- display: none;
116
+ // display: none;
117
117
  }
118
118
  .sidebar-closed > #workspace {
119
119
  right: 49px !important;
@@ -39,7 +39,7 @@
39
39
  width: 100%;
40
40
  position: relative;
41
41
  left: 1px;
42
- justify-content: space-between;
42
+ // justify-content: space-between;
43
43
  box-sizing: border-box;
44
44
 
45
45
  .red-ui-tabs-scroll-container {
@@ -50,7 +50,7 @@
50
50
  }
51
51
 
52
52
  .sidebar-open #workspace {
53
- right: 491px;
53
+ right: 486px;
54
54
  }
55
55
 
56
56
  .workspace-footer-button {
@@ -231,6 +231,7 @@
231
231
 
232
232
 
233
233
  <div id="sidebar">
234
+ <div id="sidebar-separator" ></div>
234
235
  <div id="sidebar-views">
235
236
  <div id="sidebar-content">
236
237
  <div id="editor-stack"></div>
@@ -239,7 +240,7 @@
239
240
  </div>
240
241
  <div id="sidebar-shade" class="hide"></div>
241
242
  </div>
242
- <div id="sidebar-separator"></div>
243
+
243
244
 
244
245
 
245
246
  <div id="sidebar-shortcuts">