4242</template >
4343
4444<script lang="ts" setup>
45- import { cloneDeep } from ' es-toolkit/compat' ;
45+ import { cloneDeep , includes } from ' es-toolkit/compat' ;
4646import type { FetchError } from ' ofetch' ;
4747import { Severity , type FileTree } from ' ~/shared/file-tree' ;
4848import { Dropdown , gen_map , gen_targets } from ' ~/shared/file-tree/dropdown' ;
@@ -59,7 +59,7 @@ const label = (a: string) => a;
5959const selected = reactive <{
6060 user: string ,
6161 repo: string ,
62- target: string ,
62+ target: string | null ,
6363 pkg: string | null ,
6464 features: string | null ,
6565 checker: string | null ,
@@ -89,6 +89,10 @@ githubFetch<UserRepo>({ path: "ui/user_repo.json" })
8989// Init filters.
9090const users = computed (() => Object .keys (user_repo .value ).sort ());
9191const repos = computed (() => user_repo .value [selected .user ]);
92+ const targets = computed <DropDownOptions >(() => {
93+ const t = basic .value ?.targets ;
94+ return t ? gen_targets (t ) : emptyOptions ();
95+ });
9296
9397const lockURL = ref (false );
9498type Params = {
@@ -121,22 +125,17 @@ watch(user_repo, val => {
121125// Update got state.
122126watch (() => ({ user: selected .user , repo: selected .repo , target: selected .target }),
123127 ({ user , repo , target }) => {
124- if (user && repos .value .findIndex (r => r === repo ) !== - 1 ) {
125- const target_ = target || ALL_TARGETS ;
126- get (` ui/repos/${user }/${repo }/${target_ }.json ` );
128+ if (user && includes (repos .value , repo )) {
129+ get (` ui/repos/${user }/${repo }/${target || ALL_TARGETS }.json ` );
127130 getBasic (` ui/repos/${user }/${repo }/basic.json ` );
128131 } else if (user && repos .value [0 ]) {
129132 // repo is not present, maybe user is selected, but not for repo
130133 selected .repo = repos .value [0 ];
134+ selected .target = ALL_TARGETS ;
131135 }
132136 }
133137);
134138
135- const targets = computed <DropDownOptions >(() => {
136- const t = basic .value ?.targets ;
137- return t ? gen_targets (t ) : emptyOptions ();
138- });
139-
140139const pkgs = ref (emptyOptions ());
141140const kinds = ref (emptyOptions ());
142141const checkers = ref (emptyOptions ());
0 commit comments