@@ -10,8 +10,10 @@ import {
1010 WorkspaceRole ,
1111 getClientProfile ,
1212 getSystemPath ,
13+ mountWorkspace ,
1314 getPathLink as parsecGetPathLink ,
1415 renameWorkspace as parsecRenameWorkspace ,
16+ unmountWorkspace ,
1517} from '@/parsec' ;
1618import { Routes , navigateTo } from '@/router' ;
1719import { EventDistributor } from '@/services/eventDistributor' ;
@@ -138,6 +140,7 @@ export async function openWorkspaceContextMenu(
138140 clientProfile : clientProfile ,
139141 clientRole : workspace . currentSelfRole ,
140142 isFavorite : workspaceAttributes . isFavorite ( workspace . id ) ,
143+ isHidden : workspaceAttributes . isHidden ( workspace . id ) ,
141144 } ,
142145 } ) ;
143146
@@ -156,6 +159,7 @@ export async function openWorkspaceContextMenu(
156159 clientProfile : clientProfile ,
157160 clientRole : workspace . currentSelfRole ,
158161 isFavorite : workspaceAttributes . isFavorite ( workspace . id ) ,
162+ isHidden : workspaceAttributes . isHidden ( workspace . id ) ,
159163 } ,
160164 } ) ;
161165
@@ -184,12 +188,84 @@ export async function openWorkspaceContextMenu(
184188 case WorkspaceAction . ShowHistory :
185189 await navigateTo ( Routes . History , { query : { documentPath : '/' , workspaceHandle : workspace . handle } } ) ;
186190 break ;
191+ case WorkspaceAction . Mount :
192+ await showWorkspace ( workspace , workspaceAttributes , informationManager ) ;
193+ break ;
194+ case WorkspaceAction . UnMount :
195+ await hideWorkspace ( workspace , workspaceAttributes , informationManager ) ;
196+ break ;
187197 default :
188198 console . warn ( 'No WorkspaceAction match found' ) ;
189199 }
190200 }
191201}
192202
203+ export async function showWorkspace (
204+ workspace : WorkspaceInfo ,
205+ workspaceAttributes : WorkspaceAttributes ,
206+ informationManager : InformationManager ,
207+ ) : Promise < void > {
208+ const result = await mountWorkspace ( workspace . handle ) ;
209+
210+ if ( result . ok ) {
211+ workspaceAttributes . removeHidden ( workspace . id ) ;
212+ informationManager . present (
213+ new Information ( {
214+ message : {
215+ key : 'WorkspacesPage.showHideWorkspace.successShown' ,
216+ data : { workspace : workspace . currentName } ,
217+ } ,
218+ level : InformationLevel . Success ,
219+ } ) ,
220+ PresentationMode . Toast ,
221+ ) ;
222+ } else {
223+ informationManager . present (
224+ new Information ( {
225+ message : {
226+ key : 'WorkspacesPage.showHideWorkspace.failedShown' ,
227+ data : { workspace : workspace . currentName } ,
228+ } ,
229+ level : InformationLevel . Error ,
230+ } ) ,
231+ PresentationMode . Toast ,
232+ ) ;
233+ }
234+ }
235+
236+ export async function hideWorkspace (
237+ workspace : WorkspaceInfo ,
238+ workspaceAttributes : WorkspaceAttributes ,
239+ informationManager : InformationManager ,
240+ ) : Promise < void > {
241+ const result = await unmountWorkspace ( workspace ) ;
242+
243+ if ( result . ok ) {
244+ workspaceAttributes . addHidden ( workspace . id ) ;
245+ informationManager . present (
246+ new Information ( {
247+ message : {
248+ key : 'WorkspacesPage.showHideWorkspace.successHidden' ,
249+ data : { workspace : workspace . currentName } ,
250+ } ,
251+ level : InformationLevel . Success ,
252+ } ) ,
253+ PresentationMode . Toast ,
254+ ) ;
255+ } else {
256+ informationManager . present (
257+ new Information ( {
258+ message : {
259+ key : 'WorkspacesPage.showHideWorkspace.failedHidden' ,
260+ data : { workspace : workspace . currentName } ,
261+ } ,
262+ level : InformationLevel . Error ,
263+ } ) ,
264+ PresentationMode . Toast ,
265+ ) ;
266+ }
267+ }
268+
193269async function openWorkspace ( workspace : WorkspaceInfo , informationManager : InformationManager ) : Promise < void > {
194270 const result = await getSystemPath ( workspace . handle , '/' ) ;
195271
0 commit comments