Skip to content

Commit e2dbcaf

Browse files
authored
feat: minor change in actors dropdown (#57)
* feat: minor change in actors dropdown * fix: use actor name only if title is not present
1 parent c0c5212 commit e2dbcaf

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

nodes/Apify/resources/actorResourceLocator.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,16 @@ export async function listActors(
114114
): Promise<INodeListSearchResult> {
115115
const actorSource = this.getNodeParameter('actorSource', 'recentlyUsed') as string;
116116

117-
const mapToN8nResult = (actor: any) => ({
118-
name: actor.title || actor.name,
119-
value: actor.id,
120-
url: `https://console.apify.com/actors/${actor.id}/input`,
121-
description: actor.description || actor.name,
122-
});
117+
const mapToN8nSelectOption = (actor: any) => {
118+
const optionName = actor.title ? `${actor.title} (${actor.name})` : actor.name;
119+
120+
return {
121+
name: optionName,
122+
value: actor.id,
123+
url: `https://console.apify.com/actors/${actor.id}/input`,
124+
description: actor.description || actor.name,
125+
};
126+
};
123127

124128
const {
125129
data: { items: recentActors },
@@ -139,11 +143,11 @@ export async function listActors(
139143
(actor: any) => regex.test(actor.title || '') || regex.test(actor.name || ''),
140144
);
141145
return {
142-
results: filteredActors.map(mapToN8nResult),
146+
results: filteredActors.map(mapToN8nSelectOption),
143147
};
144148
}
145149
return {
146-
results: recentActors.map(mapToN8nResult),
150+
results: recentActors.map(mapToN8nSelectOption),
147151
};
148152
}
149153

@@ -159,10 +163,7 @@ export async function listActors(
159163
},
160164
});
161165

162-
const recentIds = recentActors.map((actor: any) => actor.id);
163-
const filtered = storeActors.filter((actor: any) => !recentIds.includes(actor.id));
164-
165166
return {
166-
results: filtered.map(mapToN8nResult),
167+
results: storeActors.map(mapToN8nSelectOption),
167168
};
168169
}

0 commit comments

Comments
 (0)