Skip to content

Commit

Permalink
add conditionals to GitHub action requiring a token
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnDuprey committed Feb 12, 2025
1 parent 22e0dbc commit af17615
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
7 changes: 6 additions & 1 deletion src/pages/email/spamfilter/list-templates/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
7 changes: 6 additions & 1 deletion src/pages/email/transport/list-connector-templates/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
7 changes: 6 additions & 1 deletion src/pages/email/transport/list-templates/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
7 changes: 6 additions & 1 deletion src/pages/endpoint/MEM/list-templates/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
7 changes: 6 additions & 1 deletion src/pages/identity/administration/group-templates/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
7 changes: 6 additions & 1 deletion src/pages/tenant/conditional/list-template/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
6 changes: 6 additions & 0 deletions src/pages/tenant/standards/bpa-report/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
6 changes: 5 additions & 1 deletion src/pages/tenant/standards/list-standards/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
{
Expand Down Expand Up @@ -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",
Expand Down
15 changes: 11 additions & 4 deletions src/pages/tools/community-repos/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
Tooltip,
Typography,
Alert,
Link,
Chip,
} from "@mui/material";
import { TrashIcon } from "@heroicons/react/24/outline";
Expand All @@ -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);
Expand All @@ -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"],
Expand Down Expand Up @@ -176,7 +179,11 @@ const Page = () => {
<Button onClick={() => setOpenSearch(true)} startIcon={<Add />}>
Add Repo
</Button>
<Button onClick={() => setOpenCreate(true)} startIcon={<Add />}>
<Button
onClick={() => setOpenCreate(true)}
startIcon={<Add />}
disabled={!integrations.isSuccess || !integrations?.data?.GitHub?.Enabled}
>
Create Repo
</Button>
</>
Expand Down

0 comments on commit af17615

Please sign in to comment.