Skip to content

Commit

Permalink
Ensure to use a unique key in all table rows (#1069)
Browse files Browse the repository at this point in the history
## Done

- ensure to use a unique key in all table rows to fix updates on search
and filter of table contents

## QA

1. Run the LXD-UI:
- On the demo server via the link posted by @webteam-app below. This is
only available for PRs created by collaborators of the repo. Ask
@mas-who or @edlerd for access.
- With a local copy of this branch, [build and run as described in the
docs](../CONTRIBUTING.md#setting-up-for-development).
2. Perform the following QA steps:
- browse the tables and use search, ensure no errors are in the dev
console from duplicate or missing keys.
  • Loading branch information
edlerd authored Jan 23, 2025
2 parents d7f64f8 + 5e1c87f commit 8fbc8fc
Show file tree
Hide file tree
Showing 33 changed files with 34 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/components/ConfigurationRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ export const getConfigurationRowBase = ({
}: BaseProps): MainTableRow => {
return {
name,
key: name,
className,
columns: [
{
Expand Down
1 change: 1 addition & 0 deletions src/components/DeviceListTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ const DeviceListTable: FC<Props> = ({ configBaseURL, devices }) => {
}

return {
key: devicename,
columns: [
{
content: (
Expand Down
1 change: 1 addition & 0 deletions src/components/NetworkListTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const NetworkListTable: FC<Props> = ({ onFailure, devices }) => {
.map(([key]) => key);

return {
key: network.name,
columns: [
{
content: (
Expand Down
1 change: 1 addition & 0 deletions src/components/forms/SelectGPUModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const SelectGPUModal: FC<Props> = ({ onSelect, onClose }) => {
const selectCard = () => onSelect(card);

return {
key: card.pci_address,
className: "u-row",
columns: [
{
Expand Down
1 change: 1 addition & 0 deletions src/pages/cluster/ClusterMemberSelectTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const ClusterMemberSelectTable: FC<Props> = ({ onSelect, disableMember }) => {
};

return {
key: member.server_name,
className: classnames("u-row", {
"u-text--muted": disableReason,
"u-row--disabled": disableReason,
Expand Down
1 change: 1 addition & 0 deletions src/pages/images/CustomIsoSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const CustomIsoSelector: FC<Props> = ({
const selectIso = () => onSelect(image, "virtual-machine");

return {
key: image.fingerprint,
className: "u-row",
columns: [
{
Expand Down
1 change: 1 addition & 0 deletions src/pages/images/ImageList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ const ImageList: FC = () => {
const description = image.properties?.description ?? image.fingerprint;

return {
key: image.fingerprint,
name: image.fingerprint,
columns: [
{
Expand Down
1 change: 1 addition & 0 deletions src/pages/images/ImageSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ const ImageSelector: FC<Props> = ({ onSelect, onClose }) => {
};

return {
key: itemType + item.os + displayRelease + displayVariant,
className: "u-row",
columns: [
{
Expand Down
2 changes: 2 additions & 0 deletions src/pages/instances/InstanceList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ const InstanceList: FC = () => {

const creationRows: MainTableRow[] = creationOperations.map((operation) => {
return {
key: operation.id,
className: "u-row",
columns: [
{
Expand Down Expand Up @@ -349,6 +350,7 @@ const InstanceList: FC = () => {
.map((val) => val.address);

return {
key: instance.name,
className:
panelParams.instance === instance.name ? "u-row-selected" : "u-row",
name: instance.name,
Expand Down
1 change: 1 addition & 0 deletions src/pages/instances/InstanceOverviewProfiles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const InstanceOverviewProfiles: FC<Props> = ({ instance, onFailure }) => {
const description = profiles.filter((item) => item.name === profile)[0]
.description;
return {
key: profile,
columns: [
{
content: (
Expand Down
1 change: 1 addition & 0 deletions src/pages/instances/InstanceSnapshots.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ const InstanceSnapshots = (props: Props) => {
);

return {
key: snapshot.name,
className: "u-row",
name: snapshot.name,
columns: [
Expand Down
1 change: 1 addition & 0 deletions src/pages/networks/NetworkForwards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const NetworkForwards: FC<Props> = ({ network, project }) => {

const rows = forwards.map((forward) => {
return {
key: forward.listen_address,
columns: [
{
content: forward.listen_address,
Expand Down
1 change: 1 addition & 0 deletions src/pages/networks/NetworkList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const NetworkList: FC = () => {

const rows = networks.map((network) => {
return {
key: network.name,
columns: [
{
content: (
Expand Down
1 change: 1 addition & 0 deletions src/pages/networks/forms/NetworkAddresses.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const NetworkAddresses: FC<Props> = ({ formik, project }) => {
]}
rows={networkState?.addresses.map((item) => {
return {
key: item.address,
columns: [
{
content: item.address,
Expand Down
1 change: 1 addition & 0 deletions src/pages/operations/OperationList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const OperationList: FC = () => {
const rows = operations.map((operation) => {
const projectName = getProjectName(operation);
return {
key: operation.id,
columns: [
{
content: (
Expand Down
1 change: 1 addition & 0 deletions src/pages/permissions/PermissionGroups.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ const PermissionGroups: FC = () => {
const rows = filteredGroups.map((group) => {
const allIdentityIds = getIdentityIdsForGroup(group);
return {
key: group.name,
name: group.name,
className: "u-row",
columns: [
Expand Down
2 changes: 1 addition & 1 deletion src/pages/permissions/PermissionIdentities.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ const PermissionIdentities: FC = () => {
};

return {
name: isUnrestricted(identity) ? "" : identity.id,
key: identity.id,
name: isUnrestricted(identity) ? "" : identity.id,
className: "u-row",
columns: [
{
Expand Down
1 change: 1 addition & 0 deletions src/pages/permissions/PermissionIdpGroups.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ const PermissionIdpGroups: FC = () => {

const rows = filteredGroups.map((idpGroup) => {
return {
key: idpGroup.name,
name: idpGroup.name,
className: "u-row",
columns: [
Expand Down
1 change: 1 addition & 0 deletions src/pages/permissions/panels/EditGroupIdentitiesPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ const EditGroupIdentitiesPanel: FC<Props> = ({ groups }) => {
: "";

return {
key: identity.id,
name: identity.id,
className: "u-row",
columns: [
Expand Down
1 change: 1 addition & 0 deletions src/pages/permissions/panels/EditGroupPermissionsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ const EditGroupPermissionsForm: FC<Props> = ({
const isModified = permission.isAdded || permission.isRemoved;

return {
key: permission.id,
name: permission.id,
className: classnames("u-row", {
strikeout: permission.isRemoved,
Expand Down
1 change: 1 addition & 0 deletions src/pages/permissions/panels/EditIdentitiesForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ const EditIdentitiesForm: FC<Props> = ({
const isModified = formIdentity?.isAdded || formIdentity?.isRemoved;

return {
key: identity.id,
name: identity.id,
className: "u-row",
columns: [
Expand Down
1 change: 1 addition & 0 deletions src/pages/permissions/panels/GroupSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ const GroupSelection: FC<Props> = ({
};

return {
key: group.name,
name: group.name,
className: "u-row",
columns: [
Expand Down
1 change: 1 addition & 0 deletions src/pages/profiles/ProfileList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ const ProfileList: FC = () => {
instanceCountMap.find((item) => profile.name === item.name)?.total ?? 0;

return {
key: profile.name,
className:
panelParams.profile === profile.name ? "u-row-selected" : "u-row",
columns: [
Expand Down
1 change: 1 addition & 0 deletions src/pages/projects/ProjectSelectTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const ProjectSelectTable: FC<Props> = ({ onSelect, disableProject }) => {
};

return {
key: project.name,
className: classnames("u-row", {
"u-text--muted": disableReason,
"u-row--disabled": disableReason,
Expand Down
1 change: 1 addition & 0 deletions src/pages/settings/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ const Settings: FC = () => {
lastCategory = configField.category;

return {
key: configField.key,
columns: [
{
content: isNewCategory && (
Expand Down
1 change: 1 addition & 0 deletions src/pages/storage/CustomIsoList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ const CustomIsoList: FC = () => {
);

return {
key: image.fingerprint,
columns: [
{
content: image.aliases,
Expand Down
1 change: 1 addition & 0 deletions src/pages/storage/CustomVolumeSelectModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ const CustomVolumeSelectModal: FC<Props> = ({
};

return {
key: volume.name,
className: classnames("u-row", {
"u-text--muted": isDisabled,
"u-row--disabled": isDisabled,
Expand Down
1 change: 1 addition & 0 deletions src/pages/storage/StoragePoolSelectTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const StoragePoolSelectTable: FC<Props> = ({ onSelect, disablePool }) => {
};

return {
key: pool.name,
className: classnames("u-row", {
"u-text--muted": disableReason,
"u-row--disabled": disableReason,
Expand Down
1 change: 1 addition & 0 deletions src/pages/storage/StoragePools.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ const StoragePools: FC = () => {
const totalVolumeCount = volumes.length;

return {
key: pool.name,
columns: [
{
content: (
Expand Down
1 change: 1 addition & 0 deletions src/pages/storage/StorageVolumeSnapshots.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ const StorageVolumeSnapshots: FC<Props> = ({ volume }) => {
);

return {
key: snapshot.name,
className: "u-row",
name: snapshot.name,
columns: [
Expand Down
1 change: 1 addition & 0 deletions src/pages/storage/StorageVolumes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ const StorageVolumes: FC = () => {
const contentType = renderContentType(volume);

return {
key: volume.name,
className: "u-row",
columns: [
{
Expand Down
1 change: 1 addition & 0 deletions src/pages/warnings/WarningList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const WarningList: FC = () => {

const rows = warnings.map((warning) => {
return {
key: warning.uuid,
columns: [
{
content: warning.type,
Expand Down
1 change: 1 addition & 0 deletions src/util/clusterGroups.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export const getClusterRows = (
): MainTableRow[] =>
members.map((member) => {
return {
key: member.server_name,
className: "u-row",
name: member.server_name,
columns: [
Expand Down

0 comments on commit 8fbc8fc

Please sign in to comment.