-
Notifications
You must be signed in to change notification settings - Fork 336
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2451 from FarmBot/staging
v15.8.11
- Loading branch information
Showing
91 changed files
with
932 additions
and
620 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
jest.mock("../delete_points", () => ({ | ||
deletePointsByIds: jest.fn(), | ||
})); | ||
|
||
import { deleteAllIds } from "../delete_points_handler"; | ||
import { deletePointsByIds } from "../delete_points"; | ||
import { fakePoint } from "../../__test_support__/fake_state/resources"; | ||
|
||
describe("deleteAllIds()", () => { | ||
it("deletes points", () => { | ||
window.confirm = () => true; | ||
const points = [fakePoint(), fakePoint()]; | ||
deleteAllIds("points", points)( | ||
{ stopPropagation: jest.fn() } as unknown as React.MouseEvent<HTMLElement>); | ||
expect(deletePointsByIds).toHaveBeenCalledWith("points", [1, 2]); | ||
}); | ||
|
||
it("doesn't delete points", () => { | ||
window.confirm = () => false; | ||
const points = [fakePoint(), fakePoint()]; | ||
deleteAllIds("points", points)( | ||
{ stopPropagation: jest.fn() } as unknown as React.MouseEvent<HTMLElement>); | ||
expect(deletePointsByIds).not.toHaveBeenCalled(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { betterCompact } from "../util"; | ||
import { t } from "../i18next_wrapper"; | ||
import { TaggedGenericPointer, TaggedWeedPointer } from "farmbot"; | ||
import { deletePointsByIds } from "./delete_points"; | ||
|
||
export const deleteAllIds = ( | ||
pointName: string, | ||
points: (TaggedGenericPointer | TaggedWeedPointer)[], | ||
) => | ||
(event: React.MouseEvent<HTMLElement>) => { | ||
const ids = betterCompact(points.map(p => p.body.id)); | ||
event.stopPropagation(); | ||
confirm(t("Delete all {{ count }} {{points}} in section?", | ||
{ count: ids.length, points: pointName })) && | ||
deletePointsByIds(pointName, ids); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.