You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/docs/guide/Plugins/Plugins.mdx
+79-25Lines changed: 79 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -66,53 +66,46 @@ Check out example of adding an additional tab in a Smarty template in [backend-u
66
66
67
67
Starting with version 3.5, most new pages/managers have hooks to inject your custom component in various locations.
68
68
69
-
Pinia stores are used as an underlying mechanism to inject components and are exposing configuration functions that are driving the UI. It also makes it straightforward to interact with the store to retrieve data or trigger any existing actions.
69
+
More details about available hooks for individual pages/managers are covered in individual documentation ([Dashboard](../?path=/docs/pages-dashboard--docs), [Workflow](../?path=/docs/pages-workflow--docs), [FileManager](../?path=/docs/managers-filemanager--docs), [ReviewerManager](../?path=/docs/managers-reviewermanager--docs), [ParticipantManager](../?path=/docs/managers-participantmanager--docs), [GalleyManager](../?path=/docs/managers-galleymanager--docs)).
70
+
71
+
Pinia stores are used as an underlying tool for extensibility. JS Hooks can be leveraged using `store.extender`.
70
72
71
73
Example
72
74
73
75
```js
74
-
// Adding iThenticate column
75
-
pkp.registry.storeExtendFn(
76
-
// Pinia store name
77
-
'fileManager_SUBMISSION_FILES',
78
-
// Function to extend
79
-
'getColumns',
80
-
// Columns is the result from the original function, which can be adjusted
81
-
// Args are the arguments that the getColumns function retrieved to calculate the columns
82
-
// Context exposes props that are passed to given component
//Component responsible for rendering that table cell
99
+
//component responsible for rendering that table cell
105
100
component:'BuiFileManagerCellIthenticate',
106
101
props: {},
107
102
});
108
103
109
104
return newColumns;
110
-
},
111
-
);
105
+
});
106
+
});
112
107
```
113
108
114
-
More details about available hooks for individual pages/managers are covered in individual documentation ([Dashboard](../?path=/docs/pages-dashboard--docs), [Workflow](../?path=/docs/pages-workflow--docs), [FileManager](../?path=/docs/managers-filemanager--docs), [ReviewerManager](../?path=/docs/managers-reviewermanager--docs), [ParticipantManager](../?path=/docs/managers-participantmanager--docs), [GalleyManager](../?path=/docs/managers-galleymanager--docs)).
115
-
116
109
When the given store is present on the screen, it's also possible to get a list of available functions in the browser dev console with:
if (context.store.$id==='fileManager_SUBMISSION_FILES') {
147
+
// Add custom logic here
148
+
}
149
+
});
150
+
```
151
+
152
+
For example, if some additional data are needed, it's possible to fetch them and attach them to the store, so they're available within the given manager/page. The same [Composition API](../?path=/docs/guide-vue-composition-api--docs) syntax is used.
// attach the state to the store, so its possible to retrieve it for example in the components that are injected via JS Hooks
186
+
fileStore.ithenticateStatus= ithenticateStatus;
187
+
});
188
+
```
189
+
190
+
Complete example is available in [example plugin](https://github.com/jardakotesovec/backend-ui-example-plugin?tab=readme-ov-file#how-to-extend-filemanager-with-additional-column-and-custom-action).
191
+
138
192
### Advanced use cases
139
193
140
194
Pinia stores have their own [plugins API](https://pinia.vuejs.org/core-concepts/plugins.html). Therefore, as a plugin developer, you can leverage that. It should be used with caution, as any attempts to override store internals will likely lead to a fragile solution. But it provides some additional options for use cases which we have not considered.
0 commit comments