Skip to content

Commit

Permalink
feat(app-page-builder): add useConfigureDomainDialog hook
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashu96 authored and EmilK15 committed Jun 30, 2020
1 parent 00e2cee commit d740954
Showing 1 changed file with 39 additions and 11 deletions.
50 changes: 39 additions & 11 deletions packages/app-page-builder/src/utils/configureDomain.tsx
@@ -1,6 +1,7 @@
import React from "react";
import { css } from "emotion";
import {i18n} from "@webiny/app/i18n";
import { i18n } from "@webiny/app/i18n";
import { useDialog } from "@webiny/app-admin/hooks/useDialog";

const t = i18n.ns("app-page-builder/utils");

Expand All @@ -13,13 +14,40 @@ const confirmationMessageStyles = css({

export const configureDomainTitle = t`Configure domain`;

export const ConfigureDomainMessage = ({ domain }) => (
<span className={confirmationMessageStyles}>
No site is running at <strong>{domain}</strong>
<br />
Either start the server by <code>cd apps/site && yarn start</code>
<br />
or update the domain by going into{" "}
<a href={"/settings/page-builder/general"}>page builder settings</a>
</span>
);
export const ConfigureDomainMessage = ({ domain }) => {
const isLocalHost = domain && domain.includes("localhost");
return (
<span className={confirmationMessageStyles}>
No site is running at <strong>{domain}</strong>
<br />
{isLocalHost ? (
<span>
Either start the server by <code>cd apps/site && yarn start</code>{" "}
</span>
) : (
<span>
Either deploy the site by running <code>yarn webiny deploy apps</code>{" "}
</span>
)}
<br />
or update the domain by going into{" "}
<a href={"/settings/page-builder/general"}>page builder settings</a>
</span>
);
};

export const useConfigureDomainDialog = (domain, onAccept = null) => {
const { showDialog } = useDialog();

return {
showConfigureDomainDialog: () => {
showDialog(<ConfigureDomainMessage domain={domain} />, {
title: configureDomainTitle,
actions: {
accept: { label: "Refresh", onClick: onAccept },
cancel: { label: "Cancel" }
}
});
}
};
};

0 comments on commit d740954

Please sign in to comment.