Follow-up for Remote backend fixes PR (#11080)

This PR is a follow-up for https://github.com/enso-org/enso/pull/11067 that addresses the issues raised in the PR

(cherry picked from commit bea9d3670a)
This commit is contained in:
Sergei Garin 2024-09-16 15:18:03 +03:00 committed by James Dunkerley
parent 573bae6ed5
commit d337bc2b9f
5 changed files with 11 additions and 19 deletions

View File

@ -92,7 +92,7 @@ export default function JSONSchemaInput(props: JSONSchemaInputProps) {
value={typeof value === 'string' ? value : ''}
size={1}
className={twMerge(
'focus-child text w-60 w-full grow rounded-input border-0.5 bg-transparent px-input-x read-only:read-only',
'focus-child text w-full grow rounded-input border-0.5 bg-transparent px-input-x read-only:read-only',
getValidator(path)(value) ? 'border-primary/20' : 'border-red-700/60',
)}
placeholder={getText('enterText')}

View File

@ -70,11 +70,11 @@ export default function AssetsTableContextMenu(props: AssetsTableContextMenuProp
// up to date.
const ownsAllSelectedAssets =
!isCloud ||
[...selectedKeys].every((key) => {
const userPermissions = nodeMapRef.current.get(key)?.item.permissions
const selfPermission = permissions.tryFindSelfPermission(user, userPermissions ?? null)
return selfPermission?.permission === permissions.PermissionAction.own
})
Array.from(selectedKeys).every(
(key) =>
permissions.tryFindSelfPermission(user, nodeMapRef.current.get(key)?.item.permissions)
?.permission === permissions.PermissionAction.own,
)
// This is not a React component even though it contains JSX.
// eslint-disable-next-line no-restricted-syntax

View File

@ -1,6 +1,7 @@
/** @file The React provider for modals, along with hooks to use the provider via
* the shared React context. */
import { useEventCallback } from '#/hooks/eventCallbackHooks'
import { useSyncRef } from '#/hooks/syncRefHooks'
import * as React from 'react'
// =====================
@ -39,13 +40,9 @@ export interface ModalProviderProps extends Readonly<React.PropsWithChildren> {}
export default function ModalProvider(props: ModalProviderProps) {
const { children } = props
const [modal, setModal] = React.useState<Modal | null>(null)
// we use key to tell react to invaldidate the modal when we change it.
// We use keys to tell react to invalidate the DialogTrigger when we change the modal.
const [key, setKey] = React.useState(0)
const modalRef = React.useRef(modal)
React.useEffect(() => {
modalRef.current = modal
}, [modal])
const modalRef = useSyncRef(modal)
const setModalStableCallback = useEventCallback(
(nextModal: React.SetStateAction<React.JSX.Element | null>) => {
@ -64,7 +61,7 @@ export default function ModalProvider(props: ModalProviderProps) {
{children}
</ModalStaticProvider>
),
[children, setModalStableCallback],
[children, modalRef, setModalStableCallback],
)
return <ModalContext.Provider value={{ modal, key }}>{setModalProvider}</ModalContext.Provider>
}

View File

@ -63,7 +63,7 @@ export function tryCreateOwnerPermission(
/** Try to find a permission belonging to the user. */
export function tryFindSelfPermission(
self: User,
otherPermissions: readonly AssetPermission[] | null,
otherPermissions: readonly AssetPermission[] | null | undefined,
) {
let selfPermission: AssetPermission | null = null
for (const permission of otherPermissions ?? []) {

View File

@ -94,11 +94,6 @@ const RESTRICTED_SYNTAXES = [
selector: 'TSTypeAliasDeclaration > :matches(TSLiteralType)',
message: 'No aliases to literal types',
},
{
selector:
':not(:matches(FunctionDeclaration, FunctionExpression, ArrowFunctionExpression, SwitchStatement, SwitchCase, IfStatement:has(.consequent > :matches(ReturnStatement, ThrowStatement)):has(.alternate :matches(ReturnStatement, ThrowStatement)), Program > TryStatement, Program > TryStatement > .handler, TryStatement:has(.block > :matches(ReturnStatement, ThrowStatement)):has(:matches([handler=null], .handler :matches(ReturnStatement, ThrowStatement))), TryStatement:has(.block > :matches(ReturnStatement, ThrowStatement)):has(:matches([handler=null], .handler :matches(ReturnStatement, ThrowStatement))) > .handler)) > * > :matches(ReturnStatement, ThrowStatement)',
message: 'No early returns',
},
{
selector:
'TSTypeAliasDeclaration > :matches(TSBooleanKeyword, TSBigintKeyword, TSNullKeyword, TSNumberKeyword, TSObjectKeyword, TSStringKeyword, TSSymbolKeyword, TSUndefinedKeyword, TSUnknownKeyword, TSVoidKeyword)',