@firecms/core 3.0.0-canary.126 → 3.0.0-canary.128

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.umd.js CHANGED
@@ -2964,9 +2964,11 @@
2964
2964
  function makePropertiesEditable(properties) {
2965
2965
  Object.keys(properties).forEach((key) => {
2966
2966
  const property = properties[key];
2967
- property.editable = true;
2968
- if (property.dataType === "map" && property.properties) {
2969
- makePropertiesEditable(property.properties);
2967
+ if (property) {
2968
+ property.editable = true;
2969
+ if (property.dataType === "map" && property.properties) {
2970
+ makePropertiesEditable(property.properties);
2971
+ }
2970
2972
  }
2971
2973
  });
2972
2974
  return properties;
@@ -2974,13 +2976,19 @@
2974
2976
  function makePropertiesNonEditable(properties) {
2975
2977
  return Object.entries(properties).reduce((acc, [key, property]) => {
2976
2978
  if (!isPropertyBuilder(property) && property.dataType === "map" && property.properties) {
2977
- const updated = { ...property, properties: makePropertiesNonEditable(property.properties) };
2979
+ const updated = {
2980
+ ...property,
2981
+ properties: makePropertiesNonEditable(property.properties)
2982
+ };
2978
2983
  acc[key] = updated;
2979
2984
  }
2980
2985
  if (isPropertyBuilder(property)) {
2981
2986
  acc[key] = property;
2982
2987
  } else {
2983
- acc[key] = { ...property, editable: false };
2988
+ acc[key] = {
2989
+ ...property,
2990
+ editable: false
2991
+ };
2984
2992
  }
2985
2993
  return acc;
2986
2994
  }, {});
@@ -10786,6 +10794,23 @@
10786
10794
  }
10787
10795
  );
10788
10796
  }
10797
+ function addRecentId(collectionId, id) {
10798
+ const recentIds = getRecentIds(collectionId);
10799
+ const newRecentIds = [id, ...recentIds.filter((i) => i !== id)];
10800
+ if (newRecentIds.length > 5) {
10801
+ newRecentIds.pop();
10802
+ }
10803
+ saveSearchedIdsLocally(collectionId, newRecentIds);
10804
+ return newRecentIds;
10805
+ }
10806
+ function saveSearchedIdsLocally(collectionId, ids) {
10807
+ localStorage.setItem("recent_id_searches::" + collectionId, JSON.stringify(ids));
10808
+ }
10809
+ function getRecentIds(collectionId) {
10810
+ const stored = localStorage.getItem("recent_id_searches::" + collectionId);
10811
+ if (!stored) return [];
10812
+ return JSON.parse(stored);
10813
+ }
10789
10814
  const editEntityAction = {
10790
10815
  icon: /* @__PURE__ */ jsxRuntime.jsx(ui.KeyboardTabIcon, {}),
10791
10816
  name: "Edit",
@@ -10803,6 +10828,9 @@
10803
10828
  path: entity.path,
10804
10829
  entityId: entity.id
10805
10830
  });
10831
+ if (collection) {
10832
+ addRecentId(collection.id, entity.id);
10833
+ }
10806
10834
  const path = collection?.collectionGroup ? entity.path : fullPath ?? entity.path;
10807
10835
  context.sideEntityController.open({
10808
10836
  entityId: entity.id,
@@ -12841,6 +12869,7 @@
12841
12869
  }) {
12842
12870
  const [openPopup, setOpenPopup] = React.useState(false);
12843
12871
  const [searchString, setSearchString] = React.useState("");
12872
+ const [recentIds, setRecentIds] = React.useState(getRecentIds(collection.id));
12844
12873
  const sideEntityController = useSideEntityController();
12845
12874
  return /* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { title: !openPopup ? "Find by ID" : void 0, asChild: false, children: /* @__PURE__ */ jsxRuntime.jsx(
12846
12875
  ui.Popover,
@@ -12851,47 +12880,69 @@
12851
12880
  align: "start",
12852
12881
  alignOffset: -117,
12853
12882
  trigger: /* @__PURE__ */ jsxRuntime.jsx(ui.IconButton, { size: "small", children: /* @__PURE__ */ jsxRuntime.jsx(ui.SearchIcon, { size: "small" }) }),
12854
- children: /* @__PURE__ */ jsxRuntime.jsx(
12855
- "form",
12856
- {
12857
- noValidate: true,
12858
- onSubmit: (e) => {
12859
- e.preventDefault();
12860
- if (!searchString) return;
12861
- setOpenPopup(false);
12862
- return sideEntityController.open({
12863
- entityId: searchString.trim(),
12864
- path,
12865
- collection,
12866
- updateUrl: true
12867
- });
12883
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: ui.cls("my-2 rounded-lg bg-gray-50 dark:bg-gray-950 text-gray-900 dark:text-white"), children: [
12884
+ /* @__PURE__ */ jsxRuntime.jsx(
12885
+ "form",
12886
+ {
12887
+ noValidate: true,
12888
+ onSubmit: (e) => {
12889
+ e.preventDefault();
12890
+ if (!searchString) return;
12891
+ setOpenPopup(false);
12892
+ setRecentIds(addRecentId(collection.id, searchString.trim()));
12893
+ return sideEntityController.open({
12894
+ entityId: searchString.trim(),
12895
+ path,
12896
+ collection,
12897
+ updateUrl: true
12898
+ });
12899
+ },
12900
+ className: "w-96 max-w-full",
12901
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex p-2 w-full gap-2", children: [
12902
+ /* @__PURE__ */ jsxRuntime.jsx(
12903
+ "input",
12904
+ {
12905
+ autoFocus: openPopup,
12906
+ placeholder: "Find entity by ID",
12907
+ onChange: (e) => {
12908
+ setSearchString(e.target.value);
12909
+ },
12910
+ value: searchString,
12911
+ className: "rounded-lg bg-white dark:bg-gray-800 flex-grow bg-transparent outline-none p-2 " + ui.focusedDisabled
12912
+ }
12913
+ ),
12914
+ /* @__PURE__ */ jsxRuntime.jsx(
12915
+ ui.Button,
12916
+ {
12917
+ variant: "text",
12918
+ disabled: !searchString.trim(),
12919
+ type: "submit",
12920
+ children: /* @__PURE__ */ jsxRuntime.jsx(ui.KeyboardTabIcon, {})
12921
+ }
12922
+ )
12923
+ ] })
12924
+ }
12925
+ ),
12926
+ recentIds && recentIds.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-2 p-2", children: recentIds.map((id) => /* @__PURE__ */ jsxRuntime.jsx(
12927
+ ReferencePreview,
12928
+ {
12929
+ reference: new EntityReference(id, path),
12930
+ hover: true,
12931
+ onClick: () => {
12932
+ setOpenPopup(false);
12933
+ sideEntityController.open({
12934
+ entityId: id,
12935
+ path,
12936
+ collection,
12937
+ updateUrl: true
12938
+ });
12939
+ },
12940
+ includeEntityLink: false,
12941
+ size: "small"
12868
12942
  },
12869
- className: "text-gray-900 dark:text-white w-96 max-w-full",
12870
- children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex p-2 w-full gap-4", children: [
12871
- /* @__PURE__ */ jsxRuntime.jsx(
12872
- "input",
12873
- {
12874
- autoFocus: openPopup,
12875
- placeholder: "Find entity by ID",
12876
- onChange: (e) => {
12877
- setSearchString(e.target.value);
12878
- },
12879
- value: searchString,
12880
- className: "flex-grow bg-transparent outline-none p-1 " + ui.focusedDisabled
12881
- }
12882
- ),
12883
- /* @__PURE__ */ jsxRuntime.jsx(
12884
- ui.Button,
12885
- {
12886
- variant: "outlined",
12887
- disabled: !searchString.trim(),
12888
- type: "submit",
12889
- children: "Go"
12890
- }
12891
- )
12892
- ] })
12893
- }
12894
- )
12943
+ id
12944
+ )) })
12945
+ ] })
12895
12946
  }
12896
12947
  ) });
12897
12948
  }
@@ -12986,7 +13037,7 @@
12986
13037
  }
12987
13038
  ) });
12988
13039
  }
12989
- function DeleteConfirmationDialog({
13040
+ function ConfirmationDialog({
12990
13041
  open,
12991
13042
  onAccept,
12992
13043
  onCancel,
@@ -13521,7 +13572,7 @@
13521
13572
  return /* @__PURE__ */ jsxRuntime.jsx(
13522
13573
  "div",
13523
13574
  {
13524
- className: `pl-2 pt-1 pb-4 flex ${direction === "row" ? "flex-row-reverse" : "flex-col"} items-center`,
13575
+ className: `pl-2 pt-1 pb-1 flex ${direction === "row" ? "flex-row-reverse" : "flex-col"} items-center`,
13525
13576
  ref: iconRef,
13526
13577
  ...provided.dragHandleProps,
13527
13578
  children: /* @__PURE__ */ jsxRuntime.jsxs(
@@ -19009,7 +19060,7 @@
19009
19060
  };
19010
19061
  }
19011
19062
  const DEFAULT_SERVER = "https://api-drplyi3b6q-ey.a.run.app";
19012
- async function makeRequest(authController, dataSourceKey, pluginKeys) {
19063
+ async function makeRequest(authController, dataSourceKey, pluginKeys, apiKey) {
19013
19064
  let idToken;
19014
19065
  try {
19015
19066
  idToken = await authController.getAuthToken();
@@ -19026,6 +19077,7 @@
19026
19077
  Authorization: `Basic ${idToken}`
19027
19078
  },
19028
19079
  body: JSON.stringify({
19080
+ apiKey,
19029
19081
  email: authController.user?.email ?? null,
19030
19082
  datasource: dataSourceKey,
19031
19083
  plugins: pluginKeys
@@ -19035,14 +19087,19 @@
19035
19087
  return res.json();
19036
19088
  });
19037
19089
  }
19038
- function useProjectLog(authController, dataSourceDelegate, plugins) {
19090
+ function useProjectLog({
19091
+ authController,
19092
+ dataSourceDelegate,
19093
+ plugins,
19094
+ apiKey
19095
+ }) {
19039
19096
  const [accessResponse, setAccessResponse] = React.useState(null);
19040
19097
  const accessedUserRef = React.useRef(null);
19041
19098
  const dataSourceKey = dataSourceDelegate.key;
19042
19099
  const pluginKeys = plugins?.map((plugin) => plugin.key);
19043
19100
  React.useEffect(() => {
19044
19101
  if (authController.user && authController.user.uid !== accessedUserRef.current && !authController.initialLoading) {
19045
- makeRequest(authController, dataSourceKey, pluginKeys).then(setAccessResponse);
19102
+ makeRequest(authController, dataSourceKey, pluginKeys, apiKey).then(setAccessResponse);
19046
19103
  accessedUserRef.current = authController.user.uid;
19047
19104
  }
19048
19105
  }, [authController, dataSourceKey, pluginKeys]);
@@ -19063,7 +19120,8 @@
19063
19120
  propertyConfigs,
19064
19121
  entityViews,
19065
19122
  components,
19066
- navigationController
19123
+ navigationController,
19124
+ apiKey
19067
19125
  } = props;
19068
19126
  ui.useLocaleConfig(locale);
19069
19127
  const dataSource = useBuildDataSource({
@@ -19087,7 +19145,15 @@
19087
19145
  const analyticsController = React.useMemo(() => ({
19088
19146
  onAnalyticsEvent
19089
19147
  }), []);
19090
- const accessResponse = useProjectLog(authController, dataSourceDelegate, plugins);
19148
+ const accessResponse = useProjectLog({
19149
+ apiKey,
19150
+ authController,
19151
+ dataSourceDelegate,
19152
+ plugins
19153
+ });
19154
+ if (accessResponse?.message) {
19155
+ console.warn(accessResponse.message);
19156
+ }
19091
19157
  if (navigationController.navigationLoadingError) {
19092
19158
  return /* @__PURE__ */ jsxRuntime.jsx(ui.CenteredView, { maxWidth: "md", children: /* @__PURE__ */ jsxRuntime.jsx(
19093
19159
  ErrorView,
@@ -19107,10 +19173,10 @@
19107
19173
  ) });
19108
19174
  }
19109
19175
  if (accessResponse?.blocked) {
19110
- return /* @__PURE__ */ jsxRuntime.jsxs(ui.CenteredView, { maxWidth: "md", fullScreen: true, children: [
19111
- /* @__PURE__ */ jsxRuntime.jsx(ui.Typography, { variant: "h4", children: "Access blocked" }),
19176
+ return /* @__PURE__ */ jsxRuntime.jsxs(ui.CenteredView, { maxWidth: "md", fullScreen: true, className: "flex flex-col gap-2", children: [
19177
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Typography, { variant: "h4", gutterBottom: true, children: "License needed" }),
19112
19178
  /* @__PURE__ */ jsxRuntime.jsxs(ui.Typography, { children: [
19113
- "This app has been blocked. Please reach out at ",
19179
+ "You need a valid license to use FireCMS PRO. Please reach out at ",
19114
19180
  /* @__PURE__ */ jsxRuntime.jsx(
19115
19181
  "a",
19116
19182
  {
@@ -19120,10 +19186,7 @@
19120
19186
  ),
19121
19187
  " for more information."
19122
19188
  ] }),
19123
- accessResponse?.message && /* @__PURE__ */ jsxRuntime.jsxs(ui.Typography, { children: [
19124
- "Response from the server: ",
19125
- accessResponse?.message
19126
- ] })
19189
+ accessResponse?.message && /* @__PURE__ */ jsxRuntime.jsx(ui.Typography, { children: accessResponse?.message })
19127
19190
  ] });
19128
19191
  }
19129
19192
  return /* @__PURE__ */ jsxRuntime.jsx(AnalyticsContext.Provider, { value: analyticsController, children: /* @__PURE__ */ jsxRuntime.jsx(CustomizationControllerContext.Provider, { value: customizationController, children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -19755,6 +19818,7 @@
19755
19818
  exports2.BooleanPreview = BooleanPreview;
19756
19819
  exports2.COLLECTION_PATH_SEPARATOR = COLLECTION_PATH_SEPARATOR;
19757
19820
  exports2.CircularProgressCenter = CircularProgressCenter;
19821
+ exports2.ConfirmationDialog = ConfirmationDialog;
19758
19822
  exports2.DEFAULT_FIELD_CONFIGS = DEFAULT_FIELD_CONFIGS;
19759
19823
  exports2.DRAWER_WIDTH = DRAWER_WIDTH;
19760
19824
  exports2.DatePreview = DatePreview;
@@ -19762,7 +19826,6 @@
19762
19826
  exports2.DefaultAppBar = DefaultAppBar;
19763
19827
  exports2.DefaultDrawer = DefaultDrawer;
19764
19828
  exports2.DefaultHomePage = DefaultHomePage;
19765
- exports2.DeleteConfirmationDialog = DeleteConfirmationDialog;
19766
19829
  exports2.Drawer = Drawer;
19767
19830
  exports2.DrawerLogo = DrawerLogo;
19768
19831
  exports2.DrawerNavigationItem = DrawerNavigationItem;