@firecms/user_management 3.4.0-canary.cb27f16 → 3.4.0-canary.ce97da7

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.
@@ -0,0 +1,7 @@
1
+ import React from "react";
2
+ /**
3
+ * Shown by the Users and Roles views instead of their editors while FireCMS
4
+ * PRO is paused. The user management plugin itself stays mounted, so sign-in
5
+ * and role checks keep working; only editing users and roles is paused.
6
+ */
7
+ export declare function UserManagementPausedNotice(): React.JSX.Element;
package/dist/index.es.js CHANGED
@@ -1,13 +1,12 @@
1
1
  import React, { useEffect, useCallback, useContext, useState } from "react";
2
2
  import equal from "react-fast-compare";
3
- import { removeUndefined, useTranslation, useAuthController, toSnakeCase, FieldCaption, ConfirmationDialog, useNavigationController, useSnackbarController, useCustomizationController, defaultDateFormat } from "@firecms/core";
3
+ import { removeUndefined, useTranslation, useAuthController, toSnakeCase, FieldCaption, ConfirmationDialog, useLicenseStatus, getLicenseSubscribeUrl, isProPaused, useNavigationController, useSnackbarController, useCustomizationController, useDateFnsLocale, defaultDateFormat } from "@firecms/core";
4
4
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
5
5
  import { c } from "react-compiler-runtime";
6
- import { getColorSchemeForSeed, Chip, TableRow, TableCell, Checkbox, Tooltip, Button, Typography, DialogTitle, TextField, TableHeader, TableBody, Paper, Table, SelectItem, Select, DialogContent, LoadingButton, DialogActions, Dialog, IconButton, DeleteIcon, CenteredView, AddIcon, Container, CopyIcon, MultiSelectItem, MultiSelect, Avatar } from "@firecms/ui";
6
+ import { getColorSchemeForSeed, Chip, TableRow, TableCell, Checkbox, Tooltip, Button, Typography, DialogTitle, TextField, TableHeader, TableBody, Paper, Table, SelectItem, Select, DialogContent, LoadingButton, DialogActions, Dialog, IconButton, DeleteIcon, CenteredView, Container, AddIcon, CopyIcon, MultiSelectItem, MultiSelect, Avatar } from "@firecms/ui";
7
7
  import * as Yup from "yup";
8
8
  import { useCreateFormex, getIn, Formex } from "@firecms/formex";
9
9
  import { format } from "date-fns";
10
- import * as locales from "date-fns/locale";
11
10
  const RESERVED_GROUPS = ["Admin"];
12
11
  const DEFAULT_PERMISSIONS = {
13
12
  read: false,
@@ -1965,14 +1964,96 @@ function RolesTable(t0) {
1965
1964
  }
1966
1965
  return t21;
1967
1966
  }
1967
+ function UserManagementPausedNotice() {
1968
+ const $ = c(20);
1969
+ const {
1970
+ t
1971
+ } = useTranslation();
1972
+ const licenseStatus = useLicenseStatus();
1973
+ let t0;
1974
+ if ($[0] !== licenseStatus?.licenseState || $[1] !== t) {
1975
+ t0 = licenseStatus?.licenseState === "invalid_project" ? t("license_add_project_to_license") : t("license_get_license");
1976
+ $[0] = licenseStatus?.licenseState;
1977
+ $[1] = t;
1978
+ $[2] = t0;
1979
+ } else {
1980
+ t0 = $[2];
1981
+ }
1982
+ const linkLabel = t0;
1983
+ let t1;
1984
+ if ($[3] !== t) {
1985
+ t1 = t("pro_features_paused");
1986
+ $[3] = t;
1987
+ $[4] = t1;
1988
+ } else {
1989
+ t1 = $[4];
1990
+ }
1991
+ let t2;
1992
+ if ($[5] !== t1) {
1993
+ t2 = /* @__PURE__ */ jsx(Typography, { variant: "subtitle2", className: "uppercase", children: t1 });
1994
+ $[5] = t1;
1995
+ $[6] = t2;
1996
+ } else {
1997
+ t2 = $[6];
1998
+ }
1999
+ let t3;
2000
+ if ($[7] !== t) {
2001
+ t3 = t("user_management_paused_description");
2002
+ $[7] = t;
2003
+ $[8] = t3;
2004
+ } else {
2005
+ t3 = $[8];
2006
+ }
2007
+ let t4;
2008
+ if ($[9] !== t3) {
2009
+ t4 = /* @__PURE__ */ jsx(Typography, { children: t3 });
2010
+ $[9] = t3;
2011
+ $[10] = t4;
2012
+ } else {
2013
+ t4 = $[10];
2014
+ }
2015
+ let t5;
2016
+ if ($[11] !== licenseStatus) {
2017
+ t5 = getLicenseSubscribeUrl(licenseStatus);
2018
+ $[11] = licenseStatus;
2019
+ $[12] = t5;
2020
+ } else {
2021
+ t5 = $[12];
2022
+ }
2023
+ let t6;
2024
+ if ($[13] !== linkLabel || $[14] !== t5) {
2025
+ t6 = /* @__PURE__ */ jsx(Button, { component: "a", href: t5, target: "_blank", rel: "noopener noreferrer", children: linkLabel });
2026
+ $[13] = linkLabel;
2027
+ $[14] = t5;
2028
+ $[15] = t6;
2029
+ } else {
2030
+ t6 = $[15];
2031
+ }
2032
+ let t7;
2033
+ if ($[16] !== t2 || $[17] !== t4 || $[18] !== t6) {
2034
+ t7 = /* @__PURE__ */ jsxs(Paper, { className: "flex flex-col items-start px-4 py-6 bg-white dark:bg-surface-accent-800 gap-2", children: [
2035
+ t2,
2036
+ t4,
2037
+ t6
2038
+ ] });
2039
+ $[16] = t2;
2040
+ $[17] = t4;
2041
+ $[18] = t6;
2042
+ $[19] = t7;
2043
+ } else {
2044
+ t7 = $[19];
2045
+ }
2046
+ return t7;
2047
+ }
1968
2048
  const RolesView = React.memo(function RolesView2(t0) {
1969
- const $ = c(25);
2049
+ const $ = c(33);
1970
2050
  const {
1971
2051
  children
1972
2052
  } = t0;
1973
2053
  const {
1974
2054
  t
1975
2055
  } = useTranslation();
2056
+ const paused = isProPaused(useLicenseStatus());
1976
2057
  const {
1977
2058
  collections
1978
2059
  } = useNavigationController();
@@ -2000,94 +2081,133 @@ const RolesView = React.memo(function RolesView2(t0) {
2000
2081
  t2 = $[1];
2001
2082
  }
2002
2083
  const handleClose = t2;
2084
+ if (paused) {
2085
+ let t32;
2086
+ if ($[2] !== t) {
2087
+ t32 = t("roles");
2088
+ $[2] = t;
2089
+ $[3] = t32;
2090
+ } else {
2091
+ t32 = $[3];
2092
+ }
2093
+ let t42;
2094
+ if ($[4] !== t32) {
2095
+ t42 = /* @__PURE__ */ jsx(Typography, { gutterBottom: true, variant: "h4", className: "mt-12", component: "h4", children: t32 });
2096
+ $[4] = t32;
2097
+ $[5] = t42;
2098
+ } else {
2099
+ t42 = $[5];
2100
+ }
2101
+ let t52;
2102
+ if ($[6] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2103
+ t52 = /* @__PURE__ */ jsx(UserManagementPausedNotice, {});
2104
+ $[6] = t52;
2105
+ } else {
2106
+ t52 = $[6];
2107
+ }
2108
+ let t62;
2109
+ if ($[7] !== children || $[8] !== t42) {
2110
+ t62 = /* @__PURE__ */ jsxs(Container, { className: "w-full flex flex-col py-4 gap-4", maxWidth: "6xl", children: [
2111
+ children,
2112
+ t42,
2113
+ t52
2114
+ ] });
2115
+ $[7] = children;
2116
+ $[8] = t42;
2117
+ $[9] = t62;
2118
+ } else {
2119
+ t62 = $[9];
2120
+ }
2121
+ return t62;
2122
+ }
2003
2123
  let t3;
2004
- if ($[2] !== t) {
2124
+ if ($[10] !== t) {
2005
2125
  t3 = t("roles");
2006
- $[2] = t;
2007
- $[3] = t3;
2126
+ $[10] = t;
2127
+ $[11] = t3;
2008
2128
  } else {
2009
- t3 = $[3];
2129
+ t3 = $[11];
2010
2130
  }
2011
2131
  let t4;
2012
- if ($[4] !== t3) {
2132
+ if ($[12] !== t3) {
2013
2133
  t4 = /* @__PURE__ */ jsx(Typography, { gutterBottom: true, variant: "h4", className: "flex-grow", component: "h4", children: t3 });
2014
- $[4] = t3;
2015
- $[5] = t4;
2134
+ $[12] = t3;
2135
+ $[13] = t4;
2016
2136
  } else {
2017
- t4 = $[5];
2137
+ t4 = $[13];
2018
2138
  }
2019
2139
  let t5;
2020
2140
  let t6;
2021
- if ($[6] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2141
+ if ($[14] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2022
2142
  t5 = /* @__PURE__ */ jsx(AddIcon, {});
2023
2143
  t6 = () => setDialogOpen(true);
2024
- $[6] = t5;
2025
- $[7] = t6;
2144
+ $[14] = t5;
2145
+ $[15] = t6;
2026
2146
  } else {
2027
- t5 = $[6];
2028
- t6 = $[7];
2147
+ t5 = $[14];
2148
+ t6 = $[15];
2029
2149
  }
2030
2150
  let t7;
2031
- if ($[8] !== t) {
2151
+ if ($[16] !== t) {
2032
2152
  t7 = t("add_role");
2033
- $[8] = t;
2034
- $[9] = t7;
2153
+ $[16] = t;
2154
+ $[17] = t7;
2035
2155
  } else {
2036
- t7 = $[9];
2156
+ t7 = $[17];
2037
2157
  }
2038
2158
  let t8;
2039
- if ($[10] !== t7) {
2159
+ if ($[18] !== t7) {
2040
2160
  t8 = /* @__PURE__ */ jsx(Button, { size: "large", startIcon: t5, onClick: t6, children: t7 });
2041
- $[10] = t7;
2042
- $[11] = t8;
2161
+ $[18] = t7;
2162
+ $[19] = t8;
2043
2163
  } else {
2044
- t8 = $[11];
2164
+ t8 = $[19];
2045
2165
  }
2046
2166
  let t9;
2047
- if ($[12] !== t4 || $[13] !== t8) {
2167
+ if ($[20] !== t4 || $[21] !== t8) {
2048
2168
  t9 = /* @__PURE__ */ jsxs("div", { className: "flex items-center mt-12", children: [
2049
2169
  t4,
2050
2170
  t8
2051
2171
  ] });
2052
- $[12] = t4;
2053
- $[13] = t8;
2054
- $[14] = t9;
2172
+ $[20] = t4;
2173
+ $[21] = t8;
2174
+ $[22] = t9;
2055
2175
  } else {
2056
- t9 = $[14];
2176
+ t9 = $[22];
2057
2177
  }
2058
2178
  let t10;
2059
- if ($[15] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2179
+ if ($[23] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2060
2180
  t10 = /* @__PURE__ */ jsx(RolesTable, { onRoleClicked, editable: true });
2061
- $[15] = t10;
2181
+ $[23] = t10;
2062
2182
  } else {
2063
- t10 = $[15];
2183
+ t10 = $[23];
2064
2184
  }
2065
2185
  const t11 = selectedRole?.id ?? "new";
2066
2186
  let t12;
2067
- if ($[16] !== collections || $[17] !== dialogOpen || $[18] !== selectedRole || $[19] !== t11) {
2187
+ if ($[24] !== collections || $[25] !== dialogOpen || $[26] !== selectedRole || $[27] !== t11) {
2068
2188
  t12 = /* @__PURE__ */ jsx(RolesDetailsForm, { open: dialogOpen, role: selectedRole, editable: true, collections, handleClose }, t11);
2069
- $[16] = collections;
2070
- $[17] = dialogOpen;
2071
- $[18] = selectedRole;
2072
- $[19] = t11;
2073
- $[20] = t12;
2189
+ $[24] = collections;
2190
+ $[25] = dialogOpen;
2191
+ $[26] = selectedRole;
2192
+ $[27] = t11;
2193
+ $[28] = t12;
2074
2194
  } else {
2075
- t12 = $[20];
2195
+ t12 = $[28];
2076
2196
  }
2077
2197
  let t13;
2078
- if ($[21] !== children || $[22] !== t12 || $[23] !== t9) {
2198
+ if ($[29] !== children || $[30] !== t12 || $[31] !== t9) {
2079
2199
  t13 = /* @__PURE__ */ jsxs(Container, { className: "w-full flex flex-col py-4 gap-4", maxWidth: "6xl", children: [
2080
2200
  children,
2081
2201
  t9,
2082
2202
  t10,
2083
2203
  t12
2084
2204
  ] });
2085
- $[21] = children;
2086
- $[22] = t12;
2087
- $[23] = t9;
2088
- $[24] = t13;
2205
+ $[29] = children;
2206
+ $[30] = t12;
2207
+ $[31] = t9;
2208
+ $[32] = t13;
2089
2209
  } else {
2090
- t13 = $[24];
2210
+ t13 = $[32];
2091
2211
  }
2092
2212
  return t13;
2093
2213
  });
@@ -2580,7 +2700,7 @@ function UsersTable(t0) {
2580
2700
  const authController = useAuthController();
2581
2701
  const snackbarController = useSnackbarController();
2582
2702
  const customizationController = useCustomizationController();
2583
- const dateUtilsLocale = customizationController?.locale ? locales[customizationController?.locale] : void 0;
2703
+ const dateUtilsLocale = useDateFnsLocale(customizationController?.locale);
2584
2704
  const dateFormat = customizationController?.dateTimeFormat ?? defaultDateFormat;
2585
2705
  const [userToBeDeleted, setUserToBeDeleted] = useState(void 0);
2586
2706
  const [deleteInProgress, setDeleteInProgress] = useState(false);
@@ -2875,13 +2995,14 @@ function _temp$1(userRole) {
2875
2995
  return /* @__PURE__ */ jsx(RoleChip, { role: userRole }, userRole?.id);
2876
2996
  }
2877
2997
  const UsersView = function UsersView2(t0) {
2878
- const $ = c(24);
2998
+ const $ = c(32);
2879
2999
  const {
2880
3000
  children
2881
3001
  } = t0;
2882
3002
  const {
2883
3003
  t
2884
3004
  } = useTranslation();
3005
+ const paused = isProPaused(useLicenseStatus());
2885
3006
  const [dialogOpen, setDialogOpen] = useState(false);
2886
3007
  const [selectedUser, setSelectedUser] = useState();
2887
3008
  const [newFormKey, setNewFormKey] = useState(0);
@@ -2920,89 +3041,128 @@ const UsersView = function UsersView2(t0) {
2920
3041
  t3 = $[2];
2921
3042
  }
2922
3043
  const handleAddUser = t3;
3044
+ if (paused) {
3045
+ let t42;
3046
+ if ($[3] !== t) {
3047
+ t42 = t("users");
3048
+ $[3] = t;
3049
+ $[4] = t42;
3050
+ } else {
3051
+ t42 = $[4];
3052
+ }
3053
+ let t52;
3054
+ if ($[5] !== t42) {
3055
+ t52 = /* @__PURE__ */ jsx(Typography, { gutterBottom: true, variant: "h4", className: "mt-12", component: "h4", children: t42 });
3056
+ $[5] = t42;
3057
+ $[6] = t52;
3058
+ } else {
3059
+ t52 = $[6];
3060
+ }
3061
+ let t62;
3062
+ if ($[7] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
3063
+ t62 = /* @__PURE__ */ jsx(UserManagementPausedNotice, {});
3064
+ $[7] = t62;
3065
+ } else {
3066
+ t62 = $[7];
3067
+ }
3068
+ let t72;
3069
+ if ($[8] !== children || $[9] !== t52) {
3070
+ t72 = /* @__PURE__ */ jsxs(Container, { className: "w-full flex flex-col py-4 gap-4", maxWidth: "6xl", children: [
3071
+ children,
3072
+ t52,
3073
+ t62
3074
+ ] });
3075
+ $[8] = children;
3076
+ $[9] = t52;
3077
+ $[10] = t72;
3078
+ } else {
3079
+ t72 = $[10];
3080
+ }
3081
+ return t72;
3082
+ }
2923
3083
  let t4;
2924
- if ($[3] !== t) {
3084
+ if ($[11] !== t) {
2925
3085
  t4 = t("users");
2926
- $[3] = t;
2927
- $[4] = t4;
3086
+ $[11] = t;
3087
+ $[12] = t4;
2928
3088
  } else {
2929
- t4 = $[4];
3089
+ t4 = $[12];
2930
3090
  }
2931
3091
  let t5;
2932
- if ($[5] !== t4) {
3092
+ if ($[13] !== t4) {
2933
3093
  t5 = /* @__PURE__ */ jsx(Typography, { gutterBottom: true, variant: "h4", className: "flex-grow", component: "h4", children: t4 });
2934
- $[5] = t4;
2935
- $[6] = t5;
3094
+ $[13] = t4;
3095
+ $[14] = t5;
2936
3096
  } else {
2937
- t5 = $[6];
3097
+ t5 = $[14];
2938
3098
  }
2939
3099
  let t6;
2940
- if ($[7] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
3100
+ if ($[15] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2941
3101
  t6 = /* @__PURE__ */ jsx(AddIcon, {});
2942
- $[7] = t6;
3102
+ $[15] = t6;
2943
3103
  } else {
2944
- t6 = $[7];
3104
+ t6 = $[15];
2945
3105
  }
2946
3106
  let t7;
2947
- if ($[8] !== t) {
3107
+ if ($[16] !== t) {
2948
3108
  t7 = t("add_user");
2949
- $[8] = t;
2950
- $[9] = t7;
3109
+ $[16] = t;
3110
+ $[17] = t7;
2951
3111
  } else {
2952
- t7 = $[9];
3112
+ t7 = $[17];
2953
3113
  }
2954
3114
  let t8;
2955
- if ($[10] !== t7) {
3115
+ if ($[18] !== t7) {
2956
3116
  t8 = /* @__PURE__ */ jsx(Button, { size: "large", startIcon: t6, onClick: handleAddUser, children: t7 });
2957
- $[10] = t7;
2958
- $[11] = t8;
3117
+ $[18] = t7;
3118
+ $[19] = t8;
2959
3119
  } else {
2960
- t8 = $[11];
3120
+ t8 = $[19];
2961
3121
  }
2962
3122
  let t9;
2963
- if ($[12] !== t5 || $[13] !== t8) {
3123
+ if ($[20] !== t5 || $[21] !== t8) {
2964
3124
  t9 = /* @__PURE__ */ jsxs("div", { className: "flex items-center mt-12", children: [
2965
3125
  t5,
2966
3126
  t8
2967
3127
  ] });
2968
- $[12] = t5;
2969
- $[13] = t8;
2970
- $[14] = t9;
3128
+ $[20] = t5;
3129
+ $[21] = t8;
3130
+ $[22] = t9;
2971
3131
  } else {
2972
- t9 = $[14];
3132
+ t9 = $[22];
2973
3133
  }
2974
3134
  let t10;
2975
- if ($[15] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
3135
+ if ($[23] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2976
3136
  t10 = /* @__PURE__ */ jsx(UsersTable, { onUserClicked });
2977
- $[15] = t10;
3137
+ $[23] = t10;
2978
3138
  } else {
2979
- t10 = $[15];
3139
+ t10 = $[23];
2980
3140
  }
2981
3141
  const t11 = selectedUser?.uid ?? `new-${newFormKey}`;
2982
3142
  let t12;
2983
- if ($[16] !== dialogOpen || $[17] !== selectedUser || $[18] !== t11) {
3143
+ if ($[24] !== dialogOpen || $[25] !== selectedUser || $[26] !== t11) {
2984
3144
  t12 = /* @__PURE__ */ jsx(UserDetailsForm, { open: dialogOpen, user: selectedUser, handleClose }, t11);
2985
- $[16] = dialogOpen;
2986
- $[17] = selectedUser;
2987
- $[18] = t11;
2988
- $[19] = t12;
3145
+ $[24] = dialogOpen;
3146
+ $[25] = selectedUser;
3147
+ $[26] = t11;
3148
+ $[27] = t12;
2989
3149
  } else {
2990
- t12 = $[19];
3150
+ t12 = $[27];
2991
3151
  }
2992
3152
  let t13;
2993
- if ($[20] !== children || $[21] !== t12 || $[22] !== t9) {
3153
+ if ($[28] !== children || $[29] !== t12 || $[30] !== t9) {
2994
3154
  t13 = /* @__PURE__ */ jsxs(Container, { className: "w-full flex flex-col py-4 gap-4", maxWidth: "6xl", children: [
2995
3155
  children,
2996
3156
  t9,
2997
3157
  t10,
2998
3158
  t12
2999
3159
  ] });
3000
- $[20] = children;
3001
- $[21] = t12;
3002
- $[22] = t9;
3003
- $[23] = t13;
3160
+ $[28] = children;
3161
+ $[29] = t12;
3162
+ $[30] = t9;
3163
+ $[31] = t13;
3004
3164
  } else {
3005
- t13 = $[23];
3165
+ t13 = $[31];
3006
3166
  }
3007
3167
  return t13;
3008
3168
  };
@@ -3090,6 +3250,10 @@ function IntroWidget(t0) {
3090
3250
  const {
3091
3251
  t
3092
3252
  } = useTranslation();
3253
+ const licenseStatus = useLicenseStatus();
3254
+ if (isProPaused(licenseStatus)) {
3255
+ return null;
3256
+ }
3093
3257
  let t1;
3094
3258
  if ($[0] !== noRoles || $[1] !== noUsers || $[2] !== t) {
3095
3259
  t1 = noUsers && noRoles ? t("create_default_roles_and_add_admin") : noUsers ? t("add_current_user_as_admin") : noRoles ? t("create_default_roles") : void 0;