-
-
Notifications
You must be signed in to change notification settings - Fork 442
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make org tabs draggable in sidebar #617
Conversation
4b970aa
to
f23cd95
Compare
Don't know if its because its in WIP but the webviews (incll sidebar) hang for me if I try to drag and change the order, |
I don't know why that's happening. Can you explain any specific steps you took so that I can reproduce this? |
I've found another problem that you may see if you clear app data, add a couple (or more) organisations and then drag them around: This is caused because of line number 178 in I'll need to get the actual old index from the |
@kanishk98 attached a gif. You can also see the console error for |
@abhigyank thanks for the gif. Looks like |
As for the problem I mentioned above (related to clearing app data, dragging new domains, and getting a crash), that's because the |
Yes, that is the main issue here. From what I recall, Akash had previously suggested storing the index of the servers in domain.json itself. Then we'd be work all functions according to that index. |
b58c34e
to
b9e600b
Compare
I've used another solution, as follows: tabElements.forEach((el, index) => {
const oldIndex = +Number(el.getAttribute('data-tab-id')) % tabElements.length; This should work fine for the reset and drag crash. |
eb129f3
to
d3764e2
Compare
I'm unable to understand why the webviews freeze after dragging the server tabs. I've logged that they load and the index of the registered clicks is correct (and corresponds to the correct server). I'd really like some pointers on why this might happen. |
Looks great 👍 |
171ff4b
to
7774da8
Compare
Hello, just checking in to ask if any other changes are required here. :) Edit: I realized a little too late that running |
6386a39
to
98f6fc3
Compare
Updated PR to TypeScript. |
@kanishk98 please update the PR. @priyank-p can you help him with the implementation/logic here? |
f96767a
to
20272a2
Compare
Fixed merge conflicts - I think the functionality was mostly alright. Would love a review anytime. :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments! Looks like you forgot to add sortablejs
as a dependency?
app/renderer/js/main.js
Outdated
@@ -156,12 +156,12 @@ class ServerManagerView { | |||
const domains = []; | |||
const tabElements = document.querySelectorAll('#tabs-container .tab'); | |||
tabElements.forEach((el, index) => { | |||
const oldIndex = +el.getAttribute('data-tab-id'); | |||
const oldIndex = +Number(el.getAttribute('data-tab-id')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The use of Number
is useless here, that's what the +
does here.
app/renderer/main.html
Outdated
@@ -15,7 +15,7 @@ | |||
</div> | |||
<div id="sidebar" class="toggle-sidebar"> | |||
<div id="view-controls-container"> | |||
<div id="tabs-container"></div> | |||
<div id="tabs-container" class="simple-list"></div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might want to pick a better name for this class here like organizations-list
or sortable-organizations-list
here.
app/renderer/js/main.ts
Outdated
@@ -231,14 +233,37 @@ class ServerManagerView { | |||
} | |||
} | |||
|
|||
onEnd(): void { | |||
const newServers: any[] | ServerOrFunctionalTab[] = []; | |||
const tabMap: any = {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should create a interface here for this, it's just:
const tabMap: any = {}; | |
interface TabMap { | |
[key: number]: number; | |
} | |
const tabMap: TabMap = {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also we should probably add a detailed comment here what tabMap
stores and how it works. I used know the logic back almost a year ago and now looking at this I have no idea what this is which is the perfect reason to add a comment here.
app/renderer/js/main.ts
Outdated
@@ -123,6 +126,7 @@ class ServerManagerView { | |||
this.$dndTooltip = $actionsContainer.querySelector('#dnd-tooltip'); | |||
|
|||
this.$sidebar = document.querySelector('#sidebar'); | |||
this.$drag = document.querySelector('#simple-list'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could be more verbose here i.e. this.$sortableDrag
app/renderer/js/main.ts
Outdated
@@ -94,7 +94,7 @@ class ServerManagerView { | |||
$fullscreenEscapeKey: string; | |||
loading: AnyObject; | |||
activeTabIndex: number; | |||
servers: ServerOrFunctionalTab[]; | |||
servers: any[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this switched back to any
?
app/main/index.ts
Outdated
@@ -366,7 +366,9 @@ app.on('ready', () => { | |||
|
|||
app.on('before-quit', () => { | |||
mainWindow.webContents.send('save-domains'); | |||
isQuitting = true; | |||
setTimeout(() => { | |||
isQuitting = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, how did you come to this conclusion here? This seems a workaround than a correct fix.
@priyank-p thanks a lot for the review! I think a couple of those mistakes you listed above are because I accidentally force pushed a faulty commit at the time of review, but I'll have a look again and finalize this PR by tonight. :) |
20272a2
to
98f40de
Compare
I've updated this PR and used a batch-write function for replacing the old order of domains with the new order. This works well for me, I'd love for everyone to try it out on their end and check for missing servers/duplication (this is why we're reading the order of servers from memory for the most part). |
@kanishk98 can you fix the merge conflict? Also, I have noticed that we are not loading the server which is being dragged and I think we want to load that server instead of the new org on that index. Also, the order is not right - |
Heads up @kanishk98, we just merged some commits that conflict with the changes your made in this pull request! You can review this repository's recent commits to see where the conflicts occur. Please rebase your feature branch against the |
@akashnimare I can't reproduce this
The order is working well for me |
I would suggest we should first look into the DB migration and then work on this feature. |
Due to no recent activity, closing in favour of #1059 . |
What's this PR do?
Updates
domains.json
on dragging server tabs and (intends to) reorder server tooltips along with that.Any background context you want to provide?
Please refer to the discussion in #548.
You have tested this PR on:
Current behaviour on Windows 10 (CSS animations by
sortablejs
not recorded by Windows Game Bar)Problems in current version
On my computer, the server tab freezes for a bit before I can switch tabs again.
Other possible solutions that I considered
replaceChild()
as long as we maintain clones of the old tooltip node.