@stoker-platform/web-app 0.5.52 → 0.5.53

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/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @stoker-platform/web-app
2
2
 
3
+ ## 0.5.53
4
+
5
+ ### Patch Changes
6
+
7
+ - feat: add custom list actions
8
+ - @stoker-platform/node-client@0.5.35
9
+ - @stoker-platform/utils@0.5.29
10
+ - @stoker-platform/web-client@0.5.31
11
+
3
12
  ## 0.5.52
4
13
 
5
14
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stoker-platform/web-app",
3
- "version": "0.5.52",
3
+ "version": "0.5.53",
4
4
  "type": "module",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "scripts": {
@@ -51,9 +51,9 @@
51
51
  "@radix-ui/react-tooltip": "^1.2.8",
52
52
  "@react-google-maps/api": "^2.20.8",
53
53
  "@sentry/react": "^10.43.0",
54
- "@stoker-platform/node-client": "0.5.34",
55
- "@stoker-platform/utils": "0.5.28",
56
- "@stoker-platform/web-client": "0.5.30",
54
+ "@stoker-platform/node-client": "0.5.35",
55
+ "@stoker-platform/utils": "0.5.29",
56
+ "@stoker-platform/web-client": "0.5.31",
57
57
  "@tanstack/react-table": "^8.21.3",
58
58
  "@types/react": "18.3.13",
59
59
  "@types/react-dom": "18.3.1",
@@ -4,6 +4,7 @@ import {
4
4
  CardsConfig,
5
5
  CollectionField,
6
6
  CollectionSchema,
7
+ CustomListAction,
7
8
  Filter,
8
9
  FormList,
9
10
  ImagesConfig,
@@ -206,6 +207,7 @@ function Collection({
206
207
  const [isOfflineDisabled, setIsOfflineDisabled] = useState<boolean | undefined>(undefined)
207
208
  const [restrictExport, setRestrictExport] = useState<StokerRole[] | undefined>(undefined)
208
209
  const [disableCreate, setDisableCreate] = useState<boolean>(false)
210
+ const [customListActions, setCustomListActions] = useState<CustomListAction[] | undefined>(undefined)
209
211
 
210
212
  const [table, setTable] = useState<Table<StokerRecord> | undefined>(undefined)
211
213
  const [listConfig, setListConfig] = useState<ListConfig | undefined>(undefined)
@@ -840,6 +842,9 @@ function Collection({
840
842
  )
841
843
  setDisableCreate(!!disableCreate)
842
844
  const filters = (await getCachedConfigValue(customization, [...collectionAdminPath, "filters"])) || []
845
+ const customListActions =
846
+ (await getCachedConfigValue(customization, [...collectionAdminPath, "customListActions"])) || []
847
+ setCustomListActions(customListActions)
843
848
 
844
849
  const statusField = await getCachedConfigValue(customization, [...collectionAdminPath, "statusField"])
845
850
  setStatusField(statusField)
@@ -1883,26 +1888,84 @@ function Collection({
1883
1888
  )}
1884
1889
  </ToggleGroup>
1885
1890
  )}
1886
- {!formList &&
1887
- tab === "list" &&
1888
- (!restrictExport || restrictExport.includes(permissions.Role)) && (
1889
- <>
1890
- <Button
1891
- type="button"
1892
- size="sm"
1893
- variant="outline"
1894
- disabled={
1895
- !list.default?.length ||
1896
- isRouteLoading.has(location.pathname)
1897
- }
1898
- className="hidden sm:flex h-7 gap-1"
1899
- onClick={handleExport}
1900
- >
1901
- <File className="h-3.5 w-3.5" />
1902
- <span className="sr-only sm:not-sr-only sm:whitespace-nowrap">
1903
- Export
1904
- </span>
1905
- </Button>
1891
+ {!formList && tab === "list" && (
1892
+ <>
1893
+ {customListActions &&
1894
+ customListActions.some(
1895
+ (action) => !action.condition || action.condition(),
1896
+ ) ? (
1897
+ <DropdownMenu>
1898
+ <DropdownMenuTrigger>
1899
+ <Button
1900
+ type="button"
1901
+ size="sm"
1902
+ variant="outline"
1903
+ className="hidden sm:flex h-7 gap-1"
1904
+ >
1905
+ <span className="sr-only sm:not-sr-only sm:whitespace-nowrap">
1906
+ Actions
1907
+ </span>
1908
+ <ChevronsUpDown className="h-3.5 w-3.5" />
1909
+ </Button>
1910
+ </DropdownMenuTrigger>
1911
+ <DropdownMenuContent>
1912
+ {(!restrictExport ||
1913
+ restrictExport.includes(permissions.Role)) && (
1914
+ <DropdownMenuItem
1915
+ key="export"
1916
+ onClick={handleExport}
1917
+ disabled={
1918
+ !list.default?.length ||
1919
+ isRouteLoading.has(location.pathname)
1920
+ }
1921
+ >
1922
+ <File className="h-3.5 w-3.5 shrink-0 mr-1" />
1923
+ <span className="sr-only sm:not-sr-only sm:whitespace-nowrap">
1924
+ Export
1925
+ </span>
1926
+ </DropdownMenuItem>
1927
+ )}
1928
+ {customListActions
1929
+ .filter(
1930
+ (action) => !action.condition || action.condition(),
1931
+ )
1932
+ .map((action) => (
1933
+ <DropdownMenuItem
1934
+ key={action.title}
1935
+ onClick={action.action}
1936
+ >
1937
+ {action.icon &&
1938
+ createElement(action.icon, {
1939
+ className: "h-3.5 w-3.5 shrink-0 mr-1",
1940
+ })}
1941
+ <span className="sr-only sm:not-sr-only sm:whitespace-nowrap">
1942
+ {action.title}
1943
+ </span>
1944
+ </DropdownMenuItem>
1945
+ ))}
1946
+ </DropdownMenuContent>
1947
+ </DropdownMenu>
1948
+ ) : (
1949
+ (!restrictExport || restrictExport.includes(permissions.Role)) && (
1950
+ <Button
1951
+ type="button"
1952
+ size="sm"
1953
+ variant="outline"
1954
+ disabled={
1955
+ !list.default?.length ||
1956
+ isRouteLoading.has(location.pathname)
1957
+ }
1958
+ className="hidden sm:flex h-7 gap-1"
1959
+ onClick={handleExport}
1960
+ >
1961
+ <File className="h-3.5 w-3.5" />
1962
+ <span className="sr-only sm:not-sr-only sm:whitespace-nowrap">
1963
+ Export
1964
+ </span>
1965
+ </Button>
1966
+ )
1967
+ )}
1968
+ {(!restrictExport || restrictExport.includes(permissions.Role)) && (
1906
1969
  <CSVLink
1907
1970
  ref={csvLinkRef}
1908
1971
  className="hidden"
@@ -1911,8 +1974,9 @@ function Collection({
1911
1974
  filename={`${collectionTitle}.csv`}
1912
1975
  target="_blank"
1913
1976
  />
1914
- </>
1915
- )}
1977
+ )}
1978
+ </>
1979
+ )}
1916
1980
  {(tab === "cards" || tab === "images") && (
1917
1981
  <DropdownMenu>
1918
1982
  <DropdownMenuTrigger asChild>