@plusscommunities/pluss-feature-builder-web-d 1.0.2-beta.7 → 1.0.2-beta.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,12 @@
1
1
  import {
2
- selectFormTitle,
3
- selectFormIcon,
4
- selectFormDisplayName,
5
- selectFormLayout,
6
- selectFormFields,
2
+ selectFormTitle,
3
+ selectFormIcon,
4
+ selectFormDisplayName,
5
+ selectFormLayout,
6
+ selectFormFields,
7
7
  } from "../selectors/featureBuilderSelectors";
8
8
 
9
- import { clearFormSubmissionState } from "./formActions"
9
+ import { clearFormSubmissionState } from "./formActions";
10
10
 
11
11
  import { values } from "../values.config";
12
12
 
@@ -21,208 +21,208 @@ export const VALIDATE_AND_UPDATE_STEP = `${REDUCER_PREFIX}_VALIDATE_AND_UPDATE_S
21
21
 
22
22
  // Mode setters
23
23
  export const setWizardMode = (mode) => ({
24
- type: SET_WIZARD_MODE,
25
- payload: mode,
24
+ type: SET_WIZARD_MODE,
25
+ payload: mode,
26
26
  });
27
27
 
28
28
  // Navigation actions
29
29
  export const setNavigationState = (navigationState) => ({
30
- type: SET_NAVIGATION_STATE,
31
- payload: navigationState,
30
+ type: SET_NAVIGATION_STATE,
31
+ payload: navigationState,
32
32
  });
33
33
 
34
34
  export const setCurrentStep = (step, previousStep = null) => ({
35
- type: SET_NAVIGATION_STATE,
36
- payload: {
37
- currentStep: step,
38
- previousStep,
39
- canGoBack: step !== "welcome",
40
- canGoForward: true,
41
- },
35
+ type: SET_NAVIGATION_STATE,
36
+ payload: {
37
+ currentStep: step,
38
+ previousStep,
39
+ canGoBack: step !== "welcome",
40
+ canGoForward: true,
41
+ },
42
42
  });
43
43
 
44
44
  export const goToStep = (step) => (dispatch, getState) => {
45
- const state = getState()[values.reducerKey];
46
- const currentStep = state?.wizard?.navigation?.currentStep;
45
+ const state = getState()[values.reducerKey];
46
+ const currentStep = state?.wizard?.navigation?.currentStep;
47
47
 
48
- // Clear form submission state when changing steps
49
- dispatch(clearFormSubmissionState());
48
+ // Clear form submission state when changing steps
49
+ dispatch(clearFormSubmissionState());
50
50
 
51
- dispatch(setCurrentStep(step, currentStep));
51
+ dispatch(setCurrentStep(step, currentStep));
52
52
  };
53
53
 
54
54
  export const updateStepValidation = (step, isValid, errors = {}) => ({
55
- type: UPDATE_STEP_VALIDATION,
56
- payload: {
57
- step,
58
- isValid,
59
- errors,
60
- },
55
+ type: UPDATE_STEP_VALIDATION,
56
+ payload: {
57
+ step,
58
+ isValid,
59
+ errors,
60
+ },
61
61
  });
62
62
 
63
63
  export const validateAndUpdateStep = (step) => (dispatch, getState) => {
64
- // Use existing selectors to get form data
65
- const state = getState();
66
- const title = selectFormTitle(state);
67
- const icon = selectFormIcon(state);
68
- const displayName = selectFormDisplayName(state);
69
- const layout = selectFormLayout(state);
70
- const fields = selectFormFields(state);
64
+ // Use existing selectors to get form data
65
+ const state = getState();
66
+ const title = selectFormTitle(state);
67
+ const icon = selectFormIcon(state);
68
+ const displayName = selectFormDisplayName(state);
69
+ const layout = selectFormLayout(state);
70
+ const fields = selectFormFields(state);
71
71
 
72
- const form = { title, icon, displayName, layout, fields };
72
+ const form = { title, icon, displayName, layout, fields };
73
73
 
74
- const { isValid, errors } = getFormValidation(form, step);
74
+ const { isValid, errors } = getFormValidation(form, step);
75
75
 
76
- dispatch(updateStepValidation(step, isValid, errors));
76
+ dispatch(updateStepValidation(step, isValid, errors));
77
77
 
78
- // If valid, mark as complete
79
- if (isValid) {
80
- dispatch({
81
- type: MARK_STEP_COMPLETE,
82
- payload: step,
83
- });
84
- }
78
+ // If valid, mark as complete
79
+ if (isValid) {
80
+ dispatch({
81
+ type: MARK_STEP_COMPLETE,
82
+ payload: step,
83
+ });
84
+ }
85
85
 
86
- return { isValid, errors };
86
+ return { isValid, errors };
87
87
  };
88
88
 
89
89
  // Step completion
90
90
  export const markStepComplete = (step) => ({
91
- type: MARK_STEP_COMPLETE,
92
- payload: step,
91
+ type: MARK_STEP_COMPLETE,
92
+ payload: step,
93
93
  });
94
94
 
95
95
  // Reset wizard state
96
96
  export const resetWizardState = () => ({
97
- type: RESET_WIZARD_STATE,
97
+ type: RESET_WIZARD_STATE,
98
98
  });
99
99
 
100
100
  const getFormValidation = (form, step) => {
101
- // Return validation results for undefined form (prevent crashes)
102
- if (!form) {
103
- switch (step) {
104
- case "overview":
105
- return {
106
- isValid: false,
107
- errors: {
108
- title: "Title is required",
109
- displayName: "Display name is required",
110
- icon: "Icon is required",
111
- },
112
- };
113
- case "fields":
114
- return {
115
- isValid: false,
116
- errors: {
117
- missingTitle: "Title field is required",
118
- missingImage: "Feature image field is required",
119
- fieldLabels: "Some fields are missing labels",
120
- },
121
- };
122
- case "layout":
123
- return {
124
- isValid: false,
125
- errors: {
126
- layoutType: "Layout type is required",
127
- },
128
- };
129
- default:
130
- return { isValid: false, errors: {} };
131
- }
132
- }
133
-
134
- switch (step) {
135
- case "overview": {
136
- const hasTitle = form.title?.trim().length > 0;
137
- const hasDisplayName = form.displayName?.trim().length > 0;
138
- const hasIcon = form.icon?.length > 0;
139
-
140
- return {
141
- isValid: hasTitle && hasDisplayName && hasIcon,
142
- errors: {
143
- title: !hasTitle ? "Title is required" : null,
144
- displayName: !hasDisplayName ? "Display name is required" : null,
145
- icon: !hasIcon ? "Icon is required" : null,
146
- },
147
- };
148
- }
149
- case "fields": {
150
- const hasTitleField = form.fields?.some(
151
- (field) => field.id === "mandatory-title",
152
- );
153
- const hasImageField = form.fields?.some(
154
- (field) => field.id === "mandatory-feature-image",
155
- );
156
-
157
- // Check each field for missing labels and create field-specific errors
158
- const fieldErrors = {};
159
- let allFieldsHaveLabels = true;
160
-
161
- if (form.fields) {
162
- form.fields.forEach((field) => {
163
- if (
164
- (field.type === "text" ||
165
- field.type === "description" ||
166
- field.type === "title" ||
167
- field.type === "image" ||
168
- field.type === "gallery" ||
169
- field.type === "feature-image" ||
170
- field.type === "file" ||
171
- field.type === "cta") &&
172
- field.values
173
- ) {
174
- if (!field.values.label || field.values.label.trim().length === 0) {
175
- fieldErrors[field.id] = "Field label is required";
176
- allFieldsHaveLabels = false;
177
- }
178
- }
179
- });
180
- }
181
-
182
- return {
183
- isValid: hasTitleField && hasImageField && allFieldsHaveLabels,
184
- errors: {
185
- missingTitle: !hasTitleField ? "Title field is required" : null,
186
- missingImage: !hasImageField
187
- ? "Feature image field is required"
188
- : null,
189
- ...fieldErrors,
190
- },
191
- };
192
- }
193
- case "layout": {
194
- const hasLayoutType = form.layout?.type?.length > 0;
195
- return {
196
- isValid: hasLayoutType,
197
- errors: {
198
- layoutType: !hasLayoutType ? "Layout type is required" : null,
199
- },
200
- };
201
- }
202
- default:
203
- return { isValid: true, errors: {} };
204
- }
101
+ // Return validation results for undefined form (prevent crashes)
102
+ if (!form) {
103
+ switch (step) {
104
+ case "overview":
105
+ return {
106
+ isValid: false,
107
+ errors: {
108
+ title: "Title is required",
109
+ displayName: "Display name is required",
110
+ icon: "Icon is required",
111
+ },
112
+ };
113
+ case "fields":
114
+ return {
115
+ isValid: false,
116
+ errors: {
117
+ missingTitle: "Title field is required",
118
+ missingImage: "Feature image field is required",
119
+ fieldLabels: "Some fields are missing labels",
120
+ },
121
+ };
122
+ case "layout":
123
+ return {
124
+ isValid: false,
125
+ errors: {
126
+ layoutType: "Layout type is required",
127
+ },
128
+ };
129
+ default:
130
+ return { isValid: false, errors: {} };
131
+ }
132
+ }
133
+
134
+ switch (step) {
135
+ case "overview": {
136
+ const hasTitle = form.title?.trim().length > 0;
137
+ const hasDisplayName = form.displayName?.trim().length > 0;
138
+ const hasIcon = form.icon?.length > 0;
139
+
140
+ return {
141
+ isValid: hasTitle && hasDisplayName && hasIcon,
142
+ errors: {
143
+ title: !hasTitle ? "Title is required" : null,
144
+ displayName: !hasDisplayName ? "Display name is required" : null,
145
+ icon: !hasIcon ? "Icon is required" : null,
146
+ },
147
+ };
148
+ }
149
+ case "fields": {
150
+ const hasTitleField = form.fields?.some(
151
+ (field) => field.id === "mandatory-title",
152
+ );
153
+ const hasImageField = form.fields?.some(
154
+ (field) => field.id === "mandatory-feature-image",
155
+ );
156
+
157
+ // Check each field for missing labels and create field-specific errors
158
+ const fieldErrors = {};
159
+ let allFieldsHaveLabels = true;
160
+
161
+ if (form.fields) {
162
+ form.fields.forEach((field) => {
163
+ if (
164
+ (field.type === "text" ||
165
+ field.type === "description" ||
166
+ field.type === "title" ||
167
+ field.type === "image" ||
168
+ field.type === "gallery" ||
169
+ field.type === "feature-image" ||
170
+ field.type === "file" ||
171
+ field.type === "cta") &&
172
+ field.values
173
+ ) {
174
+ if (!field.values.label || field.values.label.trim().length === 0) {
175
+ fieldErrors[field.id] = "Field label is required";
176
+ allFieldsHaveLabels = false;
177
+ }
178
+ }
179
+ });
180
+ }
181
+
182
+ return {
183
+ isValid: hasTitleField && hasImageField && allFieldsHaveLabels,
184
+ errors: {
185
+ missingTitle: !hasTitleField ? "Title field is required" : null,
186
+ missingImage: !hasImageField
187
+ ? "Feature image field is required"
188
+ : null,
189
+ ...fieldErrors,
190
+ },
191
+ };
192
+ }
193
+ case "layout": {
194
+ const hasLayoutType = form.layout?.type?.length > 0;
195
+ return {
196
+ isValid: hasLayoutType,
197
+ errors: {
198
+ layoutType: !hasLayoutType ? "Layout type is required" : null,
199
+ },
200
+ };
201
+ }
202
+ default:
203
+ return { isValid: true, errors: {} };
204
+ }
205
205
  };
206
206
 
207
207
  export const setWizardModeAndSave = (mode) => (dispatch) => {
208
- dispatch(setWizardMode(mode));
208
+ dispatch(setWizardMode(mode));
209
209
  };
210
210
 
211
211
  export const setCurrentStepAndSave =
212
- (step, previousStep = null) =>
213
- (dispatch) => {
214
- dispatch(setCurrentStep(step, previousStep));
215
- };
212
+ (step, previousStep = null) =>
213
+ (dispatch) => {
214
+ dispatch(setCurrentStep(step, previousStep));
215
+ };
216
216
 
217
217
  export const updateStepValidationAndSave =
218
- (step, isValid, errors = {}) =>
219
- (dispatch) => {
220
- dispatch(updateStepValidation(step, isValid, errors));
221
- if (isValid) {
222
- dispatch(markStepComplete(step));
223
- }
224
- };
218
+ (step, isValid, errors = {}) =>
219
+ (dispatch) => {
220
+ dispatch(updateStepValidation(step, isValid, errors));
221
+ if (isValid) {
222
+ dispatch(markStepComplete(step));
223
+ }
224
+ };
225
225
 
226
226
  export const markStepCompleteAndSave = (step) => (dispatch) => {
227
- dispatch(markStepComplete(step));
227
+ dispatch(markStepComplete(step));
228
228
  };
@@ -241,10 +241,10 @@ export const BaseFieldConfig = (props) => {
241
241
  {setMaxImages && (
242
242
  <GenericInput
243
243
  type="number"
244
- value={maxImages || 10}
245
- placeholder="10"
244
+ value={maxImages || 16}
245
+ placeholder="16"
246
246
  label="Maximum Images"
247
- onChange={(e) => setMaxImages(parseInt(e.target.value) || 10)}
247
+ onChange={(e) => setMaxImages(parseInt(e.target.value) || 16)}
248
248
  className={styles.fieldSpacing}
249
249
  alwaysShowLabel
250
250
  />
@@ -4,12 +4,7 @@ const { Components } = PlussCore;
4
4
  const { Popup } = Components;
5
5
  import styles from "./FeatureBuilderSuccessPopup.module.css";
6
6
 
7
- const FeatureBuilderSuccessPopup = ({
8
- isOpen,
9
- onClose,
10
- featureName,
11
- displayName,
12
- }) => {
7
+ const FeatureBuilderSuccessPopup = ({ isOpen, onClose, featureName }) => {
13
8
  if (!isOpen) {
14
9
  return null;
15
10
  }
@@ -23,14 +18,14 @@ const FeatureBuilderSuccessPopup = ({
23
18
  },
24
19
  ];
25
20
 
21
+ const capitalisedName =
22
+ featureName && featureName[0].toUpperCase() + featureName.slice(1);
23
+
26
24
  return (
27
25
  <Popup
28
- title={`${featureName} Created`}
26
+ title={`${capitalisedName} Created`}
29
27
  subtitle={
30
- <>
31
- <span>{featureName}</span> is now saved and available for your
32
- communities!
33
- </>
28
+ <>{capitalisedName} is now saved and available for your communities!</>
34
29
  }
35
30
  onClose={onClose}
36
31
  buttons={buttons}
@@ -40,12 +35,11 @@ const FeatureBuilderSuccessPopup = ({
40
35
  >
41
36
  <div className={styles.successContent}>
42
37
  <div className={styles.successMessage}>
43
- To activate this feature, please add it to your sites using the
44
- Feature Picker.
38
+ {capitalisedName} is saved and ready to go. To use it, add it to your
39
+ site using the <b>Feature Picker.</b>
45
40
  </div>
46
41
  <div className={styles.successMessage}>
47
- Team members with the right permissions can start creating content for
48
- the communities that have installed the feature.
42
+ Once added, your team can start creating content for the feature.
49
43
  </div>
50
44
  </div>
51
45
  </Popup>
@@ -1,7 +1,6 @@
1
1
  .successContent {
2
2
  display: flex;
3
3
  flex-direction: column;
4
- align-items: center;
5
4
  gap: 20px;
6
5
  padding: 20px 0;
7
6
  }
@@ -30,11 +29,10 @@
30
29
  }
31
30
 
32
31
  .successMessage {
33
- text-align: center;
34
- color: #666;
35
32
  font-size: 16px;
36
33
  line-height: 1.5;
37
34
  max-width: 400px;
35
+ color: #181c4a;
38
36
  }
39
37
 
40
38
  .featureName {