Skip to content

Commit

Permalink
Show dataset sources with the same hash and different title (#1959)
Browse files Browse the repository at this point in the history
  • Loading branch information
korvin89 authored Dec 19, 2024
1 parent dc0c3a5 commit c6a6faf
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/ui/units/datasets/store/selectors/dataset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ export const connectionsSelector = (state: DatalensGlobalState) => {
});
};

const getSourceHashTitleId = <T extends {parameter_hash: string; title: string}>({
parameter_hash,
title,
}: T) => {
return `${parameter_hash}-${title}`;
};

export const sourcePrototypesSelector = (state: DatalensGlobalState) => {
const {
sourcePrototypes = [],
Expand All @@ -105,31 +112,30 @@ export const sourcePrototypesSelector = (state: DatalensGlobalState) => {

const availableSourcesMap = new Map(
sourcePrototypes.map((source) => {
const {parameter_hash: parameterHash} = source;

return [
parameterHash,
getSourceHashTitleId(source),
source as
| BaseSource
| {id?: string; isSource?: boolean; isConnectedWithAvatar?: boolean},
];
}),
);

const availableSourceAvatars = sourceAvatars.map(({source_id: sourceId}) => sourceId);

sources.filter(DatasetUtils.filterVirtual).forEach((source) => {
const {parameter_hash: parameterHash, id: sourceId} = source;

const sourcePrototype = availableSourcesMap.get(parameterHash);
const {id: sourceId} = source;
const sourceHashTitleId = getSourceHashTitleId(source);
const sourcePrototype = availableSourcesMap.get(sourceHashTitleId);

if (sourcePrototype) {
availableSourcesMap.set(parameterHash, {
availableSourcesMap.set(sourceHashTitleId, {
...sourcePrototype,
id: sourceId,
isSource: true,
});
} else {
availableSourcesMap.set(parameterHash, {
availableSourcesMap.set(sourceHashTitleId, {
...source,
isSource: true,
isConnectedWithAvatar: availableSourceAvatars.includes(sourceId),
Expand Down

0 comments on commit c6a6faf

Please sign in to comment.