Skip to content

Commit

Permalink
Merge changes from topic "cms2"
Browse files Browse the repository at this point in the history
* changes:
  [cms] "preview" link for CMS entries, CMS publish webhooks
  [cms] plasmic sync CMS project to add preview button

GitOrigin-RevId: f89484577223a0a9c4a3f78162f66ab4269eb6de
  • Loading branch information
chungwu authored and Copybara committed Dec 14, 2023
1 parent 14165bd commit 8315c61
Show file tree
Hide file tree
Showing 37 changed files with 605 additions and 183 deletions.
11 changes: 6 additions & 5 deletions platform/wab/plasmic.json
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,8 @@
"indirect": false,
"globalContextsFilePath": "",
"splitsProviderFilePath": "",
"customFunctions": []
"customFunctions": [],
"jsBundleThemes": []
},
{
"projectId": "ooL7EhXDmFQWnW9sxtchhE",
Expand Down Expand Up @@ -8815,8 +8816,8 @@
"componentImportPath": "@plasmicapp/react-web/lib/data-sources"
}
],
"jsBundleThemes": [],
"splitsProviderFilePath": ""
"splitsProviderFilePath": "",
"customFunctions": []
},
{
"projectId": "gtUDvxG6cmBbSzqLikNzoP",
Expand Down Expand Up @@ -11071,6 +11072,6 @@
"postSyncCommands": [
"git ls-files -m | xargs pre-commit run prettier --files"
],
"cliVersion": "0.1.322",
"$schema": "https://unpkg.com/@plasmicapp/[email protected].322/dist/plasmic.schema.json"
"cliVersion": "0.1.325",
"$schema": "https://unpkg.com/@plasmicapp/[email protected].325/dist/plasmic.schema.json"
}
54 changes: 27 additions & 27 deletions platform/wab/plasmic.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7640,7 +7640,7 @@
},
{
"projectId": "ieacQ3Z46z4gwo1FnaB5vY",
"version": "3.0.1",
"version": "4.0.0",
"dependencies": {
"tXkSR39sgCDWSitZxC5xFV": "75.3.1",
"oT38tGyqov9SPWHpf3Y2Rf": "4.7.0",
Expand All @@ -7657,112 +7657,112 @@
{
"type": "renderModule",
"assetId": "FxC1c7NZtR",
"checksum": "f82a417131ff56886c059db3923fa92e"
"checksum": "6a3131466a3d2a738d6827c93e27d832"
},
{
"type": "cssRules",
"assetId": "FxC1c7NZtR",
"checksum": "f82a417131ff56886c059db3923fa92e"
"checksum": "6a3131466a3d2a738d6827c93e27d832"
},
{
"type": "renderModule",
"assetId": "kX5_DA_mZR",
"checksum": "b3d490c6d240ab1ea271ff8625170eda"
"checksum": "ac8484e27b480dc7e29505b3a7fd4e46"
},
{
"type": "cssRules",
"assetId": "kX5_DA_mZR",
"checksum": "b3d490c6d240ab1ea271ff8625170eda"
"checksum": "ac8484e27b480dc7e29505b3a7fd4e46"
},
{
"type": "renderModule",
"assetId": "fC6EeUMrpE",
"checksum": "29cdae091f4d0ce21889ea8904e5c670"
"checksum": "acd8a719a39fef84320dc2d42caf7344"
},
{
"type": "cssRules",
"assetId": "fC6EeUMrpE",
"checksum": "29cdae091f4d0ce21889ea8904e5c670"
"checksum": "acd8a719a39fef84320dc2d42caf7344"
},
{
"type": "renderModule",
"assetId": "M3aa84scyXT",
"checksum": "faa7a80ca51a37a6fd24be75182d1dbe"
"checksum": "556615e52ff03402d806f84c2795d9cc"
},
{
"type": "cssRules",
"assetId": "M3aa84scyXT",
"checksum": "faa7a80ca51a37a6fd24be75182d1dbe"
"checksum": "556615e52ff03402d806f84c2795d9cc"
},
{
"type": "renderModule",
"assetId": "FpZFUfiTA6",
"checksum": "8a40f378f4698e5446cbf382dc502c05"
"checksum": "c2a25d5a0598e9cb1c93f76b7c102c06"
},
{
"type": "cssRules",
"assetId": "FpZFUfiTA6",
"checksum": "8a40f378f4698e5446cbf382dc502c05"
"checksum": "c2a25d5a0598e9cb1c93f76b7c102c06"
},
{
"type": "renderModule",
"assetId": "girCdMST6R",
"checksum": "de075d1a032621446be780abb94768f1"
"checksum": "d6db92b395dcd97a7d073914d28c0efd"
},
{
"type": "cssRules",
"assetId": "girCdMST6R",
"checksum": "de075d1a032621446be780abb94768f1"
"checksum": "d6db92b395dcd97a7d073914d28c0efd"
},
{
"type": "renderModule",
"assetId": "k2vc2stl18",
"checksum": "754bbd05aefcdae928962fbb45a139dd"
"checksum": "7691d46eef02acf7c29f3a9d83c35ed7"
},
{
"type": "cssRules",
"assetId": "k2vc2stl18",
"checksum": "754bbd05aefcdae928962fbb45a139dd"
"checksum": "7691d46eef02acf7c29f3a9d83c35ed7"
},
{
"type": "renderModule",
"assetId": "9vM3ZFGR4eV",
"checksum": "3a98421ad015ad6a815f797624bce7ea"
"checksum": "19868deece2805abbf23ba4920cc5b14"
},
{
"type": "cssRules",
"assetId": "9vM3ZFGR4eV",
"checksum": "3a98421ad015ad6a815f797624bce7ea"
"checksum": "19868deece2805abbf23ba4920cc5b14"
},
{
"type": "renderModule",
"assetId": "FiuFB1wXjp",
"checksum": "ede12d91012043471296a84f0b4297b0"
"checksum": "107becdf96040277d7c8ff46856fd563"
},
{
"type": "cssRules",
"assetId": "FiuFB1wXjp",
"checksum": "ede12d91012043471296a84f0b4297b0"
"checksum": "107becdf96040277d7c8ff46856fd563"
},
{
"type": "renderModule",
"assetId": "y1ZiXuS8BD",
"checksum": "985be79a466f1e94f0f149407067e353"
"checksum": "27a640d634db6b3100a87de84d3e4d31"
},
{
"type": "cssRules",
"assetId": "y1ZiXuS8BD",
"checksum": "985be79a466f1e94f0f149407067e353"
"checksum": "27a640d634db6b3100a87de84d3e4d31"
},
{
"type": "renderModule",
"assetId": "pLQf-lY112u",
"checksum": "cbbe117b5b2b54ff6b3e3fe9967bd5b7"
"checksum": "b7a6068e00ff68b3509746f187a08361"
},
{
"type": "cssRules",
"assetId": "pLQf-lY112u",
"checksum": "cbbe117b5b2b54ff6b3e3fe9967bd5b7"
"checksum": "b7a6068e00ff68b3509746f187a08361"
},
{
"type": "icon",
Expand All @@ -7782,22 +7782,22 @@
{
"type": "renderModule",
"assetId": "Tz8Unep1qu",
"checksum": "c840133efc8d0dc5fc704fcfb9231819"
"checksum": "e3b8f7edebe52e0947d45fe721b00a9d"
},
{
"type": "cssRules",
"assetId": "Tz8Unep1qu",
"checksum": "c840133efc8d0dc5fc704fcfb9231819"
"checksum": "e3b8f7edebe52e0947d45fe721b00a9d"
},
{
"type": "renderModule",
"assetId": "a5viGetjMi",
"checksum": "fac09e398b86da763c8977706c2c651d"
"checksum": "ffd47de83e11deb0292c44845f4371ea"
},
{
"type": "cssRules",
"assetId": "a5viGetjMi",
"checksum": "fac09e398b86da763c8977706c2c651d"
"checksum": "ffd47de83e11deb0292c44845f4371ea"
},
{
"type": "icon",
Expand Down
51 changes: 25 additions & 26 deletions platform/wab/src/wab/client/components/cms/CmsEntriesList.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
// This is a skeleton starter React component generated by Plasmic.
// This file is owned by you, feel free to edit as you see fit.
import { HTMLElementRefOf } from "@plasmicapp/react-web";
import * as React from "react";
import { useHistory, useRouteMatch } from "react-router";
import {
ApiCmseRow,
CmsDatabaseId,
CmsTableId,
} from "../../../shared/ApiSchema";
import { UU } from "../../cli-routes";
import { useApi } from "../../contexts/AppContexts";
import { UU } from "@/wab/client/cli-routes";
import { Spinner } from "@/wab/client/components/widgets";
import { useApi } from "@/wab/client/contexts/AppContexts";
import {
DefaultCmsEntriesListProps,
PlasmicCmsEntriesList,
} from "../../plasmic/plasmic_kit_cms/PlasmicCmsEntriesList";
import { Spinner } from "../widgets";
} from "@/wab/client/plasmic/plasmic_kit_cms/PlasmicCmsEntriesList";
import { ApiCmseRow, CmsDatabaseId, CmsTableId } from "@/wab/shared/ApiSchema";
import { HTMLElementRefOf } from "@plasmicapp/react-web";
import fastStringify from "fast-stringify";
import * as React from "react";
import { useHistory, useRouteMatch } from "react-router";
import { useCmsTable, useMutateTableRows } from "./cms-contexts";
import CmsEntryItem from "./CmsEntryItem";
import fastStringify from "fast-stringify";

export interface CmsEntriesListProps extends DefaultCmsEntriesListProps {
rows?: ApiCmseRow[];
Expand All @@ -30,8 +26,10 @@ function CmsEntriesList_(
const { rows, ...rest } = props;
const api = useApi();
const history = useHistory();
const match =
useRouteMatch<{ databaseId: CmsDatabaseId; tableId: CmsTableId }>();
const match = useRouteMatch<{
databaseId: CmsDatabaseId;
tableId: CmsTableId;
}>();
const { databaseId, tableId } = match.params;
const table = useCmsTable(databaseId, tableId);
const mutateTableRows = useMutateTableRows();
Expand All @@ -40,7 +38,7 @@ function CmsEntriesList_(
if (!rows || !table) {
return <Spinner />;
}
const filteredRows = rows?.filter((row) =>
const filteredRows = rows?.filter((row) =>
fastStringify(Object.values(row))
.toLowerCase()
.includes(query.toLowerCase())
Expand All @@ -51,18 +49,19 @@ function CmsEntriesList_(
{...rest}
root={{ ref }}
modelName={table.name}
searchInput={{
value: query,
onChange: (e) => setQuery(e.target.value),
}}
// searchInput={{
// value: query,
// onChange: (e) => setQuery(e.target.value),
// }}
children={
<>
{filteredRows ?
filteredRows.map((row) => (
<CmsEntryItem table={table} row={row} key={row.id} />
)): rows.map((row) => (
<CmsEntryItem table={table} row={row} key={row.id} />
))}
{filteredRows
? filteredRows.map((row) => (
<CmsEntryItem table={table} row={row} key={row.id} />
))
: rows.map((row) => (
<CmsEntryItem table={table} row={row} key={row.id} />
))}
</>
}
addButton={{
Expand Down
37 changes: 37 additions & 0 deletions platform/wab/src/wab/client/components/cms/CmsEntryDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
CmsRowId,
CmsTableId,
} from "@/wab/shared/ApiSchema";
import { substituteUrlParams } from "@/wab/shared/utils/url-utils";
import { HTMLElementRefOf } from "@plasmicapp/react-web";
import { Drawer, Form, Menu, message, notification, Tooltip } from "antd";
import { useForm } from "antd/lib/form/Form";
Expand Down Expand Up @@ -421,6 +422,24 @@ function CmsEntryDetailsForm_(
}
</Form.Item>
}
previewButton={
table.settings?.previewUrl
? {
props: {
href: substituteUrlParams(
table.settings.previewUrl,
(row.draftData?.[""] ?? row.data?.[""] ?? {}) as Record<
string,
string
>
),
target: "_blank",
},
}
: {
render: () => null,
}
}
publishButton={{
render: (ps, Comp) => (
// Wrap in Form.Item so it can react to form error state
Expand Down Expand Up @@ -449,6 +468,24 @@ function CmsEntryDetailsForm_(
content: "Your changes have been published.",
duration: 5,
});
const hooks = table.settings?.webhooks?.filter(
(hook) => hook.event === "publish"
);
if (hooks && hooks.length > 0) {
const hooksResp = await api.triggerCmsTableWebhooks(
table.id,
"publish"
);
const failed = hooksResp.responses.filter(
(r) => r.status !== 200
);
if (failed.length > 0) {
await message.warning({
content: "Some publish hooks failed.",
duration: 5,
});
}
}
}
}}
disabled={
Expand Down
Loading

0 comments on commit 8315c61

Please sign in to comment.