Skip to content

Commit

Permalink
Merge branch 'main' into cleanup-3.20.25
Browse files Browse the repository at this point in the history
  • Loading branch information
poulch authored Jan 29, 2025
2 parents 52cd101 + 8032935 commit 4dfb213
Show file tree
Hide file tree
Showing 29 changed files with 611 additions and 150 deletions.
5 changes: 5 additions & 0 deletions .changeset/mean-points-glow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": patch
---

You can now edit note in order details. Notes in order details now show id of note, id of related note and type of note "added" or "updated"
5 changes: 5 additions & 0 deletions .changeset/new-monkeys-talk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": patch
---

You can now open datagrid list item in new tab using cmd/ctrl button
5 changes: 5 additions & 0 deletions .changeset/selfish-swans-turn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": patch
---

After creating a new collection, you should see a list of assigned channels
5 changes: 5 additions & 0 deletions .changeset/violet-doors-bathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": patch
---

Activates list items on the welcome page no longer implies that they are clickable
5 changes: 5 additions & 0 deletions .changeset/wild-poems-approve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": patch
---

Editor.js no more cause error during saving
21 changes: 21 additions & 0 deletions locale/defaultMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,9 @@
"context": "channels alphabetically title",
"string": "Channels from A to Z"
},
"/n+NRO": {
"string": "Note id"
},
"/nZy6A": {
"context": "page subtitle",
"string": "Issue refund"
Expand Down Expand Up @@ -1711,6 +1714,9 @@
"context": "order number label",
"string": "Order number"
},
"9Th87u": {
"string": "Note successfully updated"
},
"9Tl/bT": {
"context": "export items as spreadsheet",
"string": "Spreadsheet for Excel, Numbers etc."
Expand Down Expand Up @@ -6496,6 +6502,9 @@
"context": "edit tracking button",
"string": "Edit tracking"
},
"dVSBW6": {
"string": "Related note id"
},
"dVk241": {
"string": "product configurations"
},
Expand Down Expand Up @@ -6699,6 +6708,9 @@
"context": "gift card history message",
"string": "Gift card expiry date was updated"
},
"fM7xZh": {
"string": "updated"
},
"fNFEkh": {
"string": "No of Rows:"
},
Expand Down Expand Up @@ -7057,6 +7069,9 @@
"context": "docs link label",
"string": "Learn more..."
},
"hniz8Z": {
"string": "here"
},
"ho75Lr": {
"context": "status label deactivated",
"string": "Deactivated"
Expand Down Expand Up @@ -8313,6 +8328,9 @@
"context": "header",
"string": "Add Value to Authorization Field"
},
"qD1kvF": {
"string": "The timeline below shows the history of all events related to this order. Each entry represents a single event along with its content or readable description. For more information regarding order events, you can find {link}."
},
"qDfaDI": {
"string": "No app or plugin is configured to handle requested transaction action"
},
Expand Down Expand Up @@ -9367,6 +9385,9 @@
"context": "gift card settings header",
"string": "Gift Cards Settings"
},
"xJEaxW": {
"string": "added"
},
"xJQX5t": {
"string": "No staff members found"
},
Expand Down
44 changes: 21 additions & 23 deletions src/collections/views/CollectionCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,28 +63,7 @@ export const CollectionCreate: React.FC<CollectionCreateProps> = ({ params }) =>
{ closeModal, openModal },
{ formId: COLLECTION_CREATE_FORM_ID },
);
const [createCollection, createCollectionOpts] = useCreateCollectionMutation({
onCompleted: data => {
if (data.collectionCreate.errors.length === 0) {
notify({
status: "success",
text: intl.formatMessage(commonMessages.savedChanges),
});
navigate(collectionUrl(data.collectionCreate.collection.id));
} else {
const backgroundImageError = data.collectionCreate.errors.find(
error => error.field === ("backgroundImage" as keyof CollectionCreateInput),
);

if (backgroundImageError) {
notify({
status: "error",
text: intl.formatMessage(commonMessages.somethingWentWrong),
});
}
}
},
});
const [createCollection, createCollectionOpts] = useCreateCollectionMutation({});
const handleCreate = async (formData: CollectionCreateData) => {
const result = await createCollection({
variables: {
Expand All @@ -103,7 +82,7 @@ export const CollectionCreate: React.FC<CollectionCreateProps> = ({ params }) =>
const id = result.data?.collectionCreate.collection?.id || null;

if (id) {
updateChannels({
await updateChannels({
variables: {
id,
input: {
Expand All @@ -118,6 +97,25 @@ export const CollectionCreate: React.FC<CollectionCreateProps> = ({ params }) =>
});
}

if (result.data.collectionCreate.errors.length === 0) {
notify({
status: "success",
text: intl.formatMessage(commonMessages.savedChanges),
});
navigate(collectionUrl(id));
} else {
const backgroundImageError = result.data.collectionCreate.errors.find(
error => error.field === ("backgroundImage" as keyof CollectionCreateInput),
);

if (backgroundImageError) {
notify({
status: "error",
text: intl.formatMessage(commonMessages.somethingWentWrong),
});
}
}

return { id, errors: getMutationErrors(result) };
};
const handleSubmit = createMetadataCreateHandler(
Expand Down
8 changes: 7 additions & 1 deletion src/components/Datagrid/Datagrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,13 @@ export const Datagrid: React.FC<DatagridProps> = ({
e.preventDefault();

if (e.currentTarget.dataset.reactRouterPath) {
navigate(e.currentTarget.dataset.reactRouterPath, navigatorOpts);
const url = e.currentTarget.dataset.reactRouterPath;

if (e.metaKey || e.ctrlKey) {
window.open(url, "_blank");
} else {
navigate(url, navigatorOpts);
}
}
}}
/>
Expand Down
2 changes: 2 additions & 0 deletions src/components/RichTextEditor/ReactEditorJS.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class ClientEditorCore implements EditorCore {
}

public async save() {
await this._editorJS.isReady;

return this._editorJS.save();
}

Expand Down
84 changes: 83 additions & 1 deletion src/components/Timeline/TimelineNote.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { OrderEventFragment } from "@dashboard/graphql/types.generated";
import Wrapper from "@test/wrapper";
import { render, screen } from "@testing-library/react";
import { act, render, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import React from "react";

import TimelineNote from "./TimelineNote";
Expand Down Expand Up @@ -142,4 +143,85 @@ describe("TimelineNote", () => {
expect(initials).toBeNull();
expect(avatar).toBeInTheDocument();
});

it("renders note id and refer id", () => {
// Arrange
const noteId = "T3JkZXJFdmVudDozNDM3";
const noteRelatedId = "T3JkZXJFdmVudDozNDQx";
const mockedUser = {
avatar: null,
id: "1",
email: "[email protected]",
firstName: "Test",
lastName: "User",
__typename: "User",
} satisfies OrderEventFragment["user"];

// Act
render(
<TimelineNote
app={null}
user={mockedUser}
date={wrapperFriendlyDate}
message="Note"
hasPlainDate={false}
id={noteId}
relatedId={noteRelatedId}
/>,
{ wrapper: Wrapper },
);

// Assert
expect(screen.getByText("Test User")).toBeInTheDocument();
expect(screen.getByText("Note")).toBeInTheDocument();
expect(screen.getByText("TU")).toBeInTheDocument();
expect(screen.getByText("a few seconds ago")).toBeInTheDocument();
expect(screen.getByText(`Note id: ${noteId}`)).toBeInTheDocument();
expect(screen.getByText(new RegExp(noteRelatedId))).toBeInTheDocument();
});

it("should edit note", async () => {
// Arrange
const noteId = "T3JkZXJFdmVudDozNDM3";
const noteRelatedId = "T3JkZXJFdmVudDozNDQx";
const onNoteUpdate = jest.fn();
const onNoteUpdateLoading = false;
const mockedUser = {
avatar: null,
id: "1",
email: "[email protected]",
firstName: "Test",
lastName: "User",
__typename: "User",
} satisfies OrderEventFragment["user"];

render(
<TimelineNote
app={null}
user={mockedUser}
date={wrapperFriendlyDate}
message="Note"
hasPlainDate={false}
id={noteId}
relatedId={noteRelatedId}
onNoteUpdate={onNoteUpdate}
onNoteUpdateLoading={onNoteUpdateLoading}
/>,
{ wrapper: Wrapper },
);

// Act
await act(async () => {
await userEvent.click(screen.getByTestId("edit-note"));
});

await act(async () => {
await userEvent.clear(screen.getByRole("textbox"));
await userEvent.type(screen.getByRole("textbox"), "New note");
await userEvent.click(screen.getByRole("button", { name: /save/i }));
});

// Assert
expect(onNoteUpdate).toHaveBeenCalledWith(noteId, "New note");
});
});
Loading

0 comments on commit 4dfb213

Please sign in to comment.