Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

fix: restore publish countdown (#6443)

Oleg Isonen30b4f994dc27
diff --git a/apps/builder/app/builder/features/publish/domains.tsx b/apps/builder/app/builder/features/publish/domains.tsx
index ee26859c8e..ff0e392386 100644
--- a/apps/builder/app/builder/features/publish/domains.tsx
+++ b/apps/builder/app/builder/features/publish/domains.tsx
@@ -371,7 +371,11 @@ const DomainItem = ({
<CopyToClipboard
text={pageUrl.toString()}
- copyText={`Copy link: ${pageUrl.toString()}`}
+ copyText={
+ <Text css={{ overflowWrap: "anywhere" }}>
+ Copy link: {pageUrl.toString()}
+ </Text>
+ }
>
<IconButton type="button" tabIndex={-1}>
<CopyIcon />
diff --git a/apps/builder/app/builder/features/publish/publish-actions.test.tsx b/apps/builder/app/builder/features/publish/publish-actions.test.tsx
index d9c520bacb..9fc4fbee5f 100644
--- a/apps/builder/app/builder/features/publish/publish-actions.test.tsx
+++ b/apps/builder/app/builder/features/publish/publish-actions.test.tsx
@@ -22,7 +22,9 @@ afterEach(() => {
const render = (
validationState: "idle" | "passed",
publishInProgress = false,
- publishDisabled = false
+ publishDisabled = false,
+ publishPending = false,
+ publishLabel = "Publish"
) => {
container = document.createElement("div");
document.body.appendChild(container);
@@ -35,8 +37,9 @@ const render = (
validateDisabled={publishInProgress}
publishDisabled={publishDisabled}
publishInProgress={publishInProgress}
+ publishPending={publishPending}
hasSelectedDomains
- publishLabel="Publish"
+ publishLabel={publishLabel}
publishButtonRef={createRef<HTMLButtonElement>()}
onValidate={vi.fn(async () => {})}
onPublish={vi.fn()}
@@ -84,6 +87,7 @@ test("clears the validation result when the publish popover closes", async () =>
validateDisabled={false}
publishDisabled={false}
publishInProgress={false}
+ publishPending={false}
hasSelectedDomains
publishLabel="Publish"
publishButtonRef={createRef<HTMLButtonElement>()}
@@ -134,11 +138,27 @@ test("clears the validation result when the publish popover closes", async () =>
expect(reopenedValidate.querySelector("svg")).toBeNull();
});
-test("shows publish progress and disables actions immediately", () => {
- const [validate, publish] = render("idle", true, true);
+test("shows the countdown and disables actions during publish progress", () => {
+ const [validate, publish] = render(
+ "idle",
+ true,
+ true,
+ false,
+ "Publishing (60s)"
+ );
+
+ expect(validate).toBeDisabled();
+ expect(publish.dataset.state).toBe("disabled");
+ expect(publish).toBeDisabled();
+ expect(publish.textContent).toBe("Publishing (60s)");
+ expect(publish.querySelector("svg")).toBeNull();
+});
+
+test("shows the pending state after the countdown expires", () => {
+ const [validate, publish] = render("idle", true, true, true);
expect(validate).toBeDisabled();
- expect(publish.dataset.state).toBe("pending");
+ expect(publish.dataset.state).toBe("disabled");
expect(publish).toBeDisabled();
expect(publish.querySelector("svg")).not.toBeNull();
});
@@ -161,6 +181,7 @@ test("shows pending immediately after Validate is clicked", async () => {
validateDisabled={false}
publishDisabled={false}
publishInProgress={false}
+ publishPending={false}
hasSelectedDomains
publishLabel="Publish"
publishButtonRef={createRef<HTMLButtonElement>()}
diff --git a/apps/builder/app/builder/features/publish/publish-actions.tsx b/apps/builder/app/builder/features/publish/publish-actions.tsx
index 45e1c38987..bd078a355d 100644
--- a/apps/builder/app/builder/features/publish/publish-actions.tsx
+++ b/apps/builder/app/builder/features/publish/publish-actions.tsx
@@ -40,6 +40,7 @@ export const PublishActions = ({
validateDisabled,
publishDisabled,
publishInProgress,
+ publishPending,
hasSelectedDomains,
publishLabel,
publishButtonRef,
@@ -50,6 +51,7 @@ export const PublishActions = ({
validateDisabled: boolean;
publishDisabled: boolean;
publishInProgress: boolean;
+ publishPending: boolean;
hasSelectedDomains: boolean;
publishLabel: string;
publishButtonRef: Ref<HTMLButtonElement>;
@@ -94,11 +96,9 @@ export const PublishActions = ({
type="button"
onClick={onPublish}
color="primary"
- state={publishInProgress ? "pending" : undefined}
+ state={publishPending ? "pending" : undefined}
css={{ flex: 1 }}
- disabled={
- publishInProgress === false && (publishDisabled || isValidating)
- }
+ disabled={publishInProgress || publishDisabled || isValidating}
>
{publishLabel}
</Button>
diff --git a/apps/builder/app/builder/features/publish/publish.tsx b/apps/builder/app/builder/features/publish/publish.tsx
index e90cb4cbc7..1e85d1582d 100644
--- a/apps/builder/app/builder/features/publish/publish.tsx
+++ b/apps/builder/app/builder/features/publish/publish.tsx
@@ -504,7 +504,11 @@ const Publish = ({
const [hasCustomDomainsSelected, setHasCustomDomainsSelected] =
useState(false);
const previousDomainsKey = useRef<string>();
- const countdown = usePublishCountdown(isPublishing);
+ const hasPendingState = project.latestBuildVirtual
+ ? getPublishStatusAndText(project.latestBuildVirtual).status === "PENDING"
+ : false;
+ const isPublishInProgress = isPublishing || hasPendingState;
+ const countdown = usePublishCountdown(isPublishInProgress);
useEffect(() => {
const form = buttonRef.current?.closest("form");
@@ -754,11 +758,6 @@ const Publish = ({
});
};
- const hasPendingState = project.latestBuildVirtual
- ? getPublishStatusAndText(project.latestBuildVirtual).status === "PENDING"
- : false;
-
- const isPublishInProgress = isPublishing || hasPendingState;
const getForm = () => buttonRef.current?.closest("form");
return (
@@ -781,6 +780,9 @@ const Publish = ({
userPublishCount >= maxDailyPublishesPerUser
}
publishInProgress={isPublishInProgress}
+ publishPending={
+ isPublishInProgress && (countdown === undefined || countdown === 0)
+ }
hasSelectedDomains={hasSelectedDomains}
publishLabel={
countdown !== undefined && countdown > 0
@@ -1184,10 +1186,9 @@ const Content = (props: {
<PopoverTitleActions>
<DropdownMenu>
<DropdownMenuTrigger asChild>
- <SmallIconButton
- aria-label="Publish options"
- icon={<EllipsesIcon />}
- />
+ <IconButton type="button" aria-label="Publish options">
+ <EllipsesIcon />
+ </IconButton>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuItem