Skip to content
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

[pull] dev from KelvinTegelaar:dev #42

Merged
merged 17 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
4 changes: 2 additions & 2 deletions .github/workflows/dev_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
id: builddeploy
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_RW }} # change this to your repository secret name
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_AMBITIOUS_MOSS_0A047A40F }} # change this to your repository secret name
repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
action: 'upload'
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
Expand All @@ -37,5 +37,5 @@ jobs:
id: closepullrequest
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_RW }} # change this to your repository secret name
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_AMBITIOUS_MOSS_0A047A40F }} # change this to your repository secret name
action: 'close'
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
27 changes: 23 additions & 4 deletions src/components/CippTable/CIPPTableToptoolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ export const CIPPTableToptoolbar = ({

//useEffect to set the column visibility to the preferred columns if they exist
useEffect(() => {
if (settings?.columnDefaults?.[pageName]) {
if (
settings?.columnDefaults?.[pageName] &&
Object.keys(settings?.columnDefaults?.[pageName]).length > 0
) {
setColumnVisibility(settings?.columnDefaults?.[pageName]);
}
}, [settings?.columnDefaults?.[pageName], router, usedColumns]);
Expand All @@ -88,27 +91,42 @@ export const CIPPTableToptoolbar = ({
});

const resetToDefaultVisibility = () => {
setColumnVisibility({});
setColumnVisibility((prevVisibility) => {
const updatedVisibility = {};
for (const col in prevVisibility) {
if (Array.isArray(originalSimpleColumns)) {
updatedVisibility[col] = originalSimpleColumns.includes(col);
}
}
return updatedVisibility;
});
settings.handleUpdate({
columnDefaults: {
...settings?.columnDefaults,
[pageName]: {},
},
});
columnPopover.handleClose();
};

const resetToPreferedVisibility = () => {
if (settings?.columnDefaults?.[pageName]) {
if (
settings?.columnDefaults?.[pageName] &&
Object.keys(settings?.columnDefaults?.[pageName]).length > 0
) {
setColumnVisibility(settings?.columnDefaults?.[pageName]);
} else {
setColumnVisibility((prevVisibility) => {
const updatedVisibility = {};
for (const col in prevVisibility) {
updatedVisibility[col] = originalSimpleColumns.includes(col);
if (Array.isArray(originalSimpleColumns)) {
updatedVisibility[col] = originalSimpleColumns.includes(col);
}
}
return updatedVisibility;
});
}
columnPopover.handleClose();
};

const saveAsPreferedColumns = () => {
Expand All @@ -118,6 +136,7 @@ export const CIPPTableToptoolbar = ({
[pageName]: columnVisibility,
},
});
columnPopover.handleClose();
};

const mergeCaseInsensitive = (obj1, obj2) => {
Expand Down
1 change: 1 addition & 0 deletions src/components/CippTable/CippDataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ export const CippDataTable = (props) => {
table={table}
api={api}
queryKey={queryKey}
simpleColumns={simpleColumns}
data={data}
columnVisibility={columnVisibility}
getRequestData={getRequestData}
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
Loading