better code: accidentally cross-package

Massimo Melina committed Apr 12, 2023 at 16:05 UTC 4e3a3165f301ced59a0d1e57143f41d817320d75
7 files changed +22 -11
admin/src/AccountForm.ts
+1 -1
@@ -9,7 +9,7 @@ import { IconBtn, isEqualLax, modifiedSx } from './misc'
9 import { Account, account2icon } from './AccountsPage'
10 import { createVerifierAndSalt, SRPParameters, SRPRoutines } from 'tssrp6a'
11 import { Delete } from '@mui/icons-material'
12 -import { isMobile } from '@hfs/frontend/src/misc'
12 +import { isMobile } from './misc'
13
14 interface FormProps { account: Account, groups: string[], done: (username: string)=>void, reload: ()=>void, addToBar: ReactNode }
15 export default function AccountForm({ account, done, groups, addToBar, reload }: FormProps) {
admin/src/AccountsPage.ts
+1 -1
@@ -10,7 +10,7 @@ import MenuButton from './MenuButton'
10 import AccountForm from './AccountForm'
11 import md from './md'
12 import _ from 'lodash'
13 -import { Flex } from '@hfs/frontend/src/components'
13 +import { Flex } from './misc'
14 import { alertDialog, confirmDialog } from './dialog'
15 import { useSnapState } from './state'
16 import { importAccountsCsv } from './importAccountsCsv'
admin/src/VfsPage.ts
+1 -1
@@ -21,7 +21,7 @@ import { AlertProps } from '@mui/material/Alert/Alert'
21 import FileForm from './FileForm'
22 import { Close, Delete } from '@mui/icons-material'
23 import { alertDialog, confirmDialog } from './dialog'
24 -import { Flex } from '@hfs/frontend/src/components'
24 +import { Flex } from './misc'
25
26 let selectOnReload: string[] | undefined
27
admin/src/dialog.ts
+1 -2
@@ -20,8 +20,7 @@ import {
20 import { Check, Close, Error as ErrorIcon, Forward, Info, Warning } from '@mui/icons-material'
21 import { newDialog, closeDialog, dialogsDefaults, DialogOptions, componentOrNode } from '@hfs/shared'
22 import { Form, FormProps } from '@hfs/mui-grid-form'
23 -import { IconBtn } from './misc'
24 -import { Flex } from '@hfs/frontend/src/components'
23 +import { IconBtn, Flex } from './misc'
24 import { useDark } from './theme'
25 import { useWindowSize } from 'usehooks-ts'
26 export * from '@hfs/shared/dialogs'
admin/src/misc.ts
+14 -2
@@ -7,7 +7,7 @@ import { SxProps } from '@mui/system'
7 import { Refresh, SvgIconComponent } from '@mui/icons-material'
8 import { alertDialog, confirmDialog } from './dialog'
9 import { apiCall } from './api'
10 -import { findFirst, formatPerc, onlyTruthy, useStateMounted } from '@hfs/shared'
10 +import { formatPerc, useStateMounted } from '@hfs/shared'
11 export * from '@hfs/shared'
12
13 export function spinner() {
@@ -131,4 +131,16 @@ export function IconProgress({ icon, progress, sx }: { icon: SvgIconComponent, p
131 }),
132 }),
133 )
134 -}
\ No newline at end of file
134 +}
135 +
136 +export function Flex({ gap='.8em', vert=false, children=null, props={}, ...rest }) {
137 + return h(Box, {
138 + sx: {
139 + display: 'flex',
140 + gap,
141 + flexDirection: vert ? 'column' : undefined,
142 + ...rest,
143 + },
144 + ...props
145 + }, children)
146 +}
frontend/src/misc.ts
-4
@@ -32,10 +32,6 @@ export function ErrorMsg({ err }: { err: Error | string | undefined }) {
32 : null
33 }
34
35 -export function isMobile() {
36 - return window.innerWidth < 800
37 -}
38 -
35 let isWorking = false // we want the 'working' thing to be singleton
36 export function working() {
37 if (isWorking)
shared/index.ts
+4
@@ -152,3 +152,7 @@ export function pendingPromise<T>() {
152 takeOut = { resolve, reject })
153 return Object.assign(ret, takeOut) as PendingPromise<T>
154 }
155 +
156 +export function isMobile() {
157 + return window.innerWidth < 800
158 +}