Skip to content

Commit

Permalink
feat(core): resources across eventcatalog are now ordered by name (#1060
Browse files Browse the repository at this point in the history
)

* feat(core): resources across eventcatalog are now ordered by name

* Create moody-ligers-retire.md
  • Loading branch information
boyney123 authored Dec 19, 2024
1 parent 8bd0fdf commit a60e94f
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/moody-ligers-retire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@eventcatalog/core": patch
---

feat(core): resources across eventcatalog are now ordered by name
5 changes: 5 additions & 0 deletions eventcatalog/src/utils/channels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,10 @@ export const getChannels = async ({ getAllVersions = true }: Props = {}): Promis
};
});

// order them by the name of the channel
cachedChannels[cacheKey].sort((a, b) => {
return (a.data.name || a.data.id).localeCompare(b.data.name || b.data.id);
});

return cachedChannels[cacheKey];
};
5 changes: 5 additions & 0 deletions eventcatalog/src/utils/collections/domains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ export const getDomains = async ({ getAllVersions = true }: Props = {}): Promise
};
});

// order them by the name of the domain
cachedDomains[cacheKey].sort((a, b) => {
return (a.data.name || a.data.id).localeCompare(b.data.name || b.data.id);
});

return cachedDomains[cacheKey];
};

Expand Down
5 changes: 5 additions & 0 deletions eventcatalog/src/utils/collections/flows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,10 @@ export const getFlows = async ({ getAllVersions = true }: Props = {}): Promise<F
};
});

// order them by the name of the flow
cachedFlows[cacheKey].sort((a, b) => {
return (a.data.name || a.data.id).localeCompare(b.data.name || b.data.id);
});

return cachedFlows[cacheKey];
};
5 changes: 5 additions & 0 deletions eventcatalog/src/utils/collections/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ export const getServices = async ({ getAllVersions = true }: Props = {}): Promis
};
});

// order them by the name of the service
cachedServices[cacheKey].sort((a, b) => {
return (a.data.name || a.data.id).localeCompare(b.data.name || b.data.id);
});

return cachedServices[cacheKey];
};

Expand Down
5 changes: 5 additions & 0 deletions eventcatalog/src/utils/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,10 @@ export const getCommands = async ({ getAllVersions = true }: Props = {}): Promis
};
});

// order them by the name of the command
cachedCommands[cacheKey].sort((a, b) => {
return (a.data.name || a.data.id).localeCompare(b.data.name || b.data.id);
});

return cachedCommands[cacheKey];
};
5 changes: 5 additions & 0 deletions eventcatalog/src/utils/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,10 @@ export const getEvents = async ({ getAllVersions = true }: Props = {}): Promise<
};
});

// order them by the name of the event
cachedEvents[cacheKey].sort((a, b) => {
return (a.data.name || a.data.id).localeCompare(b.data.name || b.data.id);
});

return cachedEvents[cacheKey];
};
5 changes: 5 additions & 0 deletions eventcatalog/src/utils/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,10 @@ export const getQueries = async ({ getAllVersions = true }: Props = {}): Promise
};
});

// order them by the name of the query
cachedQueries[cacheKey].sort((a, b) => {
return (a.data.name || a.data.id).localeCompare(b.data.name || b.data.id);
});

return cachedQueries[cacheKey];
};
5 changes: 5 additions & 0 deletions eventcatalog/src/utils/teams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,10 @@ export const getTeams = async (): Promise<Team[]> => {
};
});

// order them by the name of the team
cachedTeams.sort((a, b) => {
return (a.data.name || a.data.id).localeCompare(b.data.name || b.data.id);
});

return cachedTeams;
};
9 changes: 8 additions & 1 deletion eventcatalog/src/utils/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const getUsers = async (): Promise<User[]> => {
return team.data.hidden !== true;
});

return users.map((user) => {
const mappedUsers = users.map((user) => {
const associatedTeams = teams.filter((team) => {
return team.data.members?.some((member) => member.id === user.data.id);
});
Expand Down Expand Up @@ -66,4 +66,11 @@ export const getUsers = async (): Promise<User[]> => {
},
};
});

// order them by the name of the user
mappedUsers.sort((a, b) => {
return (a.data.name || a.data.id).localeCompare(b.data.name || b.data.id);
});

return mappedUsers;
};

0 comments on commit a60e94f

Please sign in to comment.