mirror of
https://gitlab.nic.cz/turris/reforis/foris-js.git
synced 2024-12-26 00:21:36 +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
|
// Common
|
||||||
export { RebootButton } from "./common/RebootButton";
|
export { RebootButton } from "./common/RebootButton";
|
||||||
export { WiFiSettings } from "./common/WiFiSettings/WiFiSettings";
|
export { WiFiSettings } from "./common/WiFiSettings/WiFiSettings";
|
||||||
|
|
||||||
// Form
|
// Form
|
||||||
export { ForisForm } from "./form/components/ForisForm";
|
export { ForisForm } from "./form/components/ForisForm";
|
||||||
export {
|
export {
|
||||||
|
@ -70,6 +69,7 @@ export {
|
||||||
export { ErrorMessage } from "./utils/ErrorMessage";
|
export { ErrorMessage } from "./utils/ErrorMessage";
|
||||||
export { useClickOutside } from "./utils/hooks";
|
export { useClickOutside } from "./utils/hooks";
|
||||||
export { toLocaleDateString } from "./utils/datetime";
|
export { toLocaleDateString } from "./utils/datetime";
|
||||||
|
export { displayCard } from "./utils/displayCard";
|
||||||
|
|
||||||
// Foris URL
|
// Foris URL
|
||||||
export { ForisURLs, REFORIS_URL_PREFIX } from "./utils/forisUrls";
|
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