88 :class =" { 'icon-loading': loading }"
99 class =" activity" >
1010 <!-- error message -->
11- <NcEmptyContent v-if =" error || fileInfo === null " :name =" error" >
11+ <NcEmptyContent v-if =" error || !node " :name =" error" >
1212 <template #icon >
1313 <NcIconSvgWrapper :svg =" lightningBoltSVG" />
1414 </template >
2020 v-for =" plugin, index of sidebarPlugins"
2121 :key =" index"
2222 :plugin =" plugin"
23- :file-info = " fileInfo "
23+ :node = " node "
2424 @reload-activities =" getActivities()" />
2525 </div >
2626
5454</template >
5555
5656<script lang='ts'>
57+ import type { IFolder , INode , IView } from ' @nextcloud/files'
58+ import type { PropType } from ' vue'
5759import type { IActivitySidebarAction , IActivitySidebarEntry } from ' ../models/ActivityAPI.ts'
5860
5961import lightningBoltSVG from ' @mdi/svg/svg/lightning-bolt.svg?raw'
@@ -72,6 +74,7 @@ import logger from '../utils/logger.ts'
7274
7375const ActivityTab = defineComponent ({
7476 name: ' ActivityTab' ,
77+
7578 components: {
7679 ActivityComponent ,
7780 NcEmptyContent ,
@@ -80,30 +83,66 @@ const ActivityTab = defineComponent({
8083 ActivitySidebarPlugin ,
8184 },
8285
86+ props: {
87+ /**
88+ * The node currently displayed in the sidebar
89+ */
90+ node: {
91+ type: Object as PropType <INode >,
92+ required: true ,
93+ },
94+
95+ /**
96+ * The folder shown in the files app
97+ */
98+ // eslint-disable-next-line vue/no-unused-properties
99+ folder: {
100+ type: Object as PropType <IFolder | undefined >,
101+ required: false ,
102+ default: undefined ,
103+ },
104+
105+ /**
106+ * The view shown in the files app
107+ */
108+ // eslint-disable-next-line vue/no-unused-properties
109+ view: {
110+ type: Object as PropType <IView | undefined >,
111+ required: false ,
112+ default: undefined ,
113+ },
114+ },
115+
83116 expose: [' update' ],
84117
85118 data() {
86119 return {
87120 error: ' ' ,
88121 loading: true ,
89- fileInfo: null ,
90122 activities: [] as (IActivitySidebarEntry | ActivityModel )[],
91123 lightningBoltSVG ,
92124 sidebarPlugins: [] as IActivitySidebarAction [],
93125 }
94126 },
95127
128+ watch: {
129+ node: {
130+ immediate: true ,
131+ async handler(node : INode ) {
132+ await this .update (node )
133+ },
134+ },
135+ },
136+
96137 mounted() {
97138 this .sidebarPlugins = getSidebarActions ()
98139 },
99140
100141 methods: {
101142 /**
102- * Update current fileInfo and fetch new activities
103- *
104- * @param fileInfo the current file FileInfo
143+ * Update current view and fetch new activities
105144 */
106- async update(fileInfo ) {
145+ async update() {
107146 this .sidebarPlugins = []
108147 const sidebarPlugins = getSidebarActions ()
109148 if (sidebarPlugins .length > 0 ) {
@@ -112,7 +151,6 @@ const ActivityTab = defineComponent({
112151 })
113152 }
114153
115- this .fileInfo = fileInfo
116154 this .resetState ()
117155 await this .getActivities ()
118156 },
@@ -125,7 +163,7 @@ const ActivityTab = defineComponent({
125163 this .loading = true
126164
127165 const activities = await this .processActivities (await this .loadRealActivities ())
128- const otherEntries = await getAdditionalEntries ({ fileInfo : this .fileInfo })
166+ const otherEntries = await getAdditionalEntries ({ node : this .node })
129167 this .activities = [... activities , ... otherEntries ].sort ((a , b ) => b .timestamp - a .timestamp )
130168 } catch (error ) {
131169 this .error = t (' activity' , ' Unable to load the activity list' )
@@ -155,7 +193,7 @@ const ActivityTab = defineComponent({
155193 params: {
156194 format: ' json' ,
157195 object_type: ' files' ,
158- object_id: this .fileInfo . id ,
196+ object_id: this .node . fileid ,
159197 },
160198 },
161199 )
@@ -177,7 +215,9 @@ const ActivityTab = defineComponent({
177215 processActivities(activities ): ActivityModel [] {
178216 activities = activities .map ((activity ) => new ActivityModel (activity ))
179217
180- logger .debug (` Processed ${activities .length } activity(ies) ` , { activities , fileInfo: this .fileInfo })
218+ logger .debug (` Processed ${activities .length } activity(ies) ` , {
219+ activities , node: this .node ,
220+ })
181221
182222 const filters = getActivityFilters ()
183223 return activities .filter ((activity ) => ! filters || filters .every ((filter ) => filter (activity )))
0 commit comments