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

Fix editing and saving of configs on the Config Management page #361

Merged
merged 2 commits into from
Jun 10, 2024
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
27 changes: 27 additions & 0 deletions .github/workflows/mattermost-webhook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: mattermost-ziti-webhook
on:
create:
delete:
issues:
issue_comment:
pull_request_review:
pull_request_review_comment:
pull_request:
push:
fork:
release:

jobs:
mattermost-ziti-webhook:
runs-on: ubuntu-latest
name: POST Webhook
if: github.repository_owner == 'openziti' && github.actor != 'dependabot[bot]'
env:
ZITI_LOG: 99
ZITI_NODEJS_LOG: 99
steps:
- uses: openziti/ziti-webhook-action@main
with:
ziti-id: ${{ secrets.ZITI_MATTERMOST_IDENTITY }}
webhook-url: ${{ secrets.ZITI_MATTERMOST_WEBHOOK_URL }}
webhook-secret: ${{ secrets.ZITI_MATTERMOSTI_WEBHOOK_SECRET }}
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,7 @@ export class ZacWrapperService extends ZacWrapperServiceClass {
}
}
}
saveParams.data = this.redefineObject(saveParams.data);
for (const prop in saveParams.data) {
if (Array.isArray(saveParams.data[prop]) && saveParams.data[prop].length == 0) {
delete saveParams.data[prop];
Expand Down Expand Up @@ -812,6 +813,26 @@ export class ZacWrapperService extends ZacWrapperServiceClass {
});
}

redefineObject(obj) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redefineObject seems like a strange name to me. it feels more like a resetObject to me, but maybe that's my weak js-foo?

for (let prop in obj) {
if (Array.isArray(obj[prop]) && obj[prop].length==0) {
delete obj[prop];
} else {
if (typeof obj[prop] === "string" && obj[prop].trim().length==0) {
delete obj[prop];
} else {
if (typeof obj[prop] === "object") {
obj[prop] = this.redefineObject(obj[prop]);
if (Object.keys(obj[prop]).length==0) {
delete obj[prop];
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's no 'else' here. feels like a console.log or ... anything ? would be good here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are numbers covered? or just left the same?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are numbers covered? or just left the same?

Should be left the same

}
}
}
return obj;
}

saveZitiSubData(params: any, returnTo: any) {
const controllerDomain = this.settingsService?.settings?.selectedEdgeController || '';
const serviceUrl = `${controllerDomain}/edge/management/v1`;
Expand Down
Loading