Skip to content

Commit 905b3a3

Browse files
pkp/pkp-lib#10067 Expose props via store for extensibility
1 parent 3e71591 commit 905b3a3

File tree

8 files changed

+27
-20
lines changed

8 files changed

+27
-20
lines changed

src/composables/useExtender.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Provides functions to extend and enhance existing functions
33
*/
4-
export function useExtender({context} = {context: {}}) {
4+
export function useExtender() {
55
/**
66
* Collection of functions that can be extended
77
* @type {Object<string, Function>}
@@ -33,7 +33,7 @@ export function useExtender({context} = {context: {}}) {
3333

3434
availableFunctions[fnName] = (...args) => {
3535
const originalResult = originalFn(...args);
36-
return extendingFn(originalResult, ...args, context);
36+
return extendingFn(originalResult, ...args);
3737
};
3838
}
3939

src/managers/FileManager/fileManagerStore.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {useExtender} from '@/composables/useExtender';
1010
export const useFileManagerStore = defineComponentStore(
1111
'fileManager',
1212
(props) => {
13-
const extender = useExtender({context: {props}});
13+
const extender = useExtender();
1414

1515
const {namespace, submissionStageId, submission} = toRefs(props);
1616
/**
@@ -169,6 +169,7 @@ export const useFileManagerStore = defineComponentStore(
169169

170170
/** exposed for extensibility purposes */
171171
extender,
172+
props,
172173
};
173174
},
174175
{requireNamespace: true},

src/managers/GalleyManager/galleyManagerStore.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {useExtender} from '@/composables/useExtender';
1111
export const useGalleyManagerStore = defineComponentStore(
1212
'galleyManager',
1313
(props) => {
14-
const extender = useExtender({context: {props}});
14+
const extender = useExtender();
1515

1616
const {submission, publication} = toRefs(props);
1717

@@ -216,6 +216,7 @@ export const useGalleyManagerStore = defineComponentStore(
216216

217217
/** Extender */
218218
extender,
219+
props,
219220
};
220221
},
221222
);

src/managers/ParticipantManager/participantManagerStore.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {useExtender} from '@/composables/useExtender';
1414
export const useParticipantManagerStore = defineComponentStore(
1515
'participantManager',
1616
(props) => {
17-
const extender = useExtender({context: {props}});
17+
const extender = useExtender();
1818
const submissionId = ref(props.submission.id);
1919

2020
const relativeUrl = computed(() => {
@@ -179,6 +179,7 @@ export const useParticipantManagerStore = defineComponentStore(
179179
participantLogoutAs,
180180

181181
extender,
182+
props,
182183
};
183184
},
184185
);

src/managers/ReviewerManager/reviewerManagerStore.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export const useReviewerManagerStore = defineComponentStore(
1414
getReviewAssignmentsForRound,
1515
} = useSubmission();
1616

17-
const extender = useExtender({context: {props}});
17+
const extender = useExtender();
1818

1919
const reviewAssignments = computed(() => {
2020
const reviewAssignmentsForSelectedRound = getReviewAssignmentsForRound(
@@ -244,6 +244,7 @@ export const useReviewerManagerStore = defineComponentStore(
244244
* Extender
245245
*/
246246
extender,
247+
props,
247248
};
248249
},
249250
);

src/managers/UserAccessManager/UserAccessManagerStore.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ export const useUserAccessManagerStore = defineComponentStore(
132132

133133
/**refs */
134134
searchPhrase,
135+
136+
// Extensibility
137+
extender,
135138
};
136139
},
137140
);

src/pages/dashboard/dashboardPageStore.js

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,16 @@ export const DashboardPageTypes = {
4646

4747
export const useDashboardPageStore = defineComponentStore(
4848
'dashboard',
49-
(pageInitConfig) => {
49+
(props) => {
5050
const appStore = useAppStore();
51-
const extender = useExtender({context: {props: pageInitConfig}});
51+
const extender = useExtender();
5252

53-
const dashboardPage = pageInitConfig.dashboardPage;
53+
const dashboardPage = props.dashboardPage;
5454

5555
/**
5656
* Minimal reviews count feature
5757
*/
58-
const contextMinReviewsPerSubmission =
59-
pageInitConfig.contextMinReviewsPerSubmission;
58+
const contextMinReviewsPerSubmission = props.contextMinReviewsPerSubmission;
6059

6160
/**
6261
* ModalStore
@@ -96,7 +95,7 @@ export const useDashboardPageStore = defineComponentStore(
9695
/**
9796
* Views
9897
*/
99-
const views = ref(pageInitConfig.views);
98+
const views = ref(props.views);
10099
const currentViewId = computed(() => {
101100
// does it exist
102101
const view = views.value.find(
@@ -164,7 +163,7 @@ export const useDashboardPageStore = defineComponentStore(
164163
/**
165164
* Filters form
166165
*/
167-
const filtersForm = ref(pageInitConfig.filtersForm);
166+
const filtersForm = ref(props.filtersForm);
168167

169168
const {
170169
filtersFormList,
@@ -227,7 +226,7 @@ export const useDashboardPageStore = defineComponentStore(
227226
function setCurrentPage(_currentPage) {
228227
currentPage.value = _currentPage;
229228
}
230-
const countPerPage = ref(pageInitConfig.countPerPage);
229+
const countPerPage = ref(props.countPerPage);
231230
const {apiUrl} = useUrl('_submissions');
232231

233232
const submissionsUrl = computed(() => {
@@ -283,9 +282,8 @@ export const useDashboardPageStore = defineComponentStore(
283282
// already trigger by SideNav to get initial values for all dashboards
284283
fetchSubmissions(false);
285284

286-
const reviewerManagerActions = useReviewerManagerActions(pageInitConfig);
287-
const participantManagerActions =
288-
useParticipantManagerActions(pageInitConfig);
285+
const reviewerManagerActions = useReviewerManagerActions(props);
286+
const participantManagerActions = useParticipantManagerActions(props);
289287
const fileManagerActions = useFileManagerActions();
290288
const {getCurrentPublication} = useSubmission();
291289

@@ -430,7 +428,7 @@ export const useDashboardPageStore = defineComponentStore(
430428
'WorkflowPage',
431429
{
432430
submissionId,
433-
pageInitConfig,
431+
pageInitConfig: props,
434432
},
435433
{
436434
onClose: async () => {
@@ -612,10 +610,11 @@ export const useDashboardPageStore = defineComponentStore(
612610
contextMinReviewsPerSubmission,
613611

614612
// Expose component forms, so managers and other dashboard/workflow component can access them
615-
componentForms: pageInitConfig.componentForms,
613+
componentForms: props.componentForms,
616614

617615
// Extender
618616
extender,
617+
props,
619618
};
620619
},
621620
);

src/pages/workflow/workflowStore.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export const useWorkflowStore = defineComponentStore(
3131
const dashboardPage = props.pageInitConfig.dashboardPage;
3232
const contextMinReviewsPerSubmission =
3333
props.pageInitConfig.contextMinReviewsPerSubmission;
34-
const extender = useExtender({context: {props}});
34+
const extender = useExtender();
3535
/**
3636
* Action to close the workflow from inside
3737
* */
@@ -250,6 +250,7 @@ export const useWorkflowStore = defineComponentStore(
250250

251251
Components,
252252
extender,
253+
props,
253254
};
254255
return store;
255256
},

0 commit comments

Comments
 (0)