From a28462a7abd2d4e26c4fc44ea51065ab8338922a Mon Sep 17 00:00:00 2001 From: Kendall Garner <17521368+kgarner7@users.noreply.github.com> Date: Mon, 10 Mar 2025 18:50:16 +0000 Subject: [PATCH] fix(ui): fix `make dev` (#3795) 1. For some bizarre reason, importing inflection by itself is undefined. But you can import specific functions 2. Per https://github.com/vite-pwa/vite-plugin-pwa/issues/419, `type: 'module',` is only for non-chromium browsers --- ui/src/album/AlbumInfo.jsx | 4 ++-- ui/src/album/AlbumList.jsx | 6 ++---- ui/src/common/QuickFilter.jsx | 6 +++--- ui/src/common/SongInfo.jsx | 4 ++-- ui/src/dialogs/AboutDialog.jsx | 4 ++-- ui/src/dialogs/HelpDialog.jsx | 4 ++-- ui/src/layout/Menu.jsx | 4 ++-- ui/vite.config.js | 1 - 8 files changed, 15 insertions(+), 18 deletions(-) diff --git a/ui/src/album/AlbumInfo.jsx b/ui/src/album/AlbumInfo.jsx index 6ddfda96f..d6d123895 100644 --- a/ui/src/album/AlbumInfo.jsx +++ b/ui/src/album/AlbumInfo.jsx @@ -1,6 +1,6 @@ import Table from '@material-ui/core/Table' import TableBody from '@material-ui/core/TableBody' -import inflection from 'inflection' +import { humanize, underscore } from 'inflection' import TableCell from '@material-ui/core/TableCell' import TableContainer from '@material-ui/core/TableContainer' import TableRow from '@material-ui/core/TableRow' @@ -112,7 +112,7 @@ const AlbumInfo = (props) => { className={classes.tableCell} > {translate(`resources.album.fields.${key}`, { - _: inflection.humanize(inflection.underscore(key)), + _: humanize(underscore(key)), })} : diff --git a/ui/src/album/AlbumList.jsx b/ui/src/album/AlbumList.jsx index 336c605ba..142457f12 100644 --- a/ui/src/album/AlbumList.jsx +++ b/ui/src/album/AlbumList.jsx @@ -31,7 +31,7 @@ import albumLists, { defaultAlbumList } from './albumLists' import config from '../config' import AlbumInfo from './AlbumInfo' import ExpandInfoDialog from '../dialogs/ExpandInfoDialog' -import inflection from 'inflection' +import { humanize } from 'inflection' import { makeStyles } from '@material-ui/core/styles' const useStyles = makeStyles({ @@ -140,9 +140,7 @@ const AlbumFilter = (props) => { - record?.tagValue - ? inflection.humanize(record?.tagValue) - : '-- None --' + record?.tagValue ? humanize(record?.tagValue) : '-- None --' } /> diff --git a/ui/src/common/QuickFilter.jsx b/ui/src/common/QuickFilter.jsx index 62263ffc5..79b09b333 100644 --- a/ui/src/common/QuickFilter.jsx +++ b/ui/src/common/QuickFilter.jsx @@ -1,7 +1,7 @@ import React from 'react' import { Chip, makeStyles } from '@material-ui/core' import { useTranslate } from 'react-admin' -import inflection from 'inflection' +import { humanize, underscore } from 'inflection' const useQuickFilterStyles = makeStyles((theme) => ({ chip: { @@ -16,11 +16,11 @@ export const QuickFilter = ({ source, resource, label, defaultValue }) => { if (typeof lbl === 'string' || lbl instanceof String) { if (label) { lbl = translate(lbl, { - _: inflection.humanize(inflection.underscore(lbl)), + _: humanize(underscore(lbl)), }) } else { lbl = translate(`resources.${resource}.fields.${source}`, { - _: inflection.humanize(inflection.underscore(source)), + _: humanize(underscore(source)), }) } } diff --git a/ui/src/common/SongInfo.jsx b/ui/src/common/SongInfo.jsx index bce0e750f..d94685633 100644 --- a/ui/src/common/SongInfo.jsx +++ b/ui/src/common/SongInfo.jsx @@ -13,7 +13,7 @@ import { useTranslate, useRecordContext, } from 'react-admin' -import inflection from 'inflection' +import { humanize, underscore } from 'inflection' import { ArtistLinkField, BitrateField, @@ -140,7 +140,7 @@ export const SongInfo = (props) => { {translate(`resources.song.fields.${key}`, { - _: inflection.humanize(inflection.underscore(key)), + _: humanize(underscore(key)), })} : diff --git a/ui/src/dialogs/AboutDialog.jsx b/ui/src/dialogs/AboutDialog.jsx index facc056e0..4f074002b 100644 --- a/ui/src/dialogs/AboutDialog.jsx +++ b/ui/src/dialogs/AboutDialog.jsx @@ -10,7 +10,7 @@ import TableRow from '@material-ui/core/TableRow' import TableCell from '@material-ui/core/TableCell' import Paper from '@material-ui/core/Paper' import FavoriteBorderIcon from '@material-ui/icons/FavoriteBorder' -import inflection from 'inflection' +import { humanize, underscore } from 'inflection' import { useGetOne, usePermissions, useTranslate } from 'react-admin' import config from '../config' import { DialogTitle } from './DialogTitle' @@ -136,7 +136,7 @@ const AboutDialog = ({ open, onClose }) => { {translate(`about.links.${key}`, { - _: inflection.humanize(inflection.underscore(key)), + _: humanize(underscore(key)), })} : diff --git a/ui/src/dialogs/HelpDialog.jsx b/ui/src/dialogs/HelpDialog.jsx index adbce99b2..1aa9db60e 100644 --- a/ui/src/dialogs/HelpDialog.jsx +++ b/ui/src/dialogs/HelpDialog.jsx @@ -9,7 +9,7 @@ import TableBody from '@material-ui/core/TableBody' import TableRow from '@material-ui/core/TableRow' import TableCell from '@material-ui/core/TableCell' import { useTranslate } from 'react-admin' -import inflection from 'inflection' +import { humanize } from 'inflection' import { keyMap } from '../hotkeys' import { DialogTitle } from './DialogTitle' import { DialogContent } from './DialogContent' @@ -29,7 +29,7 @@ const HelpTable = (props) => { {Object.keys(keyMap).map((key) => { const { sequences, name } = keyMap[key] const description = translate(`help.hotkeys.${name}`, { - _: inflection.humanize(name), + _: humanize(name), }) return ( diff --git a/ui/src/layout/Menu.jsx b/ui/src/layout/Menu.jsx index 2cb8a9824..bd1e37ee0 100644 --- a/ui/src/layout/Menu.jsx +++ b/ui/src/layout/Menu.jsx @@ -6,7 +6,7 @@ import { useTranslate, MenuItemLink, getResources } from 'react-admin' import ViewListIcon from '@material-ui/icons/ViewList' import AlbumIcon from '@material-ui/icons/Album' import SubMenu from './SubMenu' -import inflection from 'inflection' +import { humanize, pluralize } from 'inflection' import albumLists from '../album/albumLists' import PlaylistsSubMenu from './PlaylistsSubMenu' import config from '../config' @@ -42,7 +42,7 @@ const translatedResourceName = (resource, translate) => smart_count: 2, _: resource.options.label, }) - : inflection.humanize(inflection.pluralize(resource.name)), + : humanize(pluralize(resource.name)), }) const Menu = ({ dense = false }) => { diff --git a/ui/vite.config.js b/ui/vite.config.js index 590313ffc..dee9d3939 100644 --- a/ui/vite.config.js +++ b/ui/vite.config.js @@ -16,7 +16,6 @@ export default defineConfig({ filename: 'sw.js', devOptions: { enabled: true, - type: 'module', }, }), ],