Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion frontend/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export default tseslint.config(
],
files: ["**/*.{ts,tsx}"],
languageOptions: {
ecmaVersion: 2024,
globals: globals.browser,
parserOptions: {
projectService: true,
Expand Down
6 changes: 3 additions & 3 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@
"@types/react-dom": "^19.2.3",
"@vitejs/plugin-react": "^4.4.1",
"eslint": "^9.39.4",
"eslint-plugin-react-dom": "^2.7.2",
"eslint-plugin-react-dom": "^5.9.0",
"eslint-plugin-react-hooks": "^5.2.0",
"eslint-plugin-react-refresh": "^0.4.20",
"eslint-plugin-react-x": "^1.49.0",
"eslint-plugin-react-x": "^5.9.0",
Comment thread
nourinmohd marked this conversation as resolved.
"globals": "^15.15.0",
"typescript": "~5.8.3",
"typescript": "~6.0.3",
"typescript-eslint": "^8.32.1",
"vite": "^6.4.3",
"vite-tsconfig-paths": "^6.1.1"
Expand Down
430 changes: 162 additions & 268 deletions frontend/pnpm-lock.yaml

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions frontend/src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,17 @@ function LockStatusIcon({
);
}

function ProjectInfoItem({ label, value }: { label: string; value?: string }) {
function ProjectInfoItem({
label,
value,
}: {
label: string;
value?: string | undefined;
}) {
return (
<ProjectInfoItemContainer>
<Typography variant="caption">{label}</Typography>
<Typography bold color={value ? undefined : "warning"}>
<Typography bold {...(!value && { color: "warning" })}>
{value ?? "not set"}
</Typography>
</ProjectInfoItemContainer>
Expand Down
27 changes: 22 additions & 5 deletions frontend/src/components/LockExpireNotification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,30 @@ export function LockExpireNotification() {
});

useEffect(() => {
let ignore = false;

if (!isLockAcquired || !lockInfo) {
setTimeUntilExpire(Number.POSITIVE_INFINITY);
void Promise.resolve().then(() => {
if (!ignore) {
setTimeUntilExpire(Number.POSITIVE_INFINITY);
}
});

return;
return () => {
ignore = true;
};
}

const initialTimeLeft = Math.max(
0,
Math.ceil(lockInfo.expires_at - Date.now() / 1000),
);

setTimeUntilExpire(initialTimeLeft);
void Promise.resolve().then(() => {
if (!ignore) {
setTimeUntilExpire(initialTimeLeft);
}
});

const interval = setInterval(() => {
setTimeUntilExpire((currentTimeLeft) => {
Expand All @@ -81,6 +93,7 @@ export function LockExpireNotification() {
}, 1000);

return () => {
ignore = true;
clearInterval(interval);
};
}, [isLockAcquired, lockInfo]);
Expand All @@ -95,7 +108,9 @@ export function LockExpireNotification() {
isDialogOpen &&
timeUntilExpire > projectLockExpireNotificationThreshold
) {
setIsDialogOpen(false);
void Promise.resolve().then(() => {
setIsDialogOpen(false);
});
} else if (
isLockAcquired &&
!isDialogOpen &&
Expand Down Expand Up @@ -133,7 +148,9 @@ export function LockExpireNotification() {
!isLockAcquired &&
timeUntilExpire !== Number.POSITIVE_INFINITY
) {
setTimeUntilExpire(Number.POSITIVE_INFINITY);
void Promise.resolve().then(() => {
setTimeUntilExpire(Number.POSITIVE_INFINITY);
});
}
}, [isDialogOpen, isLockAcquired, timeUntilExpire, queryClient]);

Expand Down
12 changes: 10 additions & 2 deletions frontend/src/components/LockStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ import type { LockInfo, LockStatus } from "#client/types.gen";
import { Banner } from "#styles/common";
import { displayTimestamp } from "#utils/datetime";

function EnableEditingButton({ lockStatus }: { lockStatus?: LockStatus }) {
function EnableEditingButton({
lockStatus,
}: {
lockStatus?: LockStatus | undefined;
}) {
const queryClient = useQueryClient();
const { mutate } = useMutation({
...projectPostLockAcquireMutation(),
Expand Down Expand Up @@ -130,7 +134,11 @@ export function LockIcon({ isReadOnly }: { isReadOnly: boolean }) {
);
}

export function LockStatusBanner({ lockStatus }: { lockStatus?: LockStatus }) {
export function LockStatusBanner({
lockStatus,
}: {
lockStatus?: LockStatus | undefined;
}) {
const isReadOnly = !(lockStatus?.is_lock_acquired ?? false);

return (
Expand Down
37 changes: 16 additions & 21 deletions frontend/src/components/ProjectRecoveryNotification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,29 +61,24 @@ export function ProjectRecoveryNotification() {

// biome-ignore lint/correctness/useExhaustiveDependencies: selectProjectInvalidAttempt intentionally retriggers this effect
useEffect(() => {
async function checkSnapshots() {
try {
const { data } = await projectGetCache({
query: { resource: CACHE_RESOURCE_PROJECT_CONFIG },
throwOnError: true,
});
setLatestRevision(
data.revisions.length > 0
? data.revisions[data.revisions.length - 1]
: null,
);
setIsOpen(true);
} catch {
setLatestRevision(null);
setIsOpen(true);
}
}

if (project.errorStatus === HTTP_STATUS_422_UNPROCESSABLE_CONTENT) {
void checkSnapshots();
void projectGetCache({
query: { resource: CACHE_RESOURCE_PROJECT_CONFIG },
throwOnError: true,
})
.then(({ data }) => {
setLatestRevision(data.revisions.at(-1) ?? null);
setIsOpen(true);
})
.catch(() => {
setLatestRevision(null);
setIsOpen(true);
});
} else {
setLatestRevision(null);
setIsOpen(false);
void Promise.resolve().then(() => {
setLatestRevision(null);
setIsOpen(false);
});
}
}, [project.errorStatus, selectProjectInvalidAttempt]);

Expand Down
12 changes: 6 additions & 6 deletions frontend/src/components/common.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ import {
import { handleSsoLogin } from "#utils/authentication";

type StatusCodeHandlingProps = {
message?: string;
enableRetry?: boolean;
message?: string | undefined;
enableRetry?: boolean | undefined;
};

type ErrorFallbackProps = {
header?: string;
statusCodeHandling?: Record<number, StatusCodeHandlingProps>;
header?: string | undefined;
statusCodeHandling?: Record<number, StatusCodeHandlingProps> | undefined;
};

export function Loading() {
Expand All @@ -55,10 +55,10 @@ function ErrorFallback({
error.response.status in statusCodeHandling
) {
const handling = statusCodeHandling[error.response.status];
if (handling.message !== undefined) {
if (handling?.message !== undefined) {
message = handling.message;
}
if (handling.enableRetry !== undefined) {
if (handling?.enableRetry !== undefined) {
enableRetry = handling.enableRetry;
}
}
Expand Down
31 changes: 17 additions & 14 deletions frontend/src/components/form/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ import {

type GeneralButtonProps = {
label: string;
isPending?: boolean;
disabled?: boolean;
tooltipText?: string;
onClick?: (e: React.MouseEvent<HTMLButtonElement>) => void;
onMouseDown?: (e: React.MouseEvent<HTMLButtonElement>) => void;
} & Pick<ButtonProps, "variant" | "color" | "type">;
isPending?: boolean | undefined;
disabled?: boolean | undefined;
tooltipText?: string | undefined;
onClick?: ((e: React.MouseEvent<HTMLButtonElement>) => void) | undefined;
onMouseDown?: ((e: React.MouseEvent<HTMLButtonElement>) => void) | undefined;
variant?: ButtonProps["variant"] | undefined;
color?: ButtonProps["color"] | undefined;
type?: ButtonProps["type"] | undefined;
};

export function GeneralButton({
type = "button",
Expand All @@ -29,9 +32,9 @@ export function GeneralButton({
<Tooltip title={tooltipText ?? ""}>
<Button
type={type}
variant={variant}
aria-disabled={disabled}
color={color}
{...(variant !== undefined && { variant })}
{...(color !== undefined && { color })}
onClick={
disabled
? (e) => {
Expand All @@ -43,7 +46,7 @@ export function GeneralButton({
>
{isPending && (
<DotProgress
color={variant === "outlined" ? "primary" : undefined}
{...(variant === "outlined" && { color: "primary" })}
style={{ position: "absolute" }}
/>
)}
Expand All @@ -62,9 +65,9 @@ export function SubmitButton({
helperTextDisabled = "Form can be submitted when errors have been resolved",
}: {
label: string;
disabled?: boolean;
isPending?: boolean;
helperTextDisabled?: string;
disabled?: boolean | undefined;
isPending?: boolean | undefined;
helperTextDisabled?: string | undefined;
}) {
return (
<GeneralButton
Expand All @@ -81,8 +84,8 @@ export function CancelButton({
onClick,
onMouseDown,
}: {
onClick?: (e: React.MouseEvent<HTMLButtonElement>) => void;
onMouseDown?: (e: React.MouseEvent<HTMLButtonElement>) => void;
onClick?: ((e: React.MouseEvent<HTMLButtonElement>) => void) | undefined;
onMouseDown?: ((e: React.MouseEvent<HTMLButtonElement>) => void) | undefined;
}) {
return (
<GeneralButton
Expand Down
Loading
Loading