From af17615c5d3df07310ba27b2befee1d91f545175 Mon Sep 17 00:00:00 2001 From: John Duprey Date: Wed, 12 Feb 2025 13:27:10 -0500 Subject: [PATCH] add conditionals to GitHub action requiring a token --- .../list-connectionfilter-templates/index.js | 7 ++++++- .../email/spamfilter/list-templates/index.js | 7 ++++++- .../transport/list-connector-templates/index.js | 7 ++++++- src/pages/email/transport/list-templates/index.js | 7 ++++++- src/pages/endpoint/MEM/list-templates/index.js | 7 ++++++- .../administration/group-templates/index.js | 7 ++++++- .../tenant/conditional/list-template/index.js | 7 ++++++- src/pages/tenant/standards/bpa-report/index.js | 6 ++++++ .../tenant/standards/list-standards/index.js | 6 +++++- src/pages/tools/community-repos/index.js | 15 +++++++++++---- 10 files changed, 64 insertions(+), 12 deletions(-) diff --git a/src/pages/email/spamfilter/list-connectionfilter-templates/index.js b/src/pages/email/spamfilter/list-connectionfilter-templates/index.js index 71b2a900ef3e..9eeb2638a408 100644 --- a/src/pages/email/spamfilter/list-connectionfilter-templates/index.js +++ b/src/pages/email/spamfilter/list-connectionfilter-templates/index.js @@ -2,10 +2,14 @@ import { Layout as DashboardLayout } from "/src/layouts/index.js"; import { CippTablePage } from "/src/components/CippComponents/CippTablePage.jsx"; import { TrashIcon } from "@heroicons/react/24/outline"; import { GitHub } from "@mui/icons-material"; +import { ApiGetCall } from "/src/api/ApiCall"; const Page = () => { const pageTitle = "Connection filter Templates"; - + const integrations = ApiGetCall({ + url: "/api/ListExtensionsConfig", + queryKey: "Integrations", + }); const actions = [ { label: "Save to GitHub", @@ -49,6 +53,7 @@ const Page = () => { }, ], confirmText: "Are you sure you want to save this template to the selected repository?", + condition: () => integrations.isSuccess && integrations?.data?.GitHub.Enabled, }, { label: "Delete Template", diff --git a/src/pages/email/spamfilter/list-templates/index.js b/src/pages/email/spamfilter/list-templates/index.js index 5f8784ebfc30..ce86b031198c 100644 --- a/src/pages/email/spamfilter/list-templates/index.js +++ b/src/pages/email/spamfilter/list-templates/index.js @@ -2,10 +2,14 @@ import { Layout as DashboardLayout } from "/src/layouts/index.js"; import { CippTablePage } from "/src/components/CippComponents/CippTablePage.jsx"; import { TrashIcon } from "@heroicons/react/24/outline"; import { GitHub } from "@mui/icons-material"; +import { ApiGetCall } from "/src/api/ApiCall"; const Page = () => { const pageTitle = "Spamfilter Templates"; - + const integrations = ApiGetCall({ + url: "/api/ListExtensionsConfig", + queryKey: "Integrations", + }); const actions = [ { label: "Save to GitHub", @@ -49,6 +53,7 @@ const Page = () => { }, ], confirmText: "Are you sure you want to save this template to the selected repository?", + condition: () => integrations.isSuccess && integrations?.data?.GitHub.Enabled, }, { label: "Delete Template", diff --git a/src/pages/email/transport/list-connector-templates/index.js b/src/pages/email/transport/list-connector-templates/index.js index 88dbb5277a9b..567eac960f94 100644 --- a/src/pages/email/transport/list-connector-templates/index.js +++ b/src/pages/email/transport/list-connector-templates/index.js @@ -6,10 +6,14 @@ import { CippTablePage } from "/src/components/CippComponents/CippTablePage.jsx" import { TrashIcon } from "@heroicons/react/24/outline"; import { GitHub } from "@mui/icons-material"; import ConnectorTemplateDetails from "../../../../components/CippComponents/ConnectorTemplateDetails"; +import { ApiGetCall } from "/src/api/ApiCall"; const Page = () => { const pageTitle = "Exchange Connector Templates"; - + const integrations = ApiGetCall({ + url: "/api/ListExtensionsConfig", + queryKey: "Integrations", + }); const actions = [ { label: "Save to GitHub", @@ -53,6 +57,7 @@ const Page = () => { }, ], confirmText: "Are you sure you want to save this template to the selected repository?", + condition: () => integrations.isSuccess && integrations?.data?.GitHub.Enabled, }, { label: "Delete Template", diff --git a/src/pages/email/transport/list-templates/index.js b/src/pages/email/transport/list-templates/index.js index ecbe161d4015..5e9e8d12e90e 100644 --- a/src/pages/email/transport/list-templates/index.js +++ b/src/pages/email/transport/list-templates/index.js @@ -4,10 +4,14 @@ import { TrashIcon } from "@heroicons/react/24/outline"; import { Button } from "@mui/material"; import { RocketLaunch, GitHub } from "@mui/icons-material"; import Link from "next/link"; +import { ApiGetCall } from "/src/api/ApiCall"; const Page = () => { const pageTitle = "Transport Rule Templates"; - + const integrations = ApiGetCall({ + url: "/api/ListExtensionsConfig", + queryKey: "Integrations", + }); const actions = [ { label: "Save to GitHub", @@ -51,6 +55,7 @@ const Page = () => { }, ], confirmText: "Are you sure you want to save this template to the selected repository?", + condition: () => integrations.isSuccess && integrations?.data?.GitHub.Enabled, }, { label: "Delete Template", diff --git a/src/pages/endpoint/MEM/list-templates/index.js b/src/pages/endpoint/MEM/list-templates/index.js index 3c98cef08836..9a1dfc6e3264 100644 --- a/src/pages/endpoint/MEM/list-templates/index.js +++ b/src/pages/endpoint/MEM/list-templates/index.js @@ -3,10 +3,14 @@ import { CippTablePage } from "/src/components/CippComponents/CippTablePage.jsx" import { PencilIcon, TrashIcon } from "@heroicons/react/24/outline"; import { GitHub } from "@mui/icons-material"; import CippJsonView from "../../../../components/CippFormPages/CippJSONView"; +import { ApiGetCall } from "/src/api/ApiCall"; const Page = () => { const pageTitle = "Available Endpoint Manager Templates"; - + const integrations = ApiGetCall({ + url: "/api/ListExtensionsConfig", + queryKey: "Integrations", + }); const actions = [ { label: "Edit Template Name and Description", @@ -73,6 +77,7 @@ const Page = () => { }, ], confirmText: "Are you sure you want to save this template to the selected repository?", + condition: () => integrations.isSuccess && integrations?.data?.GitHub.Enabled, }, { label: "Delete Template", diff --git a/src/pages/identity/administration/group-templates/index.js b/src/pages/identity/administration/group-templates/index.js index dc93aec61dd7..d1d047594a89 100644 --- a/src/pages/identity/administration/group-templates/index.js +++ b/src/pages/identity/administration/group-templates/index.js @@ -4,10 +4,14 @@ import { Layout as DashboardLayout } from "/src/layouts/index.js"; import { AddBox, RocketLaunch, Delete, GitHub } from "@mui/icons-material"; import Link from "next/link"; import { CippCodeBlock } from "../../../../components/CippComponents/CippCodeBlock"; +import { ApiGetCall } from "/src/api/ApiCall"; const Page = () => { const pageTitle = "Group Templates"; - + const integrations = ApiGetCall({ + url: "/api/ListExtensionsConfig", + queryKey: "Integrations", + }); const actions = [ { label: "Save to GitHub", @@ -51,6 +55,7 @@ const Page = () => { }, ], confirmText: "Are you sure you want to save this template to the selected repository?", + condition: () => integrations.isSuccess && integrations?.data?.GitHub.Enabled, }, { label: "Delete Template", diff --git a/src/pages/tenant/conditional/list-template/index.js b/src/pages/tenant/conditional/list-template/index.js index f8cbb6eb1b2a..fbfb20795f40 100644 --- a/src/pages/tenant/conditional/list-template/index.js +++ b/src/pages/tenant/conditional/list-template/index.js @@ -3,10 +3,14 @@ import { CippTablePage } from "/src/components/CippComponents/CippTablePage.jsx" import { Button } from "@mui/material"; import CippJsonView from "../../../../components/CippFormPages/CippJSONView"; import { Delete, GitHub } from "@mui/icons-material"; +import { ApiGetCall } from "/src/api/ApiCall"; const Page = () => { const pageTitle = "Available Conditional Access Templates"; - + const integrations = ApiGetCall({ + url: "/api/ListExtensionsConfig", + queryKey: "Integrations", + }); const actions = [ { label: "Save to GitHub", @@ -50,6 +54,7 @@ const Page = () => { }, ], confirmText: "Are you sure you want to save this template to the selected repository?", + condition: () => integrations.isSuccess && integrations?.data?.GitHub.Enabled, }, { label: "Delete Template", diff --git a/src/pages/tenant/standards/bpa-report/index.js b/src/pages/tenant/standards/bpa-report/index.js index e59b5c7ea5bf..1bb4a6cca89b 100644 --- a/src/pages/tenant/standards/bpa-report/index.js +++ b/src/pages/tenant/standards/bpa-report/index.js @@ -4,9 +4,14 @@ import { Layout as DashboardLayout } from "/src/layouts/index.js"; // had to add import Link from "next/link"; import { EyeIcon } from "@heroicons/react/24/outline"; import { CopyAll, Delete, Edit, AddBox, GitHub } from "@mui/icons-material"; +import { ApiGetCall } from "/src/api/ApiCall"; const Page = () => { const pageTitle = "Best Practice Reports"; + const integrations = ApiGetCall({ + url: "/api/ListExtensionsConfig", + queryKey: "Integrations", + }); const actions = [ { label: "View Report", @@ -72,6 +77,7 @@ const Page = () => { }, ], confirmText: "Are you sure you want to save this template to the selected repository?", + condition: () => integrations.isSuccess && integrations?.data?.GitHub.Enabled, }, { label: "Delete Template", diff --git a/src/pages/tenant/standards/list-standards/index.js b/src/pages/tenant/standards/list-standards/index.js index 3bd38b3b816c..023e58df5071 100644 --- a/src/pages/tenant/standards/list-standards/index.js +++ b/src/pages/tenant/standards/list-standards/index.js @@ -9,7 +9,10 @@ import { CippApiResults } from "../../../../components/CippComponents/CippApiRes const Page = () => { const oldStandards = ApiGetCall({ url: "/api/ListStandards", queryKey: "ListStandards-legacy" }); - + const integrations = ApiGetCall({ + url: "/api/ListExtensionsConfig", + queryKey: "Integrations", + }); const pageTitle = "Standard Templates"; const actions = [ { @@ -92,6 +95,7 @@ const Page = () => { }, ], confirmText: "Are you sure you want to save this template to the selected repository?", + condition: () => integrations.isSuccess && integrations?.data?.GitHub.Enabled, }, { label: "Delete Template", diff --git a/src/pages/tools/community-repos/index.js b/src/pages/tools/community-repos/index.js index 56cfd7a62e30..34a5bd9b8510 100644 --- a/src/pages/tools/community-repos/index.js +++ b/src/pages/tools/community-repos/index.js @@ -17,7 +17,6 @@ import { Tooltip, Typography, Alert, - Link, Chip, } from "@mui/material"; import { TrashIcon } from "@heroicons/react/24/outline"; @@ -29,9 +28,8 @@ import AddIcon from "@mui/icons-material/Add"; import { Box } from "@mui/system"; import { Add, ForkLeft, OpenInNew } from "@mui/icons-material"; import { CippApiResults } from "/src/components/CippComponents/CippApiResults"; -import { ApiGetCall } from "../../../api/ApiCall"; -import NextLink from "next/link"; import CippFormComponent from "../../../components/CippComponents/CippFormComponent"; +import { ApiGetCall } from "../../../api/ApiCall"; const Page = () => { const [openSearch, setOpenSearch] = useState(false); @@ -42,6 +40,11 @@ const Page = () => { const [openCreate, setOpenCreate] = useState(false); const createForm = useForm({ mode: "onChange", defaultValues: { Type: "user" } }); + const integrations = ApiGetCall({ + url: "/api/ListExtensionsConfig", + queryKey: "Integrations", + }); + const createMutation = ApiPostCall({ urlFromData: true, relatedQueryKeys: ["CommunityRepos"], @@ -176,7 +179,11 @@ const Page = () => { -