mirror of
https://github.com/ajnart/homarr.git
synced 2026-02-26 16:30:57 +01:00
fix: import sidebar issues (#1712)
This commit is contained in:
@@ -7,12 +7,17 @@ import { createDbInsertCollection } from "./common";
|
||||
|
||||
export const createIntegrationInsertCollection = (
|
||||
preparedIntegrations: PreparedIntegration[],
|
||||
encryptionToken: string | null,
|
||||
encryptionToken: string | null | undefined,
|
||||
) => {
|
||||
const insertCollection = createDbInsertCollection(["integrations", "integrationSecrets"]);
|
||||
|
||||
if (preparedIntegrations.length === 0) {
|
||||
return insertCollection;
|
||||
}
|
||||
|
||||
logger.info(`Preparing integrations for insert collection count=${preparedIntegrations.length}`);
|
||||
|
||||
if (encryptionToken === null) {
|
||||
if (encryptionToken === null || encryptionToken === undefined) {
|
||||
logger.debug("Skipping integration decryption due to missing token");
|
||||
return insertCollection;
|
||||
}
|
||||
|
||||
@@ -6,12 +6,19 @@ import { mapAndDecryptUsers } from "../../mappers/map-user";
|
||||
import type { OldmarrImportUser } from "../../user-schema";
|
||||
import { createDbInsertCollection } from "./common";
|
||||
|
||||
export const createUserInsertCollection = (importUsers: OldmarrImportUser[], encryptionToken: string | null) => {
|
||||
export const createUserInsertCollection = (
|
||||
importUsers: OldmarrImportUser[],
|
||||
encryptionToken: string | null | undefined,
|
||||
) => {
|
||||
const insertCollection = createDbInsertCollection(["users", "groups", "groupMembers", "groupPermissions"]);
|
||||
|
||||
if (importUsers.length === 0) {
|
||||
return insertCollection;
|
||||
}
|
||||
|
||||
logger.info(`Preparing users for insert collection count=${importUsers.length}`);
|
||||
|
||||
if (encryptionToken === null) {
|
||||
if (encryptionToken === null || encryptionToken === undefined) {
|
||||
logger.debug("Skipping user decryption due to missing token");
|
||||
return insertCollection;
|
||||
}
|
||||
|
||||
@@ -20,5 +20,5 @@ export const importInitialOldmarrInputSchema = zfd.formData({
|
||||
const map = boardSelectionMapSchema.parse(SuperJSON.parse(value));
|
||||
return map;
|
||||
}),
|
||||
token: zfd.text().nullable(),
|
||||
token: zfd.text().nullable().optional(),
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { decryptSecretWithKey } from "@homarr/common/server";
|
||||
|
||||
export const ensureValidTokenOrThrow = (checksum: string | undefined, encryptionToken: string | null) => {
|
||||
export const ensureValidTokenOrThrow = (checksum: string | undefined, encryptionToken: string | null | undefined) => {
|
||||
if (!encryptionToken || !checksum) return;
|
||||
|
||||
const [first, second] = checksum.split("\n");
|
||||
|
||||
@@ -81,13 +81,26 @@ export const moveWidgetsAndAppsIfMerge = (
|
||||
}
|
||||
|
||||
if (configuration.sidebarBehaviour === "last-section") {
|
||||
if (old.settings.customization.layout.enabledLeftSidebar) {
|
||||
const areas = [...old.apps.map((app) => app.area), ...old.widgets.map((widget) => widget.area)];
|
||||
if (
|
||||
old.settings.customization.layout.enabledLeftSidebar ||
|
||||
areas.some((area) => area.type === "sidebar" && area.properties.location === "left")
|
||||
) {
|
||||
offset = moveWidgetsAndAppsInLeftSidebar(old, firstId, offset, configuration.screenSize);
|
||||
}
|
||||
|
||||
if (old.settings.customization.layout.enabledRightSidebar) {
|
||||
if (
|
||||
old.settings.customization.layout.enabledRightSidebar ||
|
||||
areas.some((area) => area.type === "sidebar" && area.properties.location === "right")
|
||||
) {
|
||||
moveWidgetsAndAppsInRightSidebar(old, firstId, offset, configuration.screenSize);
|
||||
}
|
||||
} else {
|
||||
// Remove all widgets and apps in the sidebar
|
||||
return {
|
||||
apps: old.apps.filter((app) => app.area.type !== "sidebar"),
|
||||
widgets: old.widgets.filter((app) => app.area.type !== "sidebar"),
|
||||
};
|
||||
}
|
||||
|
||||
return { apps: old.apps, widgets: old.widgets };
|
||||
|
||||
@@ -69,7 +69,7 @@ export const oldmarrAppSchema = z
|
||||
behaviour: appBehaviourSchema,
|
||||
network: appNetworkSchema,
|
||||
appearance: appAppearanceSchema,
|
||||
integration: appIntegrationSchema.optional(),
|
||||
integration: appIntegrationSchema.optional().nullable(),
|
||||
})
|
||||
.and(tileBaseSchema);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user