Skip to content

bugfixes and improvements #3466

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jan 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/workflows/PR_Branch_Check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ permissions:

jobs:
check-branch:
if: github.event.repository.fork == false
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.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
Expand All @@ -40,20 +41,20 @@ jobs:
}

// Check if PR is from a fork's main/master branch
if (context.payload.pull_request.head.repo.fork &&
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,
Expand Down
2 changes: 1 addition & 1 deletion src/components/CippComponents/CippLocationDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const CippLocationDialog = ({ location }) => {
return (
<>
<Button size="small" variant="outlined" onClick={handleOpen} startIcon={<LocationOn />}>
Show Map
{location.city}, {location.state}, {location.countryOrRegion}
</Button>
<Dialog fullWidth maxWidth="sm" onClose={handleClose} open={open}>
<DialogTitle>Location Details</DialogTitle>
Expand Down
5 changes: 3 additions & 2 deletions src/components/CippTable/util-columnsFromAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import { getCippFilterVariant } from "../../utils/get-cipp-filter-variant";
import { getCippFormatting } from "../../utils/get-cipp-formatting";
import { getCippTranslation } from "../../utils/get-cipp-translation";

const skipRecursion = ["location"];
// Function to merge keys from all objects in the array
const mergeKeys = (dataArray) => {
return dataArray.reduce((acc, item) => {
const mergeRecursive = (obj, base = {}) => {
Object.keys(obj).forEach((key) => {
if (typeof obj[key] === "object" && obj[key] !== null && !Array.isArray(obj[key])) {
if (typeof obj[key] === "object" && obj[key] !== null && !Array.isArray(obj[key]) && !skipRecursion.includes(key)) {
if (typeof base[key] === "boolean") {
// Skip merging if base[key] is a boolean
return;
Expand All @@ -30,7 +31,7 @@ const mergeKeys = (dataArray) => {

export const utilColumnsFromAPI = (dataArray) => {
const dataSample = mergeKeys(dataArray);
const skipRecursion = ["location"];

const generateColumns = (obj, parentKey = "") => {
return Object.keys(obj)
.map((key) => {
Expand Down
290 changes: 156 additions & 134 deletions src/pages/cipp/advanced/table-maintenance.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { useForm, useWatch } from "react-hook-form";
import { CippApiDialog } from "../../../components/CippComponents/CippApiDialog";
import { Grid } from "@mui/system";
import CippButtonCard from "../../../components/CippCards/CippButtonCard";
import { CippApiResults } from "../../../components/CippComponents/CippApiResults";

const CustomAddEditRowDialog = ({ formControl, open, onClose, onSubmit, defaultValues }) => {
const fields = useWatch({ control: formControl.control, name: "fields" });
Expand Down Expand Up @@ -322,155 +323,176 @@ const Page = () => {
<Grid item size={9}>
{selectedTable && (
<Box sx={{ width: "100%" }}>
<CippButtonCard
title="Table Filters"
cardSx={{ mb: 2 }}
accordionExpanded={accordionExpanded}
component="accordion"
CardButton={
<Button
variant="contained"
color="primary"
size="small"
onClick={filterFormControl.handleSubmit((data) => {
var properties = getSelectedProps(data);
setTableFilterParams({ ...data, Property: properties });
handleRefresh();
setAccordionExpanded(false);
})}
>
Apply Filters
</Button>
}
>
<Stack spacing={1}>
<CippFormComponent
type="textField"
name="Filter"
formControl={filterFormControl}
label="OData Filter"
/>
<CippFormComponent
type="autoComplete"
name="Property"
formControl={filterFormControl}
label="Property"
options={getTableFields().map((field) => ({
label: field?.label,
value: field?.name,
}))}
/>
<Stack direction="row" spacing={1}>
<Stack spacing={1}>
<CippButtonCard
title="Table Filters"
accordionExpanded={accordionExpanded}
component="accordion"
CardButton={
<Button
variant="contained"
color="primary"
size="small"
onClick={filterFormControl.handleSubmit((data) => {
var properties = getSelectedProps(data);
setTableFilterParams({ ...data, Property: properties });
handleRefresh();
setAccordionExpanded(false);
})}
>
Apply Filters
</Button>
}
>
<Stack spacing={1}>
<CippFormComponent
type="number"
name="First"
type="textField"
name="Filter"
formControl={filterFormControl}
label="First"
label="OData Filter"
/>
<CippFormComponent
type="number"
name="Skip"
type="autoComplete"
name="Property"
formControl={filterFormControl}
label="Skip"
label="Property"
options={getTableFields().map((field) => ({
label: field?.label,
value: field?.name,
}))}
/>
<Stack direction="row" spacing={1}>
<CippFormComponent
type="number"
name="First"
formControl={filterFormControl}
label="First"
/>
<CippFormComponent
type="number"
name="Skip"
formControl={filterFormControl}
label="Skip"
/>
</Stack>
</Stack>
</Stack>
</CippButtonCard>
<CippDataTable
title={`${selectedTable}`}
data={tableData}
refreshFunction={handleRefresh}
isFetching={fetchTableData.isPending}
cardButton={
<Stack direction="row" spacing={1}>
<Button
variant="contained"
color="primary"
size="small"
onClick={() => {
</CippButtonCard>
<CippApiResults apiObject={tableRowAction} />
<CippDataTable
title={`${selectedTable}`}
data={tableData}
refreshFunction={handleRefresh}
isFetching={fetchTableData.isPending}
cardButton={
<Stack direction="row" spacing={1}>
<Button
variant="contained"
color="primary"
size="small"
onClick={() => {
setDefaultAddEditValues({
fields: getTableFields().map((field) => ({
name: field?.name,
value: "",
type: field?.type,
})),
});
addEditRowDialog.handleOpen();
}} // Open add/edit row dialog
startIcon={
<SvgIcon fontSize="small">
<Add />
</SvgIcon>
}
>
Add Row
</Button>
<Button
variant="contained"
color="error"
size="small"
onClick={deleteTableDialog.handleOpen} // Open delete table dialog
startIcon={
<SvgIcon fontSize="small">
<TrashIcon />
</SvgIcon>
}
>
Delete Table
</Button>
</Stack>
}
actions={[
{
label: "Edit",
type: "POST",
icon: (
<SvgIcon fontSize="small">
<PencilIcon />
</SvgIcon>
),
customFunction: (row) => {
setDefaultAddEditValues({
fields: getTableFields().map((field) => ({
name: field?.name,
value: "",
type: field?.type,
})),
fields: Object.keys(row)
.filter((key) => key !== "ETag" && key !== "Timestamp")
.map((key) => {
const value = row[key];
let type = "textField";
if (typeof value === "number") {
type = "number";
} else if (typeof value === "boolean") {
type = "switch";
}
return { name: key, value: value, type: type };
}),
});
addEditRowDialog.handleOpen();
}} // Open add/edit row dialog
startIcon={
<SvgIcon fontSize="small">
<Add />
</SvgIcon>
}
>
Add Row
</Button>
<Button
variant="contained"
color="error"
size="small"
onClick={deleteTableDialog.handleOpen} // Open delete table dialog
startIcon={
},
noConfirm: true,
hideBulk: true,
},
{
label: "Delete",
type: "POST",
icon: (
<SvgIcon fontSize="small">
<TrashIcon />
</SvgIcon>
}
>
Delete Table
</Button>
</Stack>
}
actions={[
{
label: "Edit",
type: "POST",
icon: (
<SvgIcon fontSize="small">
<PencilIcon />
</SvgIcon>
),
customFunction: (row) => {
setDefaultAddEditValues({
fields: Object.keys(row)
.filter((key) => key !== "ETag" && key !== "Timestamp")
.map((key) => {
const value = row[key];
let type = "textField";
if (typeof value === "number") {
type = "number";
} else if (typeof value === "boolean") {
type = "switch";
}
return { name: key, value: value, type: type };
}),
});
addEditRowDialog.handleOpen();
},
noConfirm: true,
hideBulk: true,
},
{
label: "Delete",
type: "POST",
icon: (
<SvgIcon fontSize="small">
<TrashIcon />
</SvgIcon>
),
url: apiUrl,
data: {
FunctionName: "Remove-AzDataTableEntity",
TableName: `!${selectedTable}`,
Parameters: {
Entity: { RowKey: "RowKey", PartitionKey: "PartitionKey", ETag: "ETag" },
),
url: apiUrl,
customFunction: (row) => {
var entity = [];
if (Array.isArray(row)) {
entity = row.map((r) => ({
RowKey: r.RowKey,
PartitionKey: r.PartitionKey,
ETag: r.ETag,
}));
} else {
entity = {
RowKey: row.RowKey,
PartitionKey: row.PartitionKey,
ETag: row.ETag,
};
}
tableRowAction.mutate({
url: apiUrl,
data: {
FunctionName: "Remove-AzDataTableEntity",
TableName: selectedTable,
Parameters: {
Entity: entity,
},
},
});
},
confirmText:
"Do you want to delete the selected row(s)? This action cannot be undone.",
multiPost: true,
},
onSuccess: handleRefresh,
confirmText: "Do you want to delete this row?",
multiPost: false,
},
]}
/>
]}
/>
</Stack>
</Box>
)}
</Grid>
Expand Down
Loading
Loading