mirror of
https://gitlab.nic.cz/turris/reforis/foris-js.git
synced 2024-11-14 17:35:35 +01:00
Add displayCard function to utils
This commit is contained in:
parent
4898016388
commit
5469e6ec80
|
@ -39,7 +39,6 @@ export { Modal, ModalBody, ModalFooter, ModalHeader } from "./bootstrap/Modal";
|
|||
// Common
|
||||
export { RebootButton } from "./common/RebootButton";
|
||||
export { WiFiSettings } from "./common/WiFiSettings/WiFiSettings";
|
||||
|
||||
// Form
|
||||
export { ForisForm } from "./form/components/ForisForm";
|
||||
export {
|
||||
|
@ -70,6 +69,7 @@ export {
|
|||
export { ErrorMessage } from "./utils/ErrorMessage";
|
||||
export { useClickOutside } from "./utils/hooks";
|
||||
export { toLocaleDateString } from "./utils/datetime";
|
||||
export { displayCard } from "./utils/displayCard";
|
||||
|
||||
// Foris URL
|
||||
export { ForisURLs, REFORIS_URL_PREFIX } from "./utils/forisUrls";
|
||||
|
|
23
src/utils/displayCard.js
Normal file
23
src/utils/displayCard.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Copyright (C) 2020 CZ.NIC z.s.p.o. (http://www.nic.cz/)
|
||||
*
|
||||
* This is free software, licensed under the GNU General Public License v3.
|
||||
* See /LICENSE for more information.
|
||||
*/
|
||||
|
||||
export function displayCard({ package_lists: packages }, cardName) {
|
||||
const enabledPackagesNames = [];
|
||||
packages
|
||||
.filter((item) => item.enabled)
|
||||
.map((item) => {
|
||||
enabledPackagesNames.push(item.name);
|
||||
item.options
|
||||
.filter((option) => option.enabled)
|
||||
.map((option) => {
|
||||
enabledPackagesNames.push(option.name);
|
||||
return null;
|
||||
});
|
||||
return null;
|
||||
});
|
||||
return enabledPackagesNames.includes(cardName);
|
||||
}
|
Loading…
Reference in New Issue
Block a user