Skip to content

Commit 05d18d8

Browse files
pkp/pkp-lib#9527 Move global dialog to decorators
1 parent 68fe0df commit 05d18d8

File tree

10 files changed

+34
-91
lines changed

10 files changed

+34
-91
lines changed

.storybook/preview.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ import Tab from '@/components/Tabs/Tab.vue';
2020
import Tabs from '@/components/Tabs/Tabs.vue';
2121
import FloatingVue from 'floating-vue';
2222

23+
import PkpDialog from '@/components/Modal/Dialog.vue';
24+
import {useDialogStore} from '@/stores/dialogStore';
25+
2326
import VueScrollTo from 'vue-scrollto';
2427

2528
import '../src/styles/_import.less';
@@ -94,7 +97,23 @@ const preview = {
9497
decorators: [
9598
(story) => ({
9699
components: {story},
97-
template: '<div style="margin: 3em;"><story /></div>',
100+
template: '<div style="margin: 10px;"><story /></div>',
101+
}),
102+
/** Globally Available Dialog */
103+
(story) => ({
104+
setup() {
105+
const dialogStore = useDialogStore();
106+
return {dialogStore};
107+
},
108+
components: {story, PkpDialog},
109+
template: `<div>
110+
<PkpDialog
111+
:open="dialogStore.dialogOpened"
112+
v-bind="dialogStore.dialogProps"
113+
@close="dialogStore.closeDialog"
114+
></PkpDialog>
115+
<story />
116+
</div>`,
98117
}),
99118
],
100119
parameters: {

src/components/ActionPanel/ActionPanel.stories.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import ActionPanel from './ActionPanel.vue';
2-
import PkpDialog from '@/components/Modal/Dialog.vue';
32
import './ActionPanelStories.less';
43
import {useTranslation} from '@/composables/useTranslation';
54
import {useDialogStore} from '@/stores/dialogStore';
@@ -10,7 +9,7 @@ export default {
109

1110
export const Default = {
1211
render: (args) => ({
13-
components: {ActionPanel, PkpDialog},
12+
components: {ActionPanel},
1413
setup() {
1514
const {t} = useTranslation();
1615
const dialogStore = useDialogStore();
@@ -40,16 +39,10 @@ export const Default = {
4039
}
4140
return {
4241
args,
43-
dialogStore,
4442
openDeleteDialog,
4543
};
4644
},
4745
template: `
48-
<PkpDialog
49-
:open="dialogStore.dialogOpened"
50-
v-bind="dialogStore.dialogProps"
51-
@close="dialogStore.closeDialog"
52-
></PkpDialog>
5346
5447
<div class="previewActionPanel">
5548
<action-panel>

src/components/Composer/Composer.stories.js

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import Composer from './Composer.vue';
44
import fileAttachers from '@/docs/data/fileAttachers';
55
import insertContent from '@/docs/data/insertContent';
66
import emailTemplate from '@/docs/data/emailTemplate';
7-
import PkpDialog from '@/components/Modal/Dialog.vue';
8-
import {useDialogStore} from '@/stores/dialogStore';
97

108
export default {
119
title: 'Components/Composer',
@@ -14,10 +12,8 @@ export default {
1412

1513
export const Default = {
1614
render: (args) => ({
17-
components: {Composer, PkpDialog},
15+
components: {Composer},
1816
setup() {
19-
const dialogStore = useDialogStore();
20-
2117
const emailTemplates = [emailTemplate];
2218
emailTemplates.push({
2319
...emailTemplate,
@@ -106,14 +102,9 @@ export const Default = {
106102
composerState.value[key] = data[key];
107103
});
108104
}
109-
return {args, composerState, composerChanged, dialogStore};
105+
return {args, composerState, composerChanged};
110106
},
111107
template: `
112-
<PkpDialog
113-
:open="dialogStore.dialogOpened"
114-
v-bind="dialogStore.dialogProps"
115-
@close="dialogStore.closeDialog"
116-
></PkpDialog>
117108
118109
<Composer
119110
v-bind="args"

src/components/Form/fields/FieldShowEnsuringLink.stories.js

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
import FieldShowEnsuringLink from './FieldShowEnsuringLink.vue';
22
import FieldBaseMock from '../mocks/field-base';
33
import FieldShowEnsuringLinkMock from '../mocks/field-show-ensuring-link';
4-
import {useDialogStore} from '@/stores/dialogStore';
5-
import PkpDialog from '@/components/Modal/Dialog.vue';
64

75
export default {
86
title: 'Forms/FieldShowEnsuringLink',
97
component: FieldShowEnsuringLink,
108
render: (args) => ({
11-
components: {FieldShowEnsuringLink, PkpDialog},
9+
components: {FieldShowEnsuringLink},
1210
setup() {
13-
const dialogStore = useDialogStore();
14-
1511
function change(name, prop, newValue, localeKey) {
1612
if (localeKey) {
1713
args[prop][localeKey] = newValue;
@@ -20,15 +16,9 @@ export default {
2016
}
2117
}
2218

23-
return {args, change, dialogStore};
19+
return {args, change};
2420
},
2521
template: `
26-
<PkpDialog
27-
:open="dialogStore.dialogOpened"
28-
v-bind="dialogStore.dialogProps"
29-
@close="dialogStore.closeDialog"
30-
></PkpDialog>
31-
3222
<FieldShowEnsuringLink v-bind="args" @change="change" />
3323
`,
3424
}),

src/components/ListPanel/announcements/AnnouncementsListPanel.stories.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import AnnouncementsListPanel from './AnnouncementsListPanel.vue';
22

33
import AnnouncementMock from '@/mocks/announcement';
44
import FormAnnouncementMock from '@/components/Form/mocks/form-announcement';
5-
import PkpDialog from '@/components/Modal/Dialog.vue';
65
import {useDialogStore} from '@/stores/dialogStore';
76

87
export default {
@@ -71,18 +70,13 @@ const announcements = [
7170

7271
export const Base = {
7372
render: (args) => ({
74-
components: {AnnouncementsListPanel, PkpDialog},
73+
components: {AnnouncementsListPanel},
7574
setup() {
7675
const dialogStore = useDialogStore();
7776

7877
return {args, dialogStore};
7978
},
8079
template: `
81-
<PkpDialog
82-
:open="dialogStore.dialogOpened"
83-
v-bind="dialogStore.dialogProps"
84-
@close="dialogStore.closeDialog"
85-
></PkpDialog>
8680
<AnnouncementsListPanel
8781
v-bind="args"
8882
/>

src/components/ListPanel/highlights/HighlightsListPanel.stories.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import HighlightsListPanel from './HighlightsListPanel.vue';
22
import HighlightMock from '@/mocks/highlight';
33
import FormHighlightMock from '@/components/Form/mocks/form-highlight';
44
import PkpDialog from '@/components/Modal/Dialog.vue';
5-
import {useDialogStore} from '@/stores/dialogStore';
65

76
export default {
87
title: 'ListPanel/HighlightsListPanel',
@@ -69,16 +68,9 @@ export const Base = {
6968
});
7069
}
7170

72-
const dialogStore = useDialogStore();
73-
74-
return {args, setData, dialogStore};
71+
return {args, setData};
7572
},
7673
template: `
77-
<PkpDialog
78-
:open="dialogStore.dialogOpened"
79-
v-bind="dialogStore.dialogProps"
80-
@close="dialogStore.closeDialog"
81-
></PkpDialog>
8274
<HighlightsListPanel
8375
v-bind="args"
8476
@set="setData"

src/components/ListPanel/institutions/InstitutionsListPanel.stories.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import InstitutionsListPanel from './InstitutionsListPanel.vue';
22

33
import PkpDialog from '@/components/Modal/Dialog.vue';
4-
import {useDialogStore} from '@/stores/dialogStore';
54
import FormInstitutionMock from '@/components/Form/mocks/form-institution';
65

76
export default {
@@ -58,16 +57,9 @@ export const Base = {
5857
});
5958
}
6059

61-
const dialogStore = useDialogStore();
62-
63-
return {args, setData, dialogStore};
60+
return {args, setData};
6461
},
6562
template: `
66-
<PkpDialog
67-
:open="dialogStore.dialogOpened"
68-
v-bind="dialogStore.dialogProps"
69-
@close="dialogStore.closeDialog"
70-
></PkpDialog>
7163
<InstitutionsListPanel
7264
v-bind="args"
7365
/>

src/components/ListPanel/submissionFiles/SubmissionFilesListPanel.stories.js

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
import SubmissionFilesListPanel from './SubmissionFilesListPanel.vue';
22

3-
import PkpDialog from '@/components/Modal/Dialog.vue';
4-
import {useDialogStore} from '@/stores/dialogStore';
5-
63
import FormSubmissionFileMock from '@/components/Form/mocks/form-submission-file';
74
import DropzoneOptionsMock from '@/mocks/dropzoneOptions';
85
import SubmissionFilesMock from '@/mocks/submissionFiles';
@@ -19,10 +16,8 @@ yesterday.setDate(new Date().getDate() - 1);
1916

2017
export const Base = {
2118
render: (args) => ({
22-
components: {SubmissionFilesListPanel, PkpDialog},
19+
components: {SubmissionFilesListPanel},
2320
setup() {
24-
const dialogStore = useDialogStore();
25-
2621
function get(key) {
2722
return args[key] ? args[key] : {};
2823
}
@@ -35,14 +30,9 @@ export const Base = {
3530
args[key] = component;
3631
}
3732

38-
return {args, set, dialogStore};
33+
return {args, set};
3934
},
4035
template: `
41-
<PkpDialog
42-
:open="dialogStore.dialogOpened"
43-
v-bind="dialogStore.dialogProps"
44-
@close="dialogStore.closeDialog"
45-
></PkpDialog>
4636
<SubmissionFilesListPanel
4737
v-bind="args"
4838
@set="set"

src/components/ListPanel/submissions/SubmissionsListPanel.stories.js

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import SubmissionsListPanel from './SubmissionsListPanel.vue';
2-
import PkpDialog from '@/components/Modal/Dialog.vue';
3-
import {useDialogStore} from '@/stores/dialogStore';
42

53
import SubmissionsMock from '@/mocks/submissions';
64
import FieldBaseMock from '@/components/Form/mocks/field-base';
@@ -13,7 +11,7 @@ export default {
1311

1412
export const Base = {
1513
render: (args) => ({
16-
components: {SubmissionsListPanel, PkpDialog},
14+
components: {SubmissionsListPanel},
1715
setup() {
1816
function setData(id, newData) {
1917
Object.keys(newData).forEach((key) => {
@@ -23,8 +21,6 @@ export const Base = {
2321
});
2422
}
2523

26-
const dialogStore = useDialogStore();
27-
2824
/**
2925
* Add required locale keys
3026
*/
@@ -59,14 +55,9 @@ export const Base = {
5955
'Production galleys created';
6056
pkp.localeKeys['submission.list.viewSubmission'] = 'View Submission';
6157

62-
return {args, setData, dialogStore};
58+
return {args, setData};
6359
},
6460
template: `
65-
<PkpDialog
66-
:open="dialogStore.dialogOpened"
67-
v-bind="dialogStore.dialogProps"
68-
@close="dialogStore.closeDialog"
69-
></PkpDialog>
7061
<SubmissionsListPanel
7162
v-bind="args"
7263
/>

src/components/ListPanel/users/SelectReviewerListPanel.stories.js

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import SelectReviewerListPanel from './SelectReviewerListPanel.vue';
22

3-
import PkpDialog from '@/components/Modal/Dialog.vue';
4-
import {useDialogStore} from '@/stores/dialogStore';
53
import ReviewerMock from '@/mocks/reviewer';
64

75
export default {
@@ -101,7 +99,7 @@ const items = [
10199

102100
export const Base = {
103101
render: (args) => ({
104-
components: {SelectReviewerListPanel, PkpDialog},
102+
components: {SelectReviewerListPanel},
105103
setup() {
106104
function setData(id, newData) {
107105
Object.keys(newData).forEach((key) => {
@@ -111,16 +109,9 @@ export const Base = {
111109
});
112110
}
113111

114-
const dialogStore = useDialogStore();
115-
116-
return {args, setData, dialogStore};
112+
return {args, setData};
117113
},
118114
template: `
119-
<PkpDialog
120-
:open="dialogStore.dialogOpened"
121-
v-bind="dialogStore.dialogProps"
122-
@close="dialogStore.closeDialog"
123-
></PkpDialog>
124115
<SelectReviewerListPanel
125116
v-bind="args"
126117
/>

0 commit comments

Comments
 (0)