Skip to content

Commit

Permalink
Merge pull request #85 from KelvinTegelaar/dev
Browse files Browse the repository at this point in the history
[pull] dev from KelvinTegelaar:dev
  • Loading branch information
kris6673 authored Jan 22, 2025
2 parents 0073a93 + eba490b commit 9d851e6
Show file tree
Hide file tree
Showing 21 changed files with 130 additions and 70 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/PR_Branch_Check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: PR Branch Check

on:
# Using pull_request_target instead of pull_request for secure handling of fork PRs
pull_request_target:
# Only run on these PR events
types: [opened, synchronize, reopened]
# Only check PRs targeting these branches
branches:
- main
- master

permissions:
pull-requests: write
issues: write

jobs:
check-branch:
runs-on: ubuntu-latest
steps:
- name: Check and Comment on PR
# Only process fork PRs with specific branch conditions
# Must be a fork AND (source is main/master OR target is main/master)
if: |
github.event.pull_request.head.repo.fork == true &&
((github.event.pull_request.head.ref == 'main' || github.event.pull_request.head.ref == 'master') ||
(github.event.pull_request.base.ref == 'main' || github.event.pull_request.base.ref == 'master'))
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
let message = '';
message += '🔄 If you are attempting to update your CIPP repo please follow the instructions at: https://docs.cipp.app/setup/self-hosting-guide/updating ';
message += '\n\n';
// Check if PR is targeting main/master
if (context.payload.pull_request.base.ref === 'main' || context.payload.pull_request.base.ref === 'master') {
message += '⚠️ PRs cannot target the main branch directly. If you are attempting to contribute code please PR to the dev branch.\n\n';
}
// Check if PR is from a fork's main/master branch
if (context.payload.pull_request.head.repo.fork &&
(context.payload.pull_request.head.ref === 'main' || context.payload.pull_request.head.ref === 'master')) {
message += '⚠️ This PR cannot be merged because it originates from your fork\'s main/master branch. If you are attempting to contribute code please PR from your dev branch or another non-main/master branch.\n\n';
}
message += '🔒 This PR will now be automatically closed due to the above violation(s).';
// Post the comment
await github.rest.issues.createComment({
...context.repo,
issue_number: context.issue.number,
body: message
});
// Close the PR
await github.rest.pulls.update({
...context.repo,
pull_number: context.issue.number,
state: 'closed'
});
2 changes: 1 addition & 1 deletion .github/workflows/dev_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: CIPP Development Frontend CI/CD
on:
push:
branches:
- interface-rewrite
- dev

jobs:
build_and_deploy_job:
Expand Down
6 changes: 3 additions & 3 deletions src/components/CippComponents/CippApiDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,10 @@ export const CippApiDialog = (props) => {
}
useEffect(() => {
if (api.noConfirm) {
formHook.handleSubmit(onSubmit)(); // Submits the form on mount
createDialog.handleClose(); // Closes the dialog after submitting
formHook.handleSubmit(onSubmit)();
createDialog.handleClose();
}
}, [api.noConfirm]); // Run effect only when api.noConfirm changes
}, [api.noConfirm]);

const handleClose = () => {
createDialog.handleClose();
Expand Down
1 change: 1 addition & 0 deletions src/components/CippFormPages/CippAddGroupTemplateForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const CippAddGroupTemplateForm = (props) => {
type="textField"
label="Display Name"
name="displayName"
required
formControl={formControl}
fullWidth
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const CippIntegrationFieldMapping = () => {
var missingMappings = [];
fieldMapping?.data?.Mappings?.forEach((mapping) => {
const exists = fieldMapping?.data?.IntegrationFields?.some(
(integrationField) => integrationField.value === mapping.IntegrationId
(integrationField) => String(integrationField.value) === mapping.IntegrationId
);
if (exists) {
newMappings[mapping.RowKey] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ const CippIntegrationSettings = ({ children }) => {
const selectedTenant = formControl.getValues("tenantFilter");
const selectedCompany = formControl.getValues("integrationCompany");
if (!selectedTenant || !selectedCompany) return;
if (tableData?.find((item) => item.TenantId === selectedTenant.value)) return;
if (tableData?.find((item) => item.TenantId === selectedTenant.addedFields.customerId)) return;

const newRowData = {
TenantId: selectedTenant.value,
TenantId: selectedTenant.addedFields.customerId,
Tenant: selectedTenant.label,
IntegrationName: selectedCompany.label,
IntegrationId: selectedCompany.value,
Expand Down
6 changes: 5 additions & 1 deletion src/components/CippStandards/CippStandardsSideBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,11 @@ const CippStandardsSideBar = ({
}}
row={formControl.getValues()}
formControl={formControl}
relatedQueryKeys={"listStandardTemplates"}
relatedQueryKeys={[
"listStandardTemplates",
"listStandards",
`listStandardTemplates-${watchForm.GUID}`,
]}
/>
</Card>
);
Expand Down
13 changes: 7 additions & 6 deletions src/components/CippTable/util-columnsFromAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import { getCippTranslation } from "../../utils/get-cipp-translation";
const mergeKeys = (dataArray) => {
return dataArray.reduce((acc, item) => {
const mergeRecursive = (obj, base = {}) => {
Object?.keys(obj)?.forEach((key) => {
// If base[key] is a string, it should not be merged as an object
if (typeof base[key] === "string") {
return; // Skip further merging for this key
}

Object.keys(obj).forEach((key) => {
if (typeof obj[key] === "object" && obj[key] !== null && !Array.isArray(obj[key])) {
if (typeof base[key] === "boolean") {
// Skip merging if base[key] is a boolean
return;
}
base[key] = mergeRecursive(obj[key], base[key] || {});
} else if (typeof obj[key] === "boolean") {
base[key] = obj[key];
} else if (typeof obj[key] === "string" && obj[key].toUpperCase() === "FAILED") {
base[key] = base[key]; // Keep existing value if it's 'FAILED'
} else if (obj[key] !== undefined && obj[key] !== null) {
Expand Down
2 changes: 1 addition & 1 deletion src/data/Extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@
"logoDark": "/assets/integrations/pwpush_dark.png",
"forceSyncButton": false,
"description": "Enable the PasswordPusher integration to generate password links instead of plain text passwords.",
"helpText": "This integration allows you to generate password links instead of plain text passwords. Configure authentication and expiration settings that will apply to all generated passwords.",
"helpText": "This integration allows you to generate password links instead of plain text passwords. Configure authentication and expiration settings that will apply to all generated passwords. If you are a PWPush Pro customer and utilizing custom domains, please do not enter your custom domain in the Base URL field.",
"links": [
{
"name": "PWPush Documentation",
Expand Down
1 change: 0 additions & 1 deletion src/layouts/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ export const nativeMenuItems = [
{ title: "Autopilot Devices", path: "/endpoint/autopilot/list-devices" },
{ title: "Add Autopilot Device", path: "/endpoint/autopilot/add-device" },
{ title: "Profiles", path: "/endpoint/autopilot/list-profiles" },
{ title: "Add Profile", path: "/endpoint/autopilot/add-profile" },
{ title: "Status Pages", path: "/endpoint/autopilot/list-status-pages" },
{ title: "Add Status Page", path: "/endpoint/autopilot/add-status-page" },
],
Expand Down
3 changes: 3 additions & 0 deletions src/pages/cipp/integrations/configure.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ const Page = () => {
};

const handleIntegrationTest = () => {
if (testQuery.waiting) {
actionTestResults.refetch();
}
setTestQuery({
url: "/api/ExecExtensionTest",
data: {
Expand Down
8 changes: 1 addition & 7 deletions src/pages/email/connectionfilter/list-templates/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,13 @@ const Page = () => {
const pageTitle = "Connection filter Templates";

const actions = [
{
label: "View Template",
icon: <EyeIcon />, // Placeholder for the view icon
color: "success",
offCanvas: true,
},
{
label: "Delete Template",
type: "POST",
url: "/api/RemoveConnectionfilterTemplate",
data: { ID: "GUID" },
confirmText: "Do you want to delete the template?",
icon: <TrashIcon />, // Placeholder for the delete icon
icon: <TrashIcon />,
color: "danger",
},
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const Page = () => {
ID: "GUID",
},
confirmText: "Do you want to delete the template?",
icon: <TrashIcon />, // Placeholder for delete icon
icon: <TrashIcon />,
color: "danger",
},
];
Expand Down
6 changes: 0 additions & 6 deletions src/pages/email/spamfilter/list-templates/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ const Page = () => {
const pageTitle = "Spamfilter Templates";

const actions = [
{
label: "View Template",
icon: <EyeIcon />, // Placeholder for the view icon
color: "success",
offCanvas: true,
},
{
label: "Delete Template",
type: "POST",
Expand Down
20 changes: 17 additions & 3 deletions src/pages/email/transport/list-rules/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Layout as DashboardLayout } from "/src/layouts/index.js";
import { CippTablePage } from "/src/components/CippComponents/CippTablePage.jsx";
import { Button } from "@mui/material";
import { Book, DoDisturb, Done } from "@mui/icons-material";
import { TrashIcon } from "@heroicons/react/24/outline";
import Link from "next/link";

const Page = () => {
Expand All @@ -11,8 +13,9 @@ const Page = () => {
label: "Create template based on rule",
type: "POST",
url: "/api/AddTransportTemplate",
data: {}, // No extra data was specified for this action in the original file
postEntireRow: true,
confirmText: "Are you sure you want to create a template based on this rule?",
icon: <Book />,
},
{
label: "Enable Rule",
Expand All @@ -23,6 +26,7 @@ const Page = () => {
GUID: "Guid",
},
confirmText: "Are you sure you want to enable this rule?",
icon: <Done />,
},
{
label: "Disable Rule",
Expand All @@ -33,6 +37,7 @@ const Page = () => {
GUID: "Guid",
},
confirmText: "Are you sure you want to disable this rule?",
icon: <DoDisturb />,
},
{
label: "Delete Rule",
Expand All @@ -43,15 +48,24 @@ const Page = () => {
},
confirmText: "Are you sure you want to delete this rule?",
color: "danger",
icon: <TrashIcon />,
},
];

const offCanvas = {
extendedInfoFields: ["CreatedBy", "LastModifiedBy", "WhenChanged", "Description", "Guid"],
extendedInfoFields: [
"Guid",
"CreatedBy",
"LastModifiedBy",
"WhenChanged",
"Name",
"Comments",
"Description",
],
actions: actions,
};

const simpleColumns = ["Name", "State", "Mode", "RuleErrorAction", "WhenChanged"];
const simpleColumns = ["Name", "State", "Mode", "RuleErrorAction", "WhenChanged", "Comments"];

return (
<CippTablePage
Expand Down
8 changes: 1 addition & 7 deletions src/pages/email/transport/list-templates/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,13 @@ const Page = () => {
const pageTitle = "Transport Rule Templates";

const actions = [
{
label: "View Template",
icon: <EyeIcon />, // Placeholder icon for developer customization
color: "success",
offCanvas: true,
},
{
label: "Delete Template",
type: "POST",
url: "/api/RemoveTransportRuleTemplate",
data: { ID: "GUID" },
confirmText: "Do you want to delete the template?",
icon: <TrashIcon />, // Placeholder icon for developer customization
icon: <TrashIcon />,
color: "danger",
},
];
Expand Down
17 changes: 0 additions & 17 deletions src/pages/endpoint/autopilot/add-profile/index.js

This file was deleted.

8 changes: 5 additions & 3 deletions src/pages/tenant/gdap-management/onboarding/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ const Page = () => {

var missingDefaults = [];
cippDefaults.forEach((defaultRole) => {
if (!relationshipRoles?.find((role) => defaultRole.value === role.roleDefinitionId)) {
missingDefaults.push(role);
if (!relationshipRoles?.find((role) => defaultRole?.value === role?.roleDefinitionId)) {
missingDefaults.push(defaultRole);
}
});
setMissingDefaults(missingDefaults.length > 0);
Expand Down Expand Up @@ -409,7 +409,9 @@ const Page = () => {
{(currentInvite || selectedRole) && rolesMissingFromRelationship.length > 0 && (
<Alert severity="warning">
The following roles are not mapped with the current template:{" "}
{rolesMissingFromRelationship.map((role) => role.Name).join(", ")}
{rolesMissingFromRelationship
.map((role) => role?.Name ?? "Unknown Role")
.join(", ")}
</Alert>
)}
{(currentInvite || selectedRole) &&
Expand Down
1 change: 1 addition & 0 deletions src/pages/tenant/standards/list-standards/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ const Page = () => {
"updatedAt",
"updatedBy",
"runManually",
"standards",
]}
queryKey="listStandardTemplates"
/>
Expand Down
8 changes: 8 additions & 0 deletions src/pages/tenant/standards/template.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ const Page = () => {
};

const handleAddMultipleStandard = (standardName) => {
//if the standardname contains an array qualifier,e.g standardName[0], strip that away.
const arrayPattern = /(.*)\[(\d+)\]$/;
const match = standardName.match(arrayPattern);
if (match) {
standardName = match[1];
}
console.log("Adding multiple", standardName);

setSelectedStandards((prev) => {
const existingInstances = Object.keys(prev).filter((name) => name.startsWith(standardName));
const newIndex = existingInstances.length;
Expand Down
Loading

0 comments on commit 9d851e6

Please sign in to comment.