1
0
Fork 0
forked from gitea/nas

Refactor <ActionsModal> to TypeScript (#34559)

This commit is contained in:
Eugen Rochko 2025-04-28 13:43:42 +02:00 committed by GitHub
parent 17e4345eb2
commit 926c67c648
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 127 additions and 135 deletions

View file

@ -22,3 +22,29 @@ export type MenuItem =
| LinkMenuItem
| ExternalLinkMenuItem
| null;
export const isMenuItem = (item: unknown): item is MenuItem => {
if (item === null) {
return true;
}
return typeof item === 'object' && 'text' in item;
};
export const isActionItem = (item: unknown): item is ActionMenuItem => {
if (!item || !isMenuItem(item)) {
return false;
}
return 'action' in item;
};
export const isExternalLinkItem = (
item: unknown,
): item is ExternalLinkMenuItem => {
if (!item || !isMenuItem(item)) {
return false;
}
return 'href' in item;
};