Skip to content

Commit 0b5af06

Browse files
committed
feat: exclude Host from specific Internal Squads
1 parent 09d90ab commit 0b5af06

File tree

8 files changed

+64
-11
lines changed

8 files changed

+64
-11
lines changed

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"@monaco-editor/react": "^4.7.0",
6060
"@noble/post-quantum": "^0.5.2",
6161
"@paralleldrive/cuid2": "2.2.2",
62-
"@remnawave/backend-contract": "2.3.14",
62+
"@remnawave/backend-contract": "2.3.16",
6363
"@simplewebauthn/browser": "^13.2.2",
6464
"@stablelib/base64": "^2.0.1",
6565
"@stablelib/x25519": "^2.0.1",

public/locales/en/remnawave.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,9 @@
424424
"select-a-xray-json-template": "Select a Xray JSON Template",
425425
"xray-json-template": "Xray JSON Template",
426426
"override-the-xray-json-template": "Override the Xray JSON template which will be used for this host.",
427-
"vital-parameters": "Vital Parameters"
427+
"vital-parameters": "Vital Parameters",
428+
"exclude-this-host-from-specific-internal-squads": "Exclude this host from specific Internal Squads",
429+
"excluded-internal-squads": "Excluded Internal Squads"
428430
},
429431
"base-node-form": {
430432
"country": "Country",
@@ -1825,4 +1827,4 @@
18251827
}
18261828
}
18271829
}
1828-
}
1830+
}

src/pages/dashboard/hosts/ui/connectors/hosts.page.connector.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
useGetConfigProfiles,
66
useGetHosts,
77
useGetHostTags,
8+
useGetInternalSquads,
89
useGetNodes,
910
useGetSubscriptionTemplates
1011
} from '@shared/api/hooks'
@@ -14,6 +15,7 @@ import { queryClient } from '@shared/api'
1415

1516
export function HostsPageConnector() {
1617
const { data: hosts, isLoading: isHostsLoading } = useGetHosts()
18+
const { isLoading: isInternalSquadsLoading } = useGetInternalSquads()
1719
const { data: configProfiles, isLoading: isConfigProfilesLoading } = useGetConfigProfiles()
1820
const { data: hostTags, isLoading: isHostTagsLoading } = useGetHostTags()
1921
const { isLoading: isNodesLoading } = useGetNodes()
@@ -39,7 +41,8 @@ export function HostsPageConnector() {
3941
isHostsLoading ||
4042
isHostTagsLoading ||
4143
isNodesLoading ||
42-
isSubscriptionTemplatesLoading
44+
isSubscriptionTemplatesLoading ||
45+
isInternalSquadsLoading
4346
}
4447
/>
4548
)

src/shared/ui/forms/hosts/base-host-form/base-host-form.tsx

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import {
3838
SECURITY_LAYERS,
3939
UpdateHostCommand
4040
} from '@remnawave/backend-contract'
41-
import { TbCloudNetwork, TbEye, TbServer2 } from 'react-icons/tb'
41+
import { TbCirclesRelation, TbCloudNetwork, TbEye, TbServer2 } from 'react-icons/tb'
4242
import { HiQuestionMarkCircle } from 'react-icons/hi'
4343
import { useDisclosure } from '@mantine/hooks'
4444
import { useTranslation } from 'react-i18next'
@@ -75,6 +75,7 @@ export const BaseHostForm = <T extends CreateHostCommand.Request | UpdateHostCom
7575
isSubmitting,
7676
handleCloneHost,
7777
nodes,
78+
internalSquads,
7879
subscriptionTemplates
7980
} = props
8081

@@ -466,6 +467,43 @@ export const BaseHostForm = <T extends CreateHostCommand.Request | UpdateHostCom
466467
searchable
467468
{...form.getInputProps('nodes')}
468469
/>
470+
471+
<MultiSelect
472+
clearable
473+
clearButtonProps={{
474+
size: 'xs'
475+
}}
476+
data={internalSquads.map((internalSquad) => ({
477+
label: internalSquad.name,
478+
value: internalSquad.uuid
479+
}))}
480+
description={t(
481+
'base-host-form.exclude-this-host-from-specific-internal-squads'
482+
)}
483+
inputWrapperOrder={[
484+
'label',
485+
'input',
486+
'description',
487+
'error'
488+
]}
489+
key={form.key('excludedInternalSquads')}
490+
label={t('base-host-form.excluded-internal-squads')}
491+
leftSection={<TbCirclesRelation size={16} />}
492+
renderOption={(item) => {
493+
return (
494+
<Checkbox
495+
aria-hidden
496+
checked={item.checked}
497+
label={item.option.label}
498+
onChange={() => {}}
499+
style={{ pointerEvents: 'none' }}
500+
tabIndex={-1}
501+
/>
502+
)
503+
}}
504+
searchable
505+
{...form.getInputProps('excludedInternalSquads')}
506+
/>
469507
</Stack>
470508
</Fieldset>
471509
)}

src/shared/ui/forms/hosts/base-host-form/interfaces/iprops.interface.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
CreateHostCommand,
33
GetAllNodesCommand,
44
GetConfigProfilesCommand,
5+
GetInternalSquadsCommand,
56
GetSubscriptionTemplatesCommand,
67
UpdateHostCommand
78
} from '@remnawave/backend-contract'
@@ -13,6 +14,7 @@ export interface IProps<T extends CreateHostCommand.Request | UpdateHostCommand.
1314
form: UseFormReturnType<T>
1415
handleCloneHost?: () => void
1516
handleSubmit: () => void
17+
internalSquads: GetInternalSquadsCommand.Response['response']['internalSquads']
1618
isSubmitting: boolean
1719
nodes: GetAllNodesCommand.Response['response']
1820
setAdvancedOpened: (value: boolean) => void

src/widgets/dashboard/hosts/create-host-modal/create-host-modal.widget.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
QueryKeys,
1111
useCreateHost,
1212
useGetConfigProfiles,
13+
useGetInternalSquads,
1314
useGetNodes,
1415
useGetSubscriptionTemplates
1516
} from '@shared/api/hooks'
@@ -25,6 +26,7 @@ export const CreateHostModalWidget = () => {
2526

2627
const { data: configProfiles } = useGetConfigProfiles()
2728
const { data: nodes } = useGetNodes()
29+
const { data: internalSquads } = useGetInternalSquads()
2830
const { data: templates } = useGetSubscriptionTemplates()
2931

3032
const [advancedOpened, setAdvancedOpened] = useState(false)
@@ -123,6 +125,7 @@ export const CreateHostModalWidget = () => {
123125
configProfiles={configProfiles?.configProfiles ?? []}
124126
form={form}
125127
handleSubmit={handleSubmit}
128+
internalSquads={internalSquads?.internalSquads ?? []}
126129
isSubmitting={isCreateHostPending}
127130
nodes={nodes!}
128131
setAdvancedOpened={setAdvancedOpened}

src/widgets/dashboard/hosts/edit-host-modal/edit-host-modal.widget.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
QueryKeys,
1313
useCreateHost,
1414
useGetConfigProfiles,
15+
useGetInternalSquads,
1516
useGetNodes,
1617
useGetSubscriptionTemplates,
1718
useUpdateHost
@@ -32,6 +33,7 @@ export const EditHostModalWidget = memo(() => {
3233
const { data: configProfiles } = useGetConfigProfiles()
3334
const { data: nodes } = useGetNodes()
3435
const { data: templates } = useGetSubscriptionTemplates()
36+
const { data: internalSquads } = useGetInternalSquads()
3537

3638
const form = useForm<UpdateHostCommand.Request>({
3739
name: 'edit-host-form',
@@ -130,7 +132,8 @@ export const EditHostModalWidget = memo(() => {
130132
shuffleHost: host.shuffleHost ?? undefined,
131133
mihomoX25519: host.mihomoX25519 ?? undefined,
132134
nodes: host.nodes ?? undefined,
133-
xrayJsonTemplateUuid: host.xrayJsonTemplateUuid ?? undefined
135+
xrayJsonTemplateUuid: host.xrayJsonTemplateUuid ?? undefined,
136+
excludedInternalSquads: host.excludedInternalSquads ?? undefined
134137
})
135138
}
136139
}, [host, configProfiles])
@@ -276,7 +279,8 @@ export const EditHostModalWidget = memo(() => {
276279
vlessRouteId: host.vlessRouteId ?? undefined,
277280
allowInsecure: host.allowInsecure ?? undefined,
278281
nodes: host.nodes ?? undefined,
279-
xrayJsonTemplateUuid: host.xrayJsonTemplateUuid ?? undefined
282+
xrayJsonTemplateUuid: host.xrayJsonTemplateUuid ?? undefined,
283+
excludedInternalSquads: host.excludedInternalSquads ?? undefined
280284
}
281285
})
282286
}
@@ -299,6 +303,7 @@ export const EditHostModalWidget = memo(() => {
299303
form={form}
300304
handleCloneHost={handleCloneHost}
301305
handleSubmit={handleSubmit}
306+
internalSquads={internalSquads?.internalSquads ?? []}
302307
isSubmitting={isUpdateHostPending}
303308
nodes={nodes!}
304309
setAdvancedOpened={setAdvancedOpened}

0 commit comments

Comments
 (0)