-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(release): automatic release v1.1.0
- Loading branch information
Showing
106 changed files
with
5,116 additions
and
2,498 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
22.13.0 | ||
22.13.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
apps/nextjs/src/components/board/items/actions/create-item.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import type { Modify } from "@homarr/common/types"; | ||
import { createId } from "@homarr/db/client"; | ||
import type { WidgetKind } from "@homarr/definitions"; | ||
|
||
import type { Board, DynamicSection, EmptySection, Item } from "~/app/[locale]/boards/_types"; | ||
import { getFirstEmptyPosition } from "./empty-position"; | ||
|
||
export interface CreateItemInput { | ||
kind: WidgetKind; | ||
} | ||
|
||
export const createItemCallback = | ||
({ kind }: CreateItemInput) => | ||
(previous: Board): Board => { | ||
const firstSection = previous.sections | ||
.filter((section): section is EmptySection => section.kind === "empty") | ||
.sort((sectionA, sectionB) => sectionA.yOffset - sectionB.yOffset) | ||
.at(0); | ||
|
||
if (!firstSection) return previous; | ||
|
||
const dynamicSectionsOfFirstSection = previous.sections.filter( | ||
(section): section is DynamicSection => section.kind === "dynamic" && section.parentSectionId === firstSection.id, | ||
); | ||
const elements = [...firstSection.items, ...dynamicSectionsOfFirstSection]; | ||
const emptyPosition = getFirstEmptyPosition(elements, previous.columnCount); | ||
|
||
if (!emptyPosition) { | ||
console.error("Your board is full"); | ||
return previous; | ||
} | ||
|
||
const widget = { | ||
id: createId(), | ||
kind, | ||
options: {}, | ||
width: 1, | ||
height: 1, | ||
...emptyPosition, | ||
integrationIds: [], | ||
advancedOptions: { | ||
customCssClasses: [], | ||
}, | ||
} satisfies Modify< | ||
Item, | ||
{ | ||
kind: WidgetKind; | ||
} | ||
>; | ||
|
||
return { | ||
...previous, | ||
sections: previous.sections.map((section) => { | ||
// Return same section if item is not in it | ||
if (section.id !== firstSection.id) return section; | ||
return { | ||
...section, | ||
items: section.items.concat(widget), | ||
}; | ||
}), | ||
}; | ||
}; |
Oops, something went wrong.