mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-10 15:35:55 +01:00
Fix AddToHomarr button
This commit is contained in:
@@ -16,8 +16,11 @@ import { useTranslation } from 'next-i18next';
|
|||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { TFunction } from 'react-i18next';
|
import { TFunction } from 'react-i18next';
|
||||||
import { v4 as uuidv4 } from 'uuid';
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
|
import { useConfigContext } from '../../../../../config/provider';
|
||||||
|
import { tryMatchService } from '../../../../../tools/addToHomarr';
|
||||||
import { openContextModalGeneric } from '../../../../../tools/mantineModalManagerExtensions';
|
import { openContextModalGeneric } from '../../../../../tools/mantineModalManagerExtensions';
|
||||||
import { AppType } from '../../../../../types/app';
|
import { AppType } from '../../../../../types/app';
|
||||||
|
import { appTileDefinition } from '../../../../Dashboard/Tiles/Apps/AppTile';
|
||||||
|
|
||||||
let t: TFunction<'modules/docker', undefined>;
|
let t: TFunction<'modules/docker', undefined>;
|
||||||
|
|
||||||
@@ -68,6 +71,8 @@ export interface ContainerActionBarProps {
|
|||||||
export default function ContainerActionBar({ selected, reload }: ContainerActionBarProps) {
|
export default function ContainerActionBar({ selected, reload }: ContainerActionBarProps) {
|
||||||
t = useTranslation('modules/docker').t;
|
t = useTranslation('modules/docker').t;
|
||||||
const [isLoading, setisLoading] = useState(false);
|
const [isLoading, setisLoading] = useState(false);
|
||||||
|
const { name: configName, config } = useConfigContext();
|
||||||
|
const getLowestWrapper = () => config?.wrappers.sort((a, b) => a.position - b.position)[0];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Group spacing="xs">
|
<Group spacing="xs">
|
||||||
@@ -158,16 +163,17 @@ export default function ContainerActionBar({ selected, reload }: ContainerAction
|
|||||||
radius="md"
|
radius="md"
|
||||||
disabled={selected.length === 0 || selected.length > 1}
|
disabled={selected.length === 0 || selected.length > 1}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
const app = tryMatchService(selected.at(0)!);
|
||||||
const containerUrl = `http://localhost:${selected[0].Ports[0].PublicPort}`;
|
const containerUrl = `http://localhost:${selected[0].Ports[0].PublicPort}`;
|
||||||
openContextModalGeneric<{ service: AppType }>({
|
openContextModalGeneric<{ app: AppType; allowAppNamePropagation: boolean }>({
|
||||||
modal: 'editService',
|
modal: 'editApp',
|
||||||
innerProps: {
|
innerProps: {
|
||||||
service: {
|
app: {
|
||||||
id: uuidv4(),
|
id: uuidv4(),
|
||||||
name: selected[0].Names[0],
|
name: app.name ? app.name : selected[0].Names[0].substring(1),
|
||||||
url: containerUrl,
|
url: containerUrl,
|
||||||
appearance: {
|
appearance: {
|
||||||
iconUrl: '/imgs/logo/logo.png', // TODO: find icon automatically
|
iconUrl: app.icon ? app.icon : '/imgs/logo/logo.png',
|
||||||
},
|
},
|
||||||
network: {
|
network: {
|
||||||
enabledStatusChecker: true,
|
enabledStatusChecker: true,
|
||||||
@@ -178,9 +184,9 @@ export default function ContainerActionBar({ selected, reload }: ContainerAction
|
|||||||
externalUrl: '',
|
externalUrl: '',
|
||||||
},
|
},
|
||||||
area: {
|
area: {
|
||||||
type: 'sidebar', // TODO: Set the wrapper automatically
|
type: 'wrapper',
|
||||||
properties: {
|
properties: {
|
||||||
location: 'right',
|
id: getLowestWrapper()?.id ?? 'default',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
shape: {
|
shape: {
|
||||||
@@ -189,8 +195,8 @@ export default function ContainerActionBar({ selected, reload }: ContainerAction
|
|||||||
y: 0,
|
y: 0,
|
||||||
},
|
},
|
||||||
size: {
|
size: {
|
||||||
height: 1,
|
width: appTileDefinition.minWidth,
|
||||||
width: 1,
|
height: appTileDefinition.minHeight,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
integration: {
|
integration: {
|
||||||
@@ -198,7 +204,9 @@ export default function ContainerActionBar({ selected, reload }: ContainerAction
|
|||||||
properties: [],
|
properties: [],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
allowAppNamePropagation: true,
|
||||||
},
|
},
|
||||||
|
size: 'xl',
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -102,6 +102,7 @@ export const portmap = [
|
|||||||
{ name: 'nzbget', value: '6789' },
|
{ name: 'nzbget', value: '6789' },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
//TODO: Fix this to be used in the docker add to homarr button
|
||||||
export const MatchingImages: {
|
export const MatchingImages: {
|
||||||
image: string;
|
image: string;
|
||||||
type: ServiceType;
|
type: ServiceType;
|
||||||
|
|||||||
Reference in New Issue
Block a user