2626 ref =" sidebar"
2727 v-bind =" appSidebar"
2828 :force-menu =" true"
29- @close =" onClose "
29+ @close =" close "
3030 @update:active =" setActiveTab"
3131 @update:starred =" toggleStarred"
3232 @[defaultActionListener].stop.prevent =" onDefaultAction" >
@@ -238,35 +238,6 @@ export default {
238238
239239 isSystemTagsEnabled () {
240240 return OCA && ' SystemTags' in OCA
241- }
242- },
243-
244- watch: {
245- // update the sidebar data
246- async file (curr , prev ) {
247- this .resetData ()
248- if (curr && curr .trim () !== ' ' ) {
249- try {
250- this .fileInfo = await FileInfo (this .davPath )
251- // adding this as fallback because other apps expect it
252- this .fileInfo .dir = this .file .split (' /' ).slice (0 , - 1 ).join (' /' )
253-
254- // DEPRECATED legacy views
255- // TODO: remove
256- this .views .forEach (view => {
257- view .setFileInfo (this .fileInfo )
258- })
259-
260- this .$nextTick (() => {
261- if (this .$refs .sidebar ) {
262- this .$refs .sidebar .updateTabs ()
263- }
264- })
265- } catch (error) {
266- this .error = t (' files' , ' Error while loading the file data' )
267- console .error (' Error while loading the file data' , error)
268- }
269- }
270241 },
271242 },
272243
@@ -280,10 +251,6 @@ export default {
280251 canDisplay (tab ) {
281252 return tab .isEnabled (this .fileInfo )
282253 },
283- onClose () {
284- this .resetData ()
285- OCA .Files .Sidebar .close ()
286- },
287254 resetData () {
288255 this .error = null
289256 this .fileInfo = null
@@ -406,7 +373,54 @@ export default {
406373 if (OCA .SystemTags && OCA .SystemTags .View ) {
407374 OCA .SystemTags .View .toggle ()
408375 }
409- }
376+ },
377+
378+ /**
379+ * Open the sidebar for the given file
380+ *
381+ * @param {string} path the file path to load
382+ * @returns {Promise}
383+ * @throws {Error} loading failure
384+ */
385+ async open (path ) {
386+ // update current opened file
387+ this .Sidebar .file = path
388+
389+ // reset previous data
390+ this .resetData ()
391+ if (path && path .trim () !== ' ' ) {
392+ try {
393+ this .fileInfo = await FileInfo (this .davPath )
394+ // adding this as fallback because other apps expect it
395+ this .fileInfo .dir = this .file .split (' /' ).slice (0 , - 1 ).join (' /' )
396+
397+ // DEPRECATED legacy views
398+ // TODO: remove
399+ this .views .forEach (view => {
400+ view .setFileInfo (this .fileInfo )
401+ })
402+
403+ this .$nextTick (() => {
404+ if (this .$refs .sidebar ) {
405+ this .$refs .sidebar .updateTabs ()
406+ }
407+ })
408+ } catch (error) {
409+ this .error = t (' files' , ' Error while loading the file data' )
410+ console .error (' Error while loading the file data' , error)
411+
412+ throw new Error (error)
413+ }
414+ }
415+ },
416+
417+ /**
418+ * Close the sidebar
419+ */
420+ close () {
421+ this .Sidebar .file = ' '
422+ this .resetData ()
423+ },
410424 },
411425}
412426 </script >
0 commit comments