You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
portainer/app/react/components/datatables/defaultGetRowId.ts

19 lines
423 B

import { DefaultType } from './types';
/**
* gets row id by looking for one of id, Id, or ID keys on the object
*/
export function defaultGetRowId<D extends DefaultType>(row: D): string {
const key = ['id', 'Id', 'ID'].find((key) =>
Object.hasOwn(row, key)
) as keyof D;
const value = row[key];
if (typeof value === 'string' || typeof value === 'number') {
return value.toString();
}
return '';
}