Skip to content

Commit

Permalink
Schedule content item publish revamp (#2678)
Browse files Browse the repository at this point in the history
  • Loading branch information
finnar-bin and shrunyan authored May 8, 2024
1 parent 65c918b commit c8b5164
Show file tree
Hide file tree
Showing 23 changed files with 1,827 additions and 723 deletions.
58 changes: 31 additions & 27 deletions cypress/e2e/content/actions.spec.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
import moment from "moment";

const yesterdayTimestamp = moment()
.hour(0)
.minute(0)
.second(0)
.millisecond(0)
.subtract(1, "day")
.format("x");

describe("Actions in content editor", () => {
const timestamp = Date.now();

Expand Down Expand Up @@ -80,48 +90,42 @@ describe("Actions in content editor", () => {
cy.getBySelector("PublishButton").should("exist");
});

// TODO: fix race condition so schedule publish will work
it.skip("Schedules a Publish for an item", () => {
// TODO: remove reload when UI state is consistent
cy.reload();
it("Schedules a Publish for an item", () => {
cy.waitOn("/v1/content/models*", () => {
cy.visit("/content/6-a1a600-k0b6f0/7-a1be38-1b42ht/meta");
});

cy.getBySelector("PublishMenuButton").click();
cy.getBySelector("PublishScheduleButton").click({ force: true });
cy.getBySelector("SchedulePublishButton").click();
cy.getBySelector("ContentScheduledIndicator").should("exist");
});

it("Unschedules a Publish for an item", () => {
cy.getBySelector("PublishMenuButton").click();
cy.getBySelector("PublishScheduleButton").click();
// select date and time
cy.get(".form-control").first().click();
cy.get(".flatpickr-calendar.open .flatpickr-next-month").click();
cy.get(".flatpickr-calendar.open .flatpickr-day:not(.prevMonthDay)")
.first()
.click();
cy.get(".flatpickr-calendar.open .flatpickr-confirm").click();
cy.get("[data-cy=SchedulePublishButton]").click();
cy.contains("Scheduled version").should("exist");
cy.get("#SchedulePublishClose").click();
cy.getBySelector("UnschedulePublishButton").click();
cy.getBySelector("ContentScheduledIndicator").should("not.exist");
});

it("Only allows future dates to be scheduled for publish", () => {
cy.waitOn("/v1/content/models*", () => {
cy.visit("/content/6-556370-8sh47g/7-82a5c7ffb0-07vj1c");
cy.visit("/content/6-a1a600-k0b6f0/7-a1be38-1b42ht/meta");
});

cy.getBySelector("PublishMenuButton").click();
cy.getBySelector("PublishScheduleButton").click();
// cy.get(
// ".ModalAligner--ptdt- .MuiOutlinedInput-root .MuiInputAdornment-root .MuiButtonBase-root"
// ).click();
cy.getBySelector("SchedulePublishDate").find("button").click();
cy.getBySelector("PublishScheduleModal")
.find("[data-cy='datePickerInputField']")
.click();

cy.get(
'.MuiCalendarPicker-root .MuiPickersArrowSwitcher-root button[aria-label="Previous month"]'
'.MuiPickersArrowSwitcher-root button[aria-label="Previous month"]'
).should("be.disabled");
cy.get(
'.MuiCalendarPicker-root .MuiPickersArrowSwitcher-root button[aria-label="Next month"]'
'.MuiPickersArrowSwitcher-root button[aria-label="Next month"]'
).should("not.be.disabled");
});

it.skip("Unschedules a Publish for an item", () => {
cy.getBySelector("PublishMenuButton").click();
cy.getBySelector("PublishScheduleButton").click();
cy.get("#SchedulePublishClose").click();
cy.getBySelector("CancelSchedulePublishButton").click({ force: true });
});

it("Fills in default values for a new item", () => {
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"@tinymce/tinymce-react": "^4.3.0",
"@welldone-software/why-did-you-render": "^6.1.1",
"@zesty-io/core": "1.10.0",
"@zesty-io/material": "^0.13.0",
"@zesty-io/material": "^0.13.1",
"chart.js": "^3.8.0",
"chartjs-adapter-moment": "^1.0.1",
"chartjs-plugin-datalabels": "^2.0.0",
Expand Down
34 changes: 19 additions & 15 deletions src/apps/content-editor/src/app/views/ItemCreate/ItemCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@ import {
useGetContentItemQuery,
useGetContentModelFieldsQuery,
} from "../../../../../../shell/services/instance";
import { ScheduleFlyout } from "../ItemEdit/components/Header/ItemVersioning/ScheduleFlyout";
import { Error } from "../../components/Editor/Field/FieldShell";
import { ContentModelField } from "../../../../../../shell/services/types";
import {
ContentItemWithDirtyAndPublishing,
ContentModelField,
} from "../../../../../../shell/services/types";
import { SchedulePublish } from "../../../../../../shell/components/SchedulePublish";

export type ActionAfterSave =
| ""
Expand Down Expand Up @@ -341,19 +344,20 @@ export const ItemCreate = () => {
</Box>
</Stack>
</Box>
<ScheduleFlyout
isOpen={!isLoadingNewItem && isScheduleDialogOpen}
item={newItemData}
dispatch={dispatch}
toggleOpen={() => setIsScheduleDialogOpen(false)}
onScheduled={() => {
setIsScheduleDialogOpen(false);

if (willRedirect) {
history.push(`/content/${modelZUID}/${newItemData?.meta?.ZUID}`);
}
}}
/>
{isScheduleDialogOpen && !isLoadingNewItem && (
<SchedulePublish
item={newItemData as ContentItemWithDirtyAndPublishing}
onClose={() => setIsScheduleDialogOpen(false)}
onPublishNow={() => handlePublish(newItemZUID)}
onScheduleSuccess={() => {
setIsScheduleDialogOpen(false);

if (willRedirect) {
history.push(`/content/${modelZUID}/${newItemData?.meta?.ZUID}`);
}
}}
/>
)}
</WithLoader>
);
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Header } from "../components/Header";
import { ItemVersioning } from "../components/Header/ItemVersioning";

import { ItemSettings } from "./ItemSettings";
import { DataSettings } from "./ItemSettings/DataSettings";
Expand Down

This file was deleted.

Loading

0 comments on commit c8b5164

Please sign in to comment.