Skip to content

Commit

Permalink
[dagit] Display repositories in a stable order (#7518)
Browse files Browse the repository at this point in the history
  • Loading branch information
bengotow committed Apr 21, 2022
1 parent 45d9c92 commit 1f1e233
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions js_modules/dagit/packages/core/src/workspace/WorkspaceContext.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {ApolloQueryResult, gql, useQuery} from '@apollo/client';
import sortBy from 'lodash/sortBy';
import * as React from 'react';

import {AppContext} from '../app/AppContext';
Expand Down Expand Up @@ -153,16 +154,21 @@ const useWorkspaceState = (): WorkspaceState => {
return {allRepos, error: workspaceOrError};
}

allRepos = workspaceOrError.locationEntries.reduce((accum, locationEntry) => {
if (locationEntry.locationOrLoadError?.__typename !== 'RepositoryLocation') {
return accum;
}
const repositoryLocation = locationEntry.locationOrLoadError;
const reposForLocation = repositoryLocation.repositories.map((repository) => {
return {repository, repositoryLocation};
});
return [...accum, ...reposForLocation];
}, [] as DagsterRepoOption[]);
allRepos = sortBy(
workspaceOrError.locationEntries.reduce((accum, locationEntry) => {
if (locationEntry.locationOrLoadError?.__typename !== 'RepositoryLocation') {
return accum;
}
const repositoryLocation = locationEntry.locationOrLoadError;
const reposForLocation = repositoryLocation.repositories.map((repository) => {
return {repository, repositoryLocation};
});
return [...accum, ...reposForLocation];
}, [] as DagsterRepoOption[]),

// Sort by repo location, then by repo
(r) => `${r.repositoryLocation.name}:${r.repository.name}`,
);

return {error: null, allRepos};
}, [workspaceOrError]);
Expand Down

0 comments on commit 1f1e233

Please sign in to comment.