fix(taglist-order): improve error handler when the order does not exists

This commit is contained in:
Joxit 2023-05-18 07:28:07 +02:00
parent 92584fc3da
commit c6dee14d79
No known key found for this signature in database
GPG Key ID: F526592B8E012263
4 changed files with 9 additions and 5 deletions

View File

@ -55,7 +55,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
filter-results="{ state.filter }"
on-authentication="{ onAuthentication }"
use-control-cache-header="{ truthy(props.useControlCacheHeader) }"
taglist-order="{ taglistOrderParser(props.taglistOrder) }"
taglist-order="{ props.taglistOrder }"
></tag-list>
</route>
<route path="{baseRoute}taghistory/(.*)">
@ -130,7 +130,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import { stripHttps, getRegistryServers, setRegistryServers, truthy, stringToArray } from '../scripts/utils';
import router from '../scripts/router';
import { loadTheme } from '../scripts/theme';
import { taglistOrderParser } from '../scripts/taglist-order';
export default {
components: {
@ -243,7 +242,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
version,
truthy,
stringToArray,
taglistOrderParser,
};
</script>
<style>

View File

@ -66,7 +66,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import Pagination from './pagination.riot';
import TagTable from './tag-table.riot';
import router from '../../scripts/router';
import { getTagComparator } from '../../scripts/taglist-order';
import { getTagComparator, taglistOrderParser } from '../../scripts/taglist-order';
export default {
components: {
@ -81,6 +81,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
asc: true,
page: router.getPageQueryParam() || 1,
};
try {
this.state.taglistOrder = taglistOrderParser(props.taglistOrder)
} catch(e) {
props.onNotify(e);
}
},
onMounted(props, state) {
this.display(props, state);

View File

@ -1,5 +1,6 @@
export class DockerRegistryUIError extends Error {
constructor(msg) {
super(msg);
this.isError = true;
}
}

View File

@ -20,7 +20,7 @@ export const taglistOrderVariants = (taglistOrder) => {
} else if (TAGLIST_ORDER_REGEX.test(taglistOrder)) {
return taglistOrder;
}
throw new DockerRegistryUIError(`The order \`${taglistOrder}\` is not recognized.`);
throw new DockerRegistryUIError(`The taglist order \`${taglistOrder}\` is not recognized.`);
}
};