Skip to content

Commit

Permalink
Merge pull request #632 from ProteinsWebTeam/ts-table-tree
Browse files Browse the repository at this point in the history
Ts table tree
  • Loading branch information
gustavo-salazar authored Jul 4, 2024
2 parents eeb9bfa + 52baa2d commit d3bf04e
Show file tree
Hide file tree
Showing 14 changed files with 806 additions and 853 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ const ExtraTaxonomyOption = ({
<TaxonomyOption
taxId={taxId}
checked={!!checked}
title={data?.payload?.metadata?.name?.name || taxId}
title={
(typeof data?.payload?.metadata?.name === 'string'
? data?.payload?.metadata?.name
: data?.payload?.metadata?.name?.name) || taxId
}
onChange={onChange}
isStale={!!isStale}
loading={data!.loading}
Expand Down
40 changes: 40 additions & 0 deletions src/components/Table/views/Tree/DataProvider/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { PureComponent } from 'react';

type Props<Payload = unknown> = {
taxID?: string;
sendData: (taxID: string, payload: Payload) => void;
};
export interface DataProviderLoadedProps<Payload = unknown>
extends Props<Payload>,
LoadDataProps<Payload> {}

class DataProvider<Payload = unknown> extends PureComponent<
DataProviderLoadedProps<Payload>
> {
_sent: boolean = false;

componentDidMount() {
this._sendDataUpIfAny();
}

componentDidUpdate({ data }: DataProviderLoadedProps<Payload>) {
if (this.props.data?.payload !== data?.payload) this._sendDataUpIfAny();
}

_sendDataUpIfAny = () => {
if (this._sent) return;
const { taxID, data, sendData } = this.props;
if (!taxID) return;
const { loading, payload } = data || {};
if (!loading && payload) {
this._sent = true;
sendData(taxID, payload);
}
};

render() {
return null;
}
}

export default DataProvider;
Loading

0 comments on commit d3bf04e

Please sign in to comment.