@@ -10,8 +10,11 @@ import {
1010 WorkspaceRole ,
1111 getClientProfile ,
1212 getSystemPath ,
13+ isDesktop ,
14+ mountWorkspace ,
1315 getPathLink as parsecGetPathLink ,
1416 renameWorkspace as parsecRenameWorkspace ,
17+ unmountWorkspace ,
1518} from '@/parsec' ;
1619import { Routes , navigateTo } from '@/router' ;
1720import { EventDistributor } from '@/services/eventDistributor' ;
@@ -138,6 +141,7 @@ export async function openWorkspaceContextMenu(
138141 clientProfile : clientProfile ,
139142 clientRole : workspace . currentSelfRole ,
140143 isFavorite : workspaceAttributes . isFavorite ( workspace . id ) ,
144+ isHidden : workspaceAttributes . isHidden ( workspace . id ) ,
141145 } ,
142146 } ) ;
143147
@@ -156,6 +160,7 @@ export async function openWorkspaceContextMenu(
156160 clientProfile : clientProfile ,
157161 clientRole : workspace . currentSelfRole ,
158162 isFavorite : workspaceAttributes . isFavorite ( workspace . id ) ,
163+ isHidden : workspaceAttributes . isHidden ( workspace . id ) ,
159164 } ,
160165 } ) ;
161166
@@ -184,12 +189,92 @@ export async function openWorkspaceContextMenu(
184189 case WorkspaceAction . ShowHistory :
185190 await navigateTo ( Routes . History , { query : { documentPath : '/' , workspaceHandle : workspace . handle } } ) ;
186191 break ;
192+ case WorkspaceAction . Mount :
193+ await showWorkspace ( workspace , workspaceAttributes , informationManager ) ;
194+ break ;
195+ case WorkspaceAction . UnMount :
196+ await hideWorkspace ( workspace , workspaceAttributes , informationManager ) ;
197+ break ;
187198 default :
188199 console . warn ( 'No WorkspaceAction match found' ) ;
189200 }
190201 }
191202}
192203
204+ export async function showWorkspace (
205+ workspace : WorkspaceInfo ,
206+ workspaceAttributes : WorkspaceAttributes ,
207+ informationManager : InformationManager ,
208+ ) : Promise < void > {
209+ let ok = true ;
210+ if ( isDesktop ( ) ) {
211+ const result = await mountWorkspace ( workspace . handle ) ;
212+ ok = result . ok ;
213+ }
214+
215+ if ( ok ) {
216+ workspaceAttributes . removeHidden ( workspace . id ) ;
217+ informationManager . present (
218+ new Information ( {
219+ message : {
220+ key : isDesktop ( ) ? 'WorkspacesPage.showHideWorkspace.successDesktopShown' : 'WorkspacesPage.showHideWorkspace.successWebShown' ,
221+ data : { workspace : workspace . currentName } ,
222+ } ,
223+ level : InformationLevel . Success ,
224+ } ) ,
225+ PresentationMode . Toast ,
226+ ) ;
227+ } else {
228+ informationManager . present (
229+ new Information ( {
230+ message : {
231+ key : 'WorkspacesPage.showHideWorkspace.failedShown' ,
232+ data : { workspace : workspace . currentName } ,
233+ } ,
234+ level : InformationLevel . Error ,
235+ } ) ,
236+ PresentationMode . Toast ,
237+ ) ;
238+ }
239+ }
240+
241+ export async function hideWorkspace (
242+ workspace : WorkspaceInfo ,
243+ workspaceAttributes : WorkspaceAttributes ,
244+ informationManager : InformationManager ,
245+ ) : Promise < void > {
246+ let ok = true ;
247+ if ( isDesktop ( ) ) {
248+ const result = await unmountWorkspace ( workspace ) ;
249+ ok = result . ok ;
250+ }
251+
252+ if ( ok ) {
253+ workspaceAttributes . addHidden ( workspace . id ) ;
254+ informationManager . present (
255+ new Information ( {
256+ message : {
257+ key : isDesktop ( ) ? 'WorkspacesPage.showHideWorkspace.successDesktopHidden' : 'WorkspacesPage.showHideWorkspace.successWebHidden' ,
258+ data : { workspace : workspace . currentName } ,
259+ } ,
260+ level : InformationLevel . Success ,
261+ } ) ,
262+ PresentationMode . Toast ,
263+ ) ;
264+ } else {
265+ informationManager . present (
266+ new Information ( {
267+ message : {
268+ key : 'WorkspacesPage.showHideWorkspace.failedHidden' ,
269+ data : { workspace : workspace . currentName } ,
270+ } ,
271+ level : InformationLevel . Error ,
272+ } ) ,
273+ PresentationMode . Toast ,
274+ ) ;
275+ }
276+ }
277+
193278async function openWorkspace ( workspace : WorkspaceInfo , informationManager : InformationManager ) : Promise < void > {
194279 const result = await getSystemPath ( workspace . handle , '/' ) ;
195280
0 commit comments