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

Populate submitted values in site details #1043

Merged
merged 2 commits into from
Oct 30, 2024

Conversation

K-Markopoulos
Copy link
Collaborator

Issue #1038

Status and custom spotter api token values are not displayed in site details.

Changes

  • Add status initial value
  • Change api to return the spotter api token masked (only 4 last digits) if it has custom token. Unfortunately we cannot add a new computed property in the Site entity, because the spotterApiToken is not selected and therefore accessible by default, so we select all site properties and whitelist the properties we want to return.
  • On UI, show the masked token. User can provide a new one by clicking on the input field - then the old token is erased and the user can start typing the new token. If they leave the input without typing anything, the old token is filled back in. If the user wants to completely remove the custom token they uncheck the "Add custom api token" checkbox.

Note the logged spotterApiToken, when null the token is deleted, when undefined it's not changed and when it has value, the value is persisted.

Screencast.from.23-10-2024.05.16.05.webm

Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

✅ This pull request was sent to the PullRequest network for review. Expert reviewers are now being matched to your request based on the code's requirements. Stay tuned!

What to expect from this code review:
  • Comments posted to any areas of potential concern or improvement.
  • Detailed feedback or actions needed to resolve issues that are found.
  • Turnaround times vary, but we aim to be swift.

@K-Markopoulos you can click here to see the review status or cancel the code review job.

Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

PullRequest Breakdown

Reviewable lines of change

+ 88
- 46

58% TSX
35% TypeScript
7% TypeScript (tests)

Type of change

Feature - These changes are adding a new feature or improvement to existing code.

Copy link

github-actions bot commented Oct 23, 2024

Build succeeded and deployed at https://aqualink-app-1043.surge.sh
(hash ea8792d deployed at 2024-10-24T18:43:21)

Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

Great work here. I didn't spot any issues with these changes. 🎉

Image of Graham C Graham C


Reviewed with ❤️ by PullRequest

@Caesarh97
Copy link
Collaborator

Hi @K-Markopoulos,
Thank you for working on this. When testing it out, I added a spotter (not owned by Aqualink) and added its API token. I updated the page and went back to the dashboard. You can see the screenshot below. The Status "deployed" works fine, but I can not see the "Add a custom API token" box being checked or any value in the token textbox.

Regarding the second point in your changes, I didn’t fully understand it. If it's possible to show the last values that were entered for the API token, that's great. If not, that's fine and no need to do too much work on it. This view is locked to the SuperAdmin and the Site Manager for the specific site, so there's no need to mask the token or anything fancy (unless it has already been done). The "EDIT SITE DETAILS" view is only for the site manager of the specific site and the SuperAdmins to keep track of and troubleshoot what data has been entered into the database.

Screenshot 2024-10-23 at 8 59 51 AM

Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

PullRequest reviewed the updates made to #1043 since our last review was posted. This includes comments that have been posted by non-PullRequest reviewers. No further issues were found.

Reviewed by:

Image of Graham C Graham C

@K-Markopoulos
Copy link
Collaborator Author

Hi @Caesarh97,
If I'm not wrong, the generated preview link (https://aqualink-app-1043.surge.sh/) includes only the frontend changes of the PR. The backend changes have to be manually deployed to be available/testable and the spotter api token fix has some backend changes. @ericboucher can you help us with the backend deployment in order to test this PR?

The 2nd point is describing some technical things about the implementation. Basically, with the current implementation, once the token is persisted, it won't be fully visible in the UI. The user will be able to see only the last 4 characters of it. If they set "123456789", they will see "****6789".

@Caesarh97 Caesarh97 closed this Oct 24, 2024
@Caesarh97
Copy link
Collaborator

Hi @K-Markopoulos,
Got it now!

I tried it out, and it looks great! Thank you for all of your help.

@Caesarh97 Caesarh97 reopened this Oct 24, 2024
Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

✅ This pull request was sent to the PullRequest network for review. Expert reviewers are now being matched to your request based on the code's requirements. Stay tuned!

What to expect from this code review:
  • Comments posted to any areas of potential concern or improvement.
  • Detailed feedback or actions needed to resolve issues that are found.
  • Turnaround times vary, but we aim to be swift.

@K-Markopoulos you can click here to see the review status or cancel the code review job.

Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

PullRequest reviewed the updates made to #1043 up until the latest commit (ea8792d). No further issues were found.

Reviewed by:

Image of Graham C Graham C

@@ -151,10 +151,12 @@ export class Site {
@Column({ nullable: true, select: false, type: 'character varying' })
contactInformation?: string | null;

hasHobo: boolean;
hasHobo?: boolean;
Copy link
Member

Choose a reason for hiding this comment

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

Was this change needed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, since it was a required property in Site TS expected sites.service.ts::findeOne to return this property as well. The spread operator ...site tricked TS into thinking that hasHobo is included in the response, even though it was actually not. After removing the spread operator and explicitly defining the properties, TS throws an error that hasHobo is missing. I had to make this property optional to overcome this error and since it's not always defined, it makes sense to be optional.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, the alternative would be to actually have it defined no? Since it can only be true or false?

Copy link
Collaborator Author

@K-Markopoulos K-Markopoulos Oct 25, 2024

Choose a reason for hiding this comment

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

Yes, we can calculate the value and have it defined. I didn't add it in the first place, because I didn't want to change the structure of the response (the initial response didn't have hasHobo property) and it seems like it requires another query to calculate it.

const hasHoboDataSet = await hasHoboDataSubQuery(this.sourceRepository);

Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

PullRequest reviewed the updates made to #1043 since our last review was posted. This includes comments that have been posted by non-PullRequest reviewers. No further issues were found.

Reviewed by:

Image of Graham C Graham C

@ericboucher ericboucher merged commit 3e2be32 into master Oct 30, 2024
6 checks passed
@ericboucher ericboucher deleted the populate-site-submitted-details branch October 30, 2024 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants