mirror of
				https://github.com/zen-browser/desktop.git
				synced 2025-10-26 12:27:50 +00:00 
			
		
		
		
	Started working on workspaces
This commit is contained in:
		
							
								
								
									
										19
									
								
								docs/workspaces.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								docs/workspaces.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,19 @@ | |||||||
|  |  | ||||||
|  | # Workspaces Layout | ||||||
|  |  | ||||||
|  | ``` | ||||||
|  | { | ||||||
|  |   "workspaces": [ | ||||||
|  |     { | ||||||
|  |       "uuid": "uuid1", | ||||||
|  |       "name": "workspace1", | ||||||
|  |       "icon": "icon1", | ||||||
|  |       "default": true | ||||||
|  |     }, | ||||||
|  |     ... | ||||||
|  |   ] | ||||||
|  | } | ||||||
|  | ``` | ||||||
|  | To save the tabs and identity them, they will contain a `zen-workspace-uuid` attribute with the workspace uuid. | ||||||
|  |  | ||||||
|  | We will make use of firefox's builtin session restore feature to save the tabs and windows after the user closes the browser. | ||||||
| @@ -8,5 +8,11 @@ var gZenUIManager = { | |||||||
|     } |     } | ||||||
|     let tab = window.gBrowser.addTrustedTab(url, options); |     let tab = window.gBrowser.addTrustedTab(url, options); | ||||||
|     window.gBrowser.selectedTab = tab; |     window.gBrowser.selectedTab = tab; | ||||||
|   } |   }, | ||||||
|  |  | ||||||
|  |   generateUuidv4() { | ||||||
|  |     return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, c => | ||||||
|  |       (+c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> +c / 4).toString(16) | ||||||
|  |     ); | ||||||
|  |   },   | ||||||
| }; | }; | ||||||
|   | |||||||
| @@ -25,20 +25,30 @@ var ZenWorkspaces = { | |||||||
|     } |     } | ||||||
|   }, |   }, | ||||||
|  |  | ||||||
|   async saveWorkspace(workspaceData, windowID) { |   async saveWorkspace(workspaceData) { | ||||||
|     let json = await IOUtils.readJSON(this._storeFile); |     let json = await IOUtils.readJSON(this._storeFile); | ||||||
|     json[windowID] = workspaceData; |     if (!json.workspaces) { | ||||||
|  |       json.workspaces = []; | ||||||
|  |     } | ||||||
|  |     json.workspaces.push(workspaceData); | ||||||
|  |     console.log("Saving workspace", workspaceData); | ||||||
|     await IOUtils.writeJSON(this._storeFile, json); |     await IOUtils.writeJSON(this._storeFile, json); | ||||||
|   }, |   }, | ||||||
|  |  | ||||||
|   async loadWorkspace(windowID) { |   async loadWorkspace(windowID) { | ||||||
|     let json = await IOUtils.readJSON(this._storeFile); |     let json = await IOUtils.readJSON(this._storeFile); | ||||||
|     return json[windowID]; |     if (!json.workspaces) { | ||||||
|  |       return []; | ||||||
|  |     } | ||||||
|  |     return json.workspaces.filter(workspace => workspace.uuid === windowID); | ||||||
|   }, |   }, | ||||||
|  |  | ||||||
|   async removeWorkspace(windowID) { |   async removeWorkspace(windowID) { | ||||||
|     let json = await IOUtils.readJSON(this._storeFile); |     let json = await IOUtils.readJSON(this._storeFile); | ||||||
|     delete json[windowID]; |     if (!json.workspaces) { | ||||||
|  |       return; | ||||||
|  |     } | ||||||
|  |     json.workspaces = json.workspaces.filter(workspace => workspace.uuid !== windowID); | ||||||
|     await IOUtils.writeJSON(this._storeFile, json); |     await IOUtils.writeJSON(this._storeFile, json); | ||||||
|   }, |   }, | ||||||
|  |  | ||||||
| @@ -47,27 +57,33 @@ var ZenWorkspaces = { | |||||||
|     return json; |     return json; | ||||||
|   }, |   }, | ||||||
|  |  | ||||||
|   async getWorkspace(windowID) { |   // Workspaces dialog UI management | ||||||
|     let json = await IOUtils.readJSON(this._storeFile); |  | ||||||
|     return json[windowID]; |    | ||||||
|   }, |  | ||||||
|  |  | ||||||
|   // Workspaces management |   // Workspaces management | ||||||
|  |  | ||||||
|   _createWorkspaceData(windowID) { |   _prepareNewWorkspace(window) { | ||||||
|     let window = Services.wm.getOuterWindowWithId(windowID); |     for (let tab of window.gBrowser.tabs) { | ||||||
|     let tabs = Array.from(window.gBrowser.tabs).map(tab => ({ |       tab.addAttribute("zen-workspace-id", window.uuid); | ||||||
|       url: tab.linkedBrowser.currentURI.spec, |     } | ||||||
|       title: tab.label, |     window.document.documentElement.setAttribute("zen-workspace-id", window.uuid); | ||||||
|     })); |  | ||||||
|     return { |  | ||||||
|       tabs, |  | ||||||
|     }; |  | ||||||
|   }, |   }, | ||||||
|  |  | ||||||
|   async saveCurrentWorkspace(windowID) { |   _createWorkspaceData() { | ||||||
|     let workspaceData = this._createWorkspaceData(windowID); |     let window = { | ||||||
|     await this.saveWorkspace(workspaceData, windowID); |       uuid: gZenUIManager.generateUuidv4(), | ||||||
|  |       default: false, | ||||||
|  |       icon: "", | ||||||
|  |       name: `New Workspace`, | ||||||
|  |     }; | ||||||
|  |     this._prepareNewWorkspace(window); | ||||||
|  |     return window; | ||||||
|  |   }, | ||||||
|  |  | ||||||
|  |   async createAndSaveWorkspace() { | ||||||
|  |     let workspaceData = this._createWorkspaceData(); | ||||||
|  |     await this.saveWorkspace(workspaceData); | ||||||
|   }, |   }, | ||||||
| }; | }; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,11 +0,0 @@ | |||||||
| diff --git a/browser/base/content/appmenu-viewcache.inc.xhtml b/browser/base/content/appmenu-viewcache.inc.xhtml |  | ||||||
| index 07b1765f18236835363fb74c898d3a690659cc9b..7b58cbb5de147ed29fbc48c0093c731fe5cca90b 100644 |  | ||||||
| --- a/browser/base/content/appmenu-viewcache.inc.xhtml |  | ||||||
| +++ b/browser/base/content/appmenu-viewcache.inc.xhtml |  | ||||||
| @@ -765,5 +765,6 @@ |  | ||||||
|      </vbox> |  | ||||||
|    </panelview> |  | ||||||
|   |  | ||||||
| +#include zen-panels-ui.inc.xhtml |  | ||||||
|  #include ../../components/reportbrokensite/content/reportBrokenSitePanel.inc.xhtml |  | ||||||
|  </html:template> |  | ||||||
| @@ -1,18 +0,0 @@ | |||||||
| <panelview id="PanelUI-zen-profiles" position="bottomleft topleft" mainview="true" side="right"> |  | ||||||
|   <vbox> |  | ||||||
|     <html:div id="PanelUI-zen-profiles-header"> |  | ||||||
|       <html:div id="PanelUI-zen-profiles-user-picture"></html:div> |  | ||||||
|     </html:div> |  | ||||||
|     <vbox id="PanelUI-zen-profiles-current-info"> |  | ||||||
|       <label id="PanelUI-zen-profiles-current-name"></label> |  | ||||||
|       <p id="PanelUI-zen-profiles-current-profile-current" data-l10n-id="zen-panel-ui-current-profile-text"></p> |  | ||||||
|     </vbox> |  | ||||||
|     <hbox id="PanelUI-zen-profiles-actions"> |  | ||||||
|       <toolbarbutton id="PanelUI-zen-profiles-managePrfs" oncommand="switchToTabHavingURI('about:profiles', true);" data-l10n-id="appmenu-manage-profiles" class="subviewbutton"></toolbarbutton> |  | ||||||
|       <toolbarbutton id="PanelUI-zen-profiles-privateWin" command="Tools:PrivateBrowsing" data-l10n-id="appmenuitem-new-private-window" class="subviewbutton"></toolbarbutton> |  | ||||||
|       <toolbarbutton id="PanelUI-zen-profiles-newProfile" oncommand="ZenProfileDialogUI.createProfileWizard();" data-l10n-id="appmenu-create-profile" class="subviewbutton"></toolbarbutton> |  | ||||||
|     </hbox> |  | ||||||
|     <vbox id="PanelUI-zen-profiles-list">       |  | ||||||
|     </vbox> |  | ||||||
|   </vbox> |  | ||||||
| </panelview> |  | ||||||
| @@ -56,3 +56,22 @@ | |||||||
|   </panelmultiview> |   </panelmultiview> | ||||||
| </panel> | </panel> | ||||||
| </html:template> | </html:template> | ||||||
|  |  | ||||||
|  | <panelview id="PanelUI-zen-profiles" position="bottomleft topleft" mainview="true" side="right"> | ||||||
|  |   <vbox> | ||||||
|  |     <html:div id="PanelUI-zen-profiles-header"> | ||||||
|  |       <html:div id="PanelUI-zen-profiles-user-picture"></html:div> | ||||||
|  |     </html:div> | ||||||
|  |     <vbox id="PanelUI-zen-profiles-current-info"> | ||||||
|  |       <label id="PanelUI-zen-profiles-current-name"></label> | ||||||
|  |       <p id="PanelUI-zen-profiles-current-profile-current" data-l10n-id="zen-panel-ui-current-profile-text"></p> | ||||||
|  |     </vbox> | ||||||
|  |     <hbox id="PanelUI-zen-profiles-actions"> | ||||||
|  |       <toolbarbutton id="PanelUI-zen-profiles-managePrfs" oncommand="switchToTabHavingURI('about:profiles', true);" data-l10n-id="appmenu-manage-profiles" class="subviewbutton"></toolbarbutton> | ||||||
|  |       <toolbarbutton id="PanelUI-zen-profiles-privateWin" command="Tools:PrivateBrowsing" data-l10n-id="appmenuitem-new-private-window" class="subviewbutton"></toolbarbutton> | ||||||
|  |       <toolbarbutton id="PanelUI-zen-profiles-newProfile" oncommand="ZenProfileDialogUI.createProfileWizard();" data-l10n-id="appmenu-create-profile" class="subviewbutton"></toolbarbutton> | ||||||
|  |     </hbox> | ||||||
|  |     <vbox id="PanelUI-zen-profiles-list">       | ||||||
|  |     </vbox> | ||||||
|  |   </vbox> | ||||||
|  | </panelview> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Mauro Balades
					Mauro Balades