Skip to content

Commit cc4e1c4

Browse files
committed
Clean up some lingering errors
1 parent c774eba commit cc4e1c4

12 files changed

Lines changed: 1006 additions & 211 deletions

src/components/Collections.tsx

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
EditableConfigListStateProps,
55
EditableConfigListDispatchProps,
66
EditableConfigListOwnProps,
7+
AssociatedEntry,
78
} from "./EditableConfigList";
89
import { connect } from "react-redux";
910
import * as PropTypes from "prop-types";
@@ -117,9 +118,9 @@ export class Collections extends GenericEditableConfigList<
117118
return {
118119
registerLibrary: (library: LibraryData) => {
119120
if (this.itemToEdit()) {
120-
const data = new (window as any).FormData();
121+
const data = new FormData();
121122
data.append("library_short_name", library.short_name);
122-
data.append("collection_id", this.itemToEdit().id);
123+
data.append("collection_id", String(this.itemToEdit().id));
123124
this.props.registerLibrary(data).then(() => {
124125
if (this.props.fetchLibraryRegistrations) {
125126
this.props.fetchLibraryRegistrations();
@@ -131,8 +132,12 @@ export class Collections extends GenericEditableConfigList<
131132
};
132133
}
133134

134-
UNSAFE_componentWillMount() {
135-
super.UNSAFE_componentWillMount();
135+
protected getAllLibraries() {
136+
return this.props.data?.allLibraries ?? [];
137+
}
138+
139+
componentDidMount() {
140+
super.componentDidMount();
136141
if (this.props.fetchLibraryRegistrations) {
137142
this.props.fetchLibraryRegistrations();
138143
}
@@ -149,10 +154,16 @@ export class Collections extends GenericEditableConfigList<
149154
};
150155
}
151156

152-
renderLi(item, index): JSX.Element {
157+
renderLi(
158+
item: CollectionData,
159+
precomputedEntries: AssociatedEntry[] | undefined | null = null
160+
): JSX.Element {
153161
if (item.marked_for_deletion) {
154162
return (
155-
<li className="deleted-collection" key={index}>
163+
<li
164+
className="deleted-collection"
165+
key={String(item[this.identifierKey])}
166+
>
156167
<TrashIcon />
157168
<h4>{this.label(item)}</h4>
158169
<p>
@@ -163,7 +174,7 @@ export class Collections extends GenericEditableConfigList<
163174
</li>
164175
);
165176
}
166-
return super.renderLi(item, index);
177+
return super.renderLi(item, precomputedEntries);
167178
}
168179

169180
async delete(item: CollectionData): Promise<void> {

src/components/DiscoveryServices.tsx

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,12 @@ export class DiscoveryServices extends GenericEditableConfigList<
5959
getChildContext() {
6060
return {
6161
registerLibrary: (library: LibraryData, registration_stage: string) => {
62-
if (this.itemToEdit()) {
63-
const data = new (window as any).FormData();
62+
const item = this.itemToEdit();
63+
if (item) {
64+
const data = new FormData();
6465
data.append("library_short_name", library.short_name);
6566
data.append("registration_stage", registration_stage);
66-
data.append("integration_id", this.itemToEdit().id);
67+
data.append("integration_id", String(item.id));
6768
this.props.registerLibrary(data).then(() => {
6869
if (this.props.fetchLibraryRegistrations) {
6970
this.props.fetchLibraryRegistrations();
@@ -83,12 +84,6 @@ export class DiscoveryServices extends GenericEditableConfigList<
8384
return (serviceReg?.libraries ?? []).filter((l) => l.status === "success");
8485
}
8586

86-
protected getAssociatedItems(
87-
item: DiscoveryServiceData
88-
): Array<any> | undefined {
89-
return this.registeredLibraries(item);
90-
}
91-
9287
protected formatAssociatedCount(count: number): string {
9388
return count === 0
9489
? "no registered libraries"
@@ -99,8 +94,9 @@ export class DiscoveryServices extends GenericEditableConfigList<
9994

10095
protected getAssociatedEntries(
10196
item: DiscoveryServiceData
102-
): Array<{ label: string; suffix?: string; href?: string }> {
103-
const registered = this.registeredLibraries(item) ?? [];
97+
): Array<{ label: string; suffix?: string; href?: string }> | undefined {
98+
const registered = this.registeredLibraries(item);
99+
if (registered === undefined) return undefined;
104100
const allLibraries = this.props.data?.allLibraries ?? [];
105101
return registered.map((lib) => {
106102
const meta = allLibraries.find((l) => l.short_name === lib.short_name);
@@ -113,8 +109,8 @@ export class DiscoveryServices extends GenericEditableConfigList<
113109
});
114110
}
115111

116-
UNSAFE_componentWillMount() {
117-
super.UNSAFE_componentWillMount();
112+
componentDidMount() {
113+
super.componentDidMount();
118114
if (this.props.fetchLibraryRegistrations) {
119115
this.props.fetchLibraryRegistrations();
120116
}

0 commit comments

Comments
 (0)