Skip to content

Commit

Permalink
Sort pinned items by collection_position
Browse files Browse the repository at this point in the history
  • Loading branch information
tlrobinson committed Jun 14, 2018
1 parent 8e4a4e5 commit 9145799
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions frontend/src/metabase/components/CollectionLanding.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,16 @@ class DefaultLanding extends React.Component {
return <CollectionEmptyState />;
}

const [pinned, other] = _.partition(
const [pinned, unpinned] = _.partition(
items,
i => i.collection_position != null,
);

// sort the pinned items by collection_position
pinned.sort(
(a, b) => a.collection_position - b.collection_position,
);

return (
<Box>
{pinned.length > 0 ? (
Expand Down Expand Up @@ -234,17 +239,17 @@ class DefaultLanding extends React.Component {
</Box>
)}
</Flex>
{other.length > 0 ? (
{unpinned.length > 0 ? (
<PinnedDropArea pinIndex={null} margin={8}>
<Card
mb={selected.length > 0 ? 5 : 2}
style={{
position: "relative",
height: ROW_HEIGHT * other.length,
height: ROW_HEIGHT * unpinned.length,
}}
>
<VirtualizedList
items={other}
items={unpinned}
rowHeight={ROW_HEIGHT}
renderItem={({ item, index }) => (
<DraggableItem item={item} selection={selection}>
Expand Down

0 comments on commit 9145799

Please sign in to comment.