Skip to content

Commit

Permalink
fix(taglist-order): improve error handler when the order does not exists
Browse files Browse the repository at this point in the history
  • Loading branch information
Joxit committed May 18, 2023
1 parent 92584fc commit c6dee14
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
4 changes: 1 addition & 3 deletions src/components/docker-registry-ui.riot
Original file line number Diff line number Diff line change
Expand Up @@ -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/(.*)">
Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -243,7 +242,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
version,
truthy,
stringToArray,
taglistOrderParser,
};
</script>
<style>
Expand Down
7 changes: 6 additions & 1 deletion src/components/tag-list/tag-list.riot
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/scripts/error.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export class DockerRegistryUIError extends Error {
constructor(msg) {
super(msg);
this.isError = true;
}
}
2 changes: 1 addition & 1 deletion src/scripts/taglist-order.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.`);
}
};

Expand Down

0 comments on commit c6dee14

Please sign in to comment.