@gogitcms/design-system 0.16.0-next.6 → 0.16.0-next.7
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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gogitcms/design-system",
|
|
3
|
-
"version": "0.16.0-next.
|
|
3
|
+
"version": "0.16.0-next.7",
|
|
4
4
|
"main": "src/index.ts",
|
|
5
5
|
"types": "src/index.ts",
|
|
6
6
|
"// exports": "The root entry is the react-native source the SPAs, desktop app and mobile app consume. ./web is the plain-DOM build for server-rendered surfaces (the Astro docs site) that don't run react-native-web, and ./css ships the tokens as custom properties. The trailing wildcard keeps deep paths resolvable — plugin bundling and the Vite aliases reach into src/ directly.",
|
|
@@ -146,3 +146,51 @@ test("failure surfaces the error and a dismiss button", () => {
|
|
|
146
146
|
expect(screen.getByTestId("merge-error")).toHaveTextContent("main moved while merging");
|
|
147
147
|
expect(screen.getByTestId("apply-dismiss")).toBeInTheDocument();
|
|
148
148
|
});
|
|
149
|
+
|
|
150
|
+
test("with a review reason the confirmation step promises a review, not a merge commit", () => {
|
|
151
|
+
render(
|
|
152
|
+
wrap(
|
|
153
|
+
<ApplyChangesModal
|
|
154
|
+
{...branches}
|
|
155
|
+
reviewReason="main is protected, so this opens a change request for review."
|
|
156
|
+
onConfirm={() => {}}
|
|
157
|
+
onClose={() => {}}
|
|
158
|
+
/>,
|
|
159
|
+
),
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
const confirm = screen.getByTestId("apply-confirm");
|
|
163
|
+
// The run will stop before the push, so the copy must not describe one.
|
|
164
|
+
expect(confirm).not.toHaveTextContent("pushes a merge commit");
|
|
165
|
+
expect(confirm).not.toHaveTextContent("is then deleted");
|
|
166
|
+
expect(screen.getByTestId("apply-confirm-review")).toHaveTextContent("opens a pull request for review");
|
|
167
|
+
expect(confirm).toHaveTextContent("Nothing is pushed to origin/main until it is approved");
|
|
168
|
+
expect(confirm).toHaveTextContent("main is protected");
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
test("needs_review without code conflicts explains the review instead of listing files", () => {
|
|
172
|
+
const onCreateChangeRequest = jest.fn();
|
|
173
|
+
render(
|
|
174
|
+
wrap(
|
|
175
|
+
<ApplyChangesModal
|
|
176
|
+
{...branches}
|
|
177
|
+
reviewReason="main is protected, so this opens a change request for review."
|
|
178
|
+
progress={{ ...base, status: "needs_review", step: "merging", escalationFiles: [] }}
|
|
179
|
+
onCreateChangeRequest={onCreateChangeRequest}
|
|
180
|
+
onClose={() => {}}
|
|
181
|
+
/>,
|
|
182
|
+
),
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
const panel = screen.getByTestId("merge-needs-review");
|
|
186
|
+
// No conflict: it is not called one, and no empty file list is drawn.
|
|
187
|
+
expect(panel).not.toHaveTextContent("Code conflicts need a developer");
|
|
188
|
+
expect(panel).toHaveTextContent("This merge needs a review");
|
|
189
|
+
expect(screen.getByTestId("merge-needs-review-reason")).toHaveTextContent("nothing was pushed to main");
|
|
190
|
+
expect(screen.getByTestId("merge-needs-review-reason")).toHaveTextContent("main is protected");
|
|
191
|
+
|
|
192
|
+
// The same escalation flow: an explanation, then a change request.
|
|
193
|
+
fireEvent.change(screen.getByTestId("change-request-explanation"), { target: { value: "Spring copy" } });
|
|
194
|
+
fireEvent.click(screen.getByTestId("create-change-request-submit"));
|
|
195
|
+
expect(onCreateChangeRequest).toHaveBeenCalledWith("Spring copy");
|
|
196
|
+
});
|
|
@@ -35,6 +35,15 @@ export type ApplyChangesModalProps = {
|
|
|
35
35
|
progress?: MergeProgress;
|
|
36
36
|
/** A short summary of what will be merged, shown on the confirmation step. */
|
|
37
37
|
summary?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Why this apply cannot push to the target directly and opens a change
|
|
40
|
+
* request instead — the target is protected, or the caller cannot publish
|
|
41
|
+
* every project on the branch. When set, the confirmation step describes the
|
|
42
|
+
* review that will happen rather than a merge commit that will not, and the
|
|
43
|
+
* needs_review panel gives this reason when there are no code conflicts to
|
|
44
|
+
* list. Absent for an ordinary direct merge.
|
|
45
|
+
*/
|
|
46
|
+
reviewReason?: string;
|
|
38
47
|
/** Number of unresolved conflicts, shown on the conflicted state. */
|
|
39
48
|
conflictCount?: number;
|
|
40
49
|
/**
|
|
@@ -99,7 +108,7 @@ function StepRow({ label, state }: { label: string; state: "done" | "active" | "
|
|
|
99
108
|
* (spinner → green check), then shows a success panel with the commit + stats,
|
|
100
109
|
* or an error. Read-only: it reflects a run the host drives via a subscription.
|
|
101
110
|
*/
|
|
102
|
-
export function ApplyChangesModal({ sourceBranch, targetBranch, progress, summary, conflictCount, changeRequestOpen, changeRequestUrl, creatingChangeRequest, onConfirm, onReviewConflicts, onCreateChangeRequest, onViewChangeRequest, onClose, onDone }: ApplyChangesModalProps) {
|
|
111
|
+
export function ApplyChangesModal({ sourceBranch, targetBranch, progress, summary, reviewReason, conflictCount, changeRequestOpen, changeRequestUrl, creatingChangeRequest, onConfirm, onReviewConflicts, onCreateChangeRequest, onViewChangeRequest, onClose, onDone }: ApplyChangesModalProps) {
|
|
103
112
|
const t = useTheme();
|
|
104
113
|
const done = onDone ?? onClose;
|
|
105
114
|
const [explanation, setExplanation] = useState("");
|
|
@@ -121,6 +130,13 @@ export function ApplyChangesModal({ sourceBranch, targetBranch, progress, summar
|
|
|
121
130
|
const status = progress?.status;
|
|
122
131
|
const conflicted = status === "conflicted";
|
|
123
132
|
const needsReview = status === "needs_review";
|
|
133
|
+
// A needs_review run either lists code files a developer must resolve, or
|
|
134
|
+
// lists nothing because the merge was clean and simply may not be pushed by
|
|
135
|
+
// this run (a protected target, or partial project access). The two need
|
|
136
|
+
// different words: the second is not a conflict and naming it one would send
|
|
137
|
+
// the editor looking for files that are not there.
|
|
138
|
+
const escalationFiles = progress?.escalationFiles ?? [];
|
|
139
|
+
const codeConflicts = escalationFiles.length > 0;
|
|
124
140
|
const terminal = status === "succeeded" || status === "failed" || conflicted || needsReview;
|
|
125
141
|
const current = progress ? stepOrder[progress.step] : 0;
|
|
126
142
|
|
|
@@ -201,30 +217,63 @@ export function ApplyChangesModal({ sourceBranch, targetBranch, progress, summar
|
|
|
201
217
|
// Confirmation step: spell out the irreversible, outward-facing effects
|
|
202
218
|
// before anything is pushed to the remote.
|
|
203
219
|
<View testID="apply-confirm" style={{ gap: t.space(3) }}>
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
220
|
+
{reviewReason ? (
|
|
221
|
+
// The run will stop before the push, so promising a merge commit
|
|
222
|
+
// on origin here would be describing something that will not
|
|
223
|
+
// happen. Say what will: a review, and nothing on the target
|
|
224
|
+
// until it is approved.
|
|
225
|
+
<>
|
|
226
|
+
<Text variant="body" color="secondary" testID="apply-confirm-review">
|
|
227
|
+
{`This merges ${sourceBranch} into ${targetBranch} in the CMS and opens a pull request for review. Nothing is pushed to origin/${targetBranch} until it is approved.`}
|
|
228
|
+
</Text>
|
|
229
|
+
<Text variant="body" color="secondary">{reviewReason}</Text>
|
|
230
|
+
</>
|
|
231
|
+
) : (
|
|
232
|
+
<>
|
|
233
|
+
<Text variant="body" color="secondary">
|
|
234
|
+
{`This merges ${sourceBranch} into ${targetBranch}, commits the result, and pushes a merge commit to origin/${targetBranch}.`}
|
|
235
|
+
</Text>
|
|
236
|
+
<Text variant="body" color="secondary">
|
|
237
|
+
{`${sourceBranch} is then deleted. This can’t be undone.`}
|
|
238
|
+
</Text>
|
|
239
|
+
</>
|
|
240
|
+
)}
|
|
210
241
|
{summary ? <Text variant="monoSm" color="tertiary">{summary}</Text> : null}
|
|
211
242
|
</View>
|
|
212
243
|
) : needsReview ? (
|
|
213
|
-
// Content merged, but
|
|
214
|
-
//
|
|
244
|
+
// Content merged, but the run may not push it. Either code/config
|
|
245
|
+
// files conflict — a content editor can't resolve these — or the
|
|
246
|
+
// target can't take a direct push from this run. Both collect an
|
|
247
|
+
// explanation and escalate through a pull request.
|
|
215
248
|
<View testID="merge-needs-review" style={{ gap: t.space(3) }}>
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
<
|
|
226
|
-
|
|
227
|
-
|
|
249
|
+
{codeConflicts ? (
|
|
250
|
+
<>
|
|
251
|
+
<View style={{ flexDirection: "row", alignItems: "center", gap: t.space(2) }}>
|
|
252
|
+
<Icon name="gitPullRequest" size={16} color={t.color.diffDelFg} />
|
|
253
|
+
<Text variant="body" weight="medium">Code conflicts need a developer</Text>
|
|
254
|
+
</View>
|
|
255
|
+
<Text variant="body" color="secondary">
|
|
256
|
+
{`The content merged cleanly, but these files changed on both ${sourceBranch} and ${targetBranch} and need a developer to resolve:`}
|
|
257
|
+
</Text>
|
|
258
|
+
<View style={{ gap: 2, padding: t.space(2), borderRadius: t.radius.md, backgroundColor: t.color.diffDelBg }}>
|
|
259
|
+
{escalationFiles.map((f) => (
|
|
260
|
+
<Text key={f} variant="monoSm" color={t.color.diffDelFg} testID={`escalation-file-${f}`}>{f}</Text>
|
|
261
|
+
))}
|
|
262
|
+
</View>
|
|
263
|
+
</>
|
|
264
|
+
) : (
|
|
265
|
+
<>
|
|
266
|
+
<View style={{ flexDirection: "row", alignItems: "center", gap: t.space(2) }}>
|
|
267
|
+
<Icon name="gitPullRequest" size={16} color={t.color.textSecondary} />
|
|
268
|
+
<Text variant="body" weight="medium">This merge needs a review</Text>
|
|
269
|
+
</View>
|
|
270
|
+
<Text variant="body" color="secondary" testID="merge-needs-review-reason">
|
|
271
|
+
{`The content merged cleanly and nothing was pushed to ${targetBranch}. ` +
|
|
272
|
+
(reviewReason ?? `Someone with the authority to publish it has to approve it.`) +
|
|
273
|
+
` Opening a change request creates a pull request for that review.`}
|
|
274
|
+
</Text>
|
|
275
|
+
</>
|
|
276
|
+
)}
|
|
228
277
|
<Input
|
|
229
278
|
value={explanation}
|
|
230
279
|
onChangeText={setExplanation}
|
|
@@ -483,6 +483,9 @@ export type ContentBrowserProps = {
|
|
|
483
483
|
canApplyChanges?: boolean;
|
|
484
484
|
applyOpen?: boolean;
|
|
485
485
|
applySummary?: string;
|
|
486
|
+
// Why applying opens a change request instead of merging (see
|
|
487
|
+
// ApplyChangesModal.reviewReason). Absent for a direct merge.
|
|
488
|
+
applyReviewReason?: string;
|
|
486
489
|
applyProgress?: MergeProgress;
|
|
487
490
|
applyConflictCount?: number;
|
|
488
491
|
onConfirmApply?: () => void;
|
|
@@ -3767,6 +3770,7 @@ function ApplyModalOverlay(props: ContentBrowserProps) {
|
|
|
3767
3770
|
sourceBranch={props.workspace.branch}
|
|
3768
3771
|
targetBranch={props.targetBranch ?? props.defaultBranch ?? ""}
|
|
3769
3772
|
summary={props.applySummary}
|
|
3773
|
+
reviewReason={props.applyReviewReason}
|
|
3770
3774
|
progress={props.applyProgress}
|
|
3771
3775
|
conflictCount={props.applyConflictCount}
|
|
3772
3776
|
changeRequestOpen={props.changeRequestOpen}
|