hide sites inputs on clients

This commit is contained in:
miloschwartz
2025-11-05 10:37:52 -08:00
parent 2274404324
commit c73f8c88f7
2 changed files with 70 additions and 106 deletions

View File

@@ -173,39 +173,6 @@ export default function GeneralPage() {
</FormItem> </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>
</Form> </Form>
</SettingsSectionForm> </SettingsSectionForm>

View File

@@ -99,10 +99,7 @@ export default function Page() {
id: z.string(), id: z.string(),
text: z.string() text: z.string()
}) })
) ),
.refine((val) => val.length > 0, {
message: t("siteRequired")
}),
subnet: z.string().ip().min(1, { subnet: z.string().ip().min(1, {
message: t("subnetRequired") message: t("subnetRequired")
}) })
@@ -293,18 +290,18 @@ export default function Page() {
// Fetch available sites // Fetch available sites
const res = await api.get<AxiosResponse<ListSitesResponse>>( // const res = await api.get<AxiosResponse<ListSitesResponse>>(
`/org/${orgId}/sites/` // `/org/${orgId}/sites/`
); // );
const sites = res.data.data.sites.filter( // const sites = res.data.data.sites.filter(
(s) => s.type === "newt" && s.subnet // (s) => s.type === "newt" && s.subnet
); // );
setSites( // setSites(
sites.map((site) => ({ // sites.map((site) => ({
id: site.siteId.toString(), // id: site.siteId.toString(),
text: site.name // text: site.name
})) // }))
); // );
let olmVersion = "latest"; let olmVersion = "latest";
@@ -468,60 +465,60 @@ export default function Page() {
)} )}
/> />
<FormField {/* <FormField */}
control={form.control} {/* control={form.control} */}
name="siteIds" {/* name="siteIds" */}
render={(field) => ( {/* render={(field) => ( */}
<FormItem className="flex flex-col"> {/* <FormItem className="flex flex-col"> */}
<FormLabel> {/* <FormLabel> */}
{t("sites")} {/* {t("sites")} */}
</FormLabel> {/* </FormLabel> */}
<TagInput {/* <TagInput */}
{...field} {/* {...field} */}
activeTagIndex={ {/* activeTagIndex={ */}
activeSitesTagIndex {/* activeSitesTagIndex */}
} {/* } */}
setActiveTagIndex={ {/* setActiveTagIndex={ */}
setActiveSitesTagIndex {/* setActiveSitesTagIndex */}
} {/* } */}
placeholder={t("selectSites")} {/* placeholder={t("selectSites")} */}
size="sm" {/* size="sm" */}
tags={ {/* tags={ */}
form.getValues() {/* form.getValues() */}
.siteIds {/* .siteIds */}
} {/* } */}
setTags={( {/* setTags={( */}
olmags {/* olmags */}
) => { {/* ) => { */}
form.setValue( {/* form.setValue( */}
"siteIds", {/* "siteIds", */}
olmags as [ {/* olmags as [ */}
Tag, {/* Tag, */}
...Tag[] {/* ...Tag[] */}
] {/* ] */}
); {/* ); */}
}} {/* }} */}
enableAutocomplete={ {/* enableAutocomplete={ */}
true {/* true */}
} {/* } */}
autocompleteOptions={ {/* autocompleteOptions={ */}
sites {/* sites */}
} {/* } */}
allowDuplicates={ {/* allowDuplicates={ */}
false {/* false */}
} {/* } */}
restrictTagsToAutocompleteOptions={ {/* restrictTagsToAutocompleteOptions={ */}
true {/* true */}
} {/* } */}
sortTags={true} {/* sortTags={true} */}
/> {/* /> */}
<FormDescription> {/* <FormDescription> */}
{t("sitesDescription")} {/* {t("sitesDescription")} */}
</FormDescription> {/* </FormDescription> */}
<FormMessage /> {/* <FormMessage /> */}
</FormItem> {/* </FormItem> */}
)} {/* )} */}
/> {/* /> */}
</form> </form>
</Form> </Form>
</SettingsSectionForm> </SettingsSectionForm>