mirror of
https://github.com/fosrl/pangolin.git
synced 2026-01-28 22:00:51 +00:00
hide sites inputs on clients
This commit is contained in:
@@ -75,14 +75,14 @@ export default function GeneralPage() {
|
||||
const res = await api.get<AxiosResponse<ListSitesResponse>>(
|
||||
`/org/${client?.orgId}/sites/`
|
||||
);
|
||||
|
||||
|
||||
const availableSites = res.data.data.sites
|
||||
.filter((s) => s.type === "newt" && s.subnet)
|
||||
.map((site) => ({
|
||||
id: site.siteId.toString(),
|
||||
text: site.name
|
||||
}));
|
||||
|
||||
|
||||
setSites(availableSites);
|
||||
|
||||
// Filter sites to only include those assigned to the client
|
||||
@@ -173,39 +173,6 @@ export default function GeneralPage() {
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="siteIds"
|
||||
render={(field) => (
|
||||
<FormItem className="flex flex-col">
|
||||
<FormLabel>{t("sites")}</FormLabel>
|
||||
<TagInput
|
||||
{...field}
|
||||
activeTagIndex={activeSitesTagIndex}
|
||||
setActiveTagIndex={setActiveSitesTagIndex}
|
||||
placeholder={t("selectSites")}
|
||||
size="sm"
|
||||
tags={form.getValues().siteIds}
|
||||
setTags={(newTags) => {
|
||||
form.setValue(
|
||||
"siteIds",
|
||||
newTags as [Tag, ...Tag[]]
|
||||
);
|
||||
}}
|
||||
enableAutocomplete={true}
|
||||
autocompleteOptions={sites}
|
||||
allowDuplicates={false}
|
||||
restrictTagsToAutocompleteOptions={true}
|
||||
sortTags={true}
|
||||
/>
|
||||
<FormDescription>
|
||||
{t("sitesDescription")}
|
||||
</FormDescription>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</form>
|
||||
</Form>
|
||||
</SettingsSectionForm>
|
||||
@@ -224,4 +191,4 @@ export default function GeneralPage() {
|
||||
</SettingsSection>
|
||||
</SettingsContainer>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,10 +99,7 @@ export default function Page() {
|
||||
id: z.string(),
|
||||
text: z.string()
|
||||
})
|
||||
)
|
||||
.refine((val) => val.length > 0, {
|
||||
message: t("siteRequired")
|
||||
}),
|
||||
),
|
||||
subnet: z.string().ip().min(1, {
|
||||
message: t("subnetRequired")
|
||||
})
|
||||
@@ -293,18 +290,18 @@ export default function Page() {
|
||||
|
||||
// Fetch available sites
|
||||
|
||||
const res = await api.get<AxiosResponse<ListSitesResponse>>(
|
||||
`/org/${orgId}/sites/`
|
||||
);
|
||||
const sites = res.data.data.sites.filter(
|
||||
(s) => s.type === "newt" && s.subnet
|
||||
);
|
||||
setSites(
|
||||
sites.map((site) => ({
|
||||
id: site.siteId.toString(),
|
||||
text: site.name
|
||||
}))
|
||||
);
|
||||
// const res = await api.get<AxiosResponse<ListSitesResponse>>(
|
||||
// `/org/${orgId}/sites/`
|
||||
// );
|
||||
// const sites = res.data.data.sites.filter(
|
||||
// (s) => s.type === "newt" && s.subnet
|
||||
// );
|
||||
// setSites(
|
||||
// sites.map((site) => ({
|
||||
// id: site.siteId.toString(),
|
||||
// text: site.name
|
||||
// }))
|
||||
// );
|
||||
|
||||
let olmVersion = "latest";
|
||||
|
||||
@@ -468,60 +465,60 @@ export default function Page() {
|
||||
)}
|
||||
/>
|
||||
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="siteIds"
|
||||
render={(field) => (
|
||||
<FormItem className="flex flex-col">
|
||||
<FormLabel>
|
||||
{t("sites")}
|
||||
</FormLabel>
|
||||
<TagInput
|
||||
{...field}
|
||||
activeTagIndex={
|
||||
activeSitesTagIndex
|
||||
}
|
||||
setActiveTagIndex={
|
||||
setActiveSitesTagIndex
|
||||
}
|
||||
placeholder={t("selectSites")}
|
||||
size="sm"
|
||||
tags={
|
||||
form.getValues()
|
||||
.siteIds
|
||||
}
|
||||
setTags={(
|
||||
olmags
|
||||
) => {
|
||||
form.setValue(
|
||||
"siteIds",
|
||||
olmags as [
|
||||
Tag,
|
||||
...Tag[]
|
||||
]
|
||||
);
|
||||
}}
|
||||
enableAutocomplete={
|
||||
true
|
||||
}
|
||||
autocompleteOptions={
|
||||
sites
|
||||
}
|
||||
allowDuplicates={
|
||||
false
|
||||
}
|
||||
restrictTagsToAutocompleteOptions={
|
||||
true
|
||||
}
|
||||
sortTags={true}
|
||||
/>
|
||||
<FormDescription>
|
||||
{t("sitesDescription")}
|
||||
</FormDescription>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
{/* <FormField */}
|
||||
{/* control={form.control} */}
|
||||
{/* name="siteIds" */}
|
||||
{/* render={(field) => ( */}
|
||||
{/* <FormItem className="flex flex-col"> */}
|
||||
{/* <FormLabel> */}
|
||||
{/* {t("sites")} */}
|
||||
{/* </FormLabel> */}
|
||||
{/* <TagInput */}
|
||||
{/* {...field} */}
|
||||
{/* activeTagIndex={ */}
|
||||
{/* activeSitesTagIndex */}
|
||||
{/* } */}
|
||||
{/* setActiveTagIndex={ */}
|
||||
{/* setActiveSitesTagIndex */}
|
||||
{/* } */}
|
||||
{/* placeholder={t("selectSites")} */}
|
||||
{/* size="sm" */}
|
||||
{/* tags={ */}
|
||||
{/* form.getValues() */}
|
||||
{/* .siteIds */}
|
||||
{/* } */}
|
||||
{/* setTags={( */}
|
||||
{/* olmags */}
|
||||
{/* ) => { */}
|
||||
{/* form.setValue( */}
|
||||
{/* "siteIds", */}
|
||||
{/* olmags as [ */}
|
||||
{/* Tag, */}
|
||||
{/* ...Tag[] */}
|
||||
{/* ] */}
|
||||
{/* ); */}
|
||||
{/* }} */}
|
||||
{/* enableAutocomplete={ */}
|
||||
{/* true */}
|
||||
{/* } */}
|
||||
{/* autocompleteOptions={ */}
|
||||
{/* sites */}
|
||||
{/* } */}
|
||||
{/* allowDuplicates={ */}
|
||||
{/* false */}
|
||||
{/* } */}
|
||||
{/* restrictTagsToAutocompleteOptions={ */}
|
||||
{/* true */}
|
||||
{/* } */}
|
||||
{/* sortTags={true} */}
|
||||
{/* /> */}
|
||||
{/* <FormDescription> */}
|
||||
{/* {t("sitesDescription")} */}
|
||||
{/* </FormDescription> */}
|
||||
{/* <FormMessage /> */}
|
||||
{/* </FormItem> */}
|
||||
{/* )} */}
|
||||
{/* /> */}
|
||||
</form>
|
||||
</Form>
|
||||
</SettingsSectionForm>
|
||||
|
||||
Reference in New Issue
Block a user