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

Hide number of changes in UI, add it in debug logging utility #861

Merged
merged 6 commits into from
Aug 30, 2022

Conversation

apedroferreira
Copy link
Member

@apedroferreira apedroferreira commented Aug 26, 2022

Closes #781 (fix just for UX, not the number of updates yet)

  • Show either Saving changes... (saving), You have unsaved changes. (unsaved changes, not saving) or All changes saved! in UI
  • Create small debug logging infrastructure with a new TOOLPAD_DEBUG environment variable and utils/logs with a method for debug logs. Feel free to suggest changes or alternatives about this.
  • Log unsaved/saved DOM changes if debugging is active, this should be helpful in fixing any issues with number of updates
Screen.Recording.2022-08-26.at.17.24.44.mov

@apedroferreira apedroferreira self-assigned this Aug 26, 2022
@render
Copy link

render bot commented Aug 26, 2022

@oliviertassinari oliviertassinari requested a deployment to hide-number-of-changes - toolpad-db PR #861 August 26, 2022 16:29 — with Render Abandoned
@bharatkashyap
Copy link
Member

bharatkashyap commented Aug 27, 2022

  • Show either Saving changes... (saving), You have unsaved changes. (unsaved changes, not saving) or All changes saved! in UI

I would suggest the "All changes saved" to be transient (disappear after a few second delay), benchmarking based on how Google Docs does it:

Screen.Recording.2022-08-27.at.5.37.09.PM.mov

@Janpot
Copy link
Member

Janpot commented Aug 29, 2022

I would suggest the "All changes saved" to be transient (disappear after a few second delay), benchmarking based on how Google Docs does it:

Yes, taking it a bit further even, to reduce the amount of space it takes in the UI and avoid layout shifting, perhaps it makes sense to just use an icon + tooltip for this?
We could use color to indicated "all saved"/"has unsaved changes" and a spinner to indicate "saving"?

@apedroferreira
Copy link
Member Author

apedroferreira commented Aug 29, 2022

I would suggest the "All changes saved" to be transient (disappear after a few second delay), benchmarking based on how Google Docs does it:

Good idea! I'll add something like that.

Yes, taking it a bit further even, to reduce the amount of space it takes in the UI and avoid layout shifting, perhaps it makes sense to just use an icon + tooltip for this?
We could use color to indicated "all saved"/"has unsaved changes" and a spinner to indicate "saving"?

On one hand this makes the information we're conveying less clear, but this information is also a bit secondary, so I think this would make sense. I'll try something like this too.

@render
Copy link

render bot commented Aug 29, 2022

@oliviertassinari oliviertassinari requested a deployment to hide-number-of-changes - toolpad-db PR #861 August 29, 2022 21:20 — with Render Abandoned
@apedroferreira
Copy link
Member Author

apedroferreira commented Aug 30, 2022

With icon and tooltip (disappears after 4.5 seconds without changing, forgot to record that):

Screen.Recording.2022-08-30.at.17.29.39.mov

<Tooltip title={getSaveStateMessage(isSaving, hasUnsavedChanges)}>
<Box display="flex" flexDirection="row" alignItems="center">
{isSaving ? (
<CircularProgress size={16} color="inherit" sx={{ mr: 1 }} />
Copy link
Member

Choose a reason for hiding this comment

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

I feel that we don't need the CircularProgress icon for the isSaving state: it is not discernable to me in the video as a separate icon; perhaps we can add a "pulsating" animation to the icon in the isSaving state

Copy link
Member

Choose a reason for hiding this comment

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

Anyway, that could be a follow-up improvement! This looks great to me overall as a first step

Copy link
Member

Choose a reason for hiding this comment

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

it is not discernable to me in the video as a separate icon

keep in mind this video is made on a locally running app, irl it will often take longer to complete the request

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah it's showing as long as saving is true, looks like in dev it's a pretty short time.
lmk if you think we should show the loader when there are unsaved changes even though the saving flag is false

Copy link
Member

@Janpot Janpot left a comment

Choose a reason for hiding this comment

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

Looking good 👍

we could also use the CloudDone icon for this

@apedroferreira
Copy link
Member Author

Looking good 👍

we could also use the CloudDone icon for this

ok i'll make a quick switch before merging, it's more techy i guess :D

@apedroferreira apedroferreira merged commit 43a7a01 into master Aug 30, 2022
@apedroferreira apedroferreira deleted the hide-number-of-changes branch August 30, 2022 17:18
Copy link
Member

@Janpot Janpot left a comment

Choose a reason for hiding this comment

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

Had a few more comments

@@ -0,0 +1,6 @@
export function debugLog(message: string, color: string): void {
Copy link
Member

Choose a reason for hiding this comment

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

@apedroferreira This looks like a function that is only there to circumvent // eslint-disable-next-line no-console. Can't we just use console.log, so that we don't get tempted to start logging everything?

Copy link
Member Author

@apedroferreira apedroferreira Aug 31, 2022

Choose a reason for hiding this comment

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

i made this a separate function to abstract away the environment variable check and the color in the logs. but sure, we can write it every time too. i'll change it.

Copy link
Member

@Janpot Janpot Aug 31, 2022

Choose a reason for hiding this comment

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

Perhaps we can leave out the color and the env check?

  • Not sure we need the env check if we use logging sparingly
  • Not sure what the color brings, but if we use it, we should probably think about the semantic meaning of it

Copy link
Member Author

Choose a reason for hiding this comment

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

i was thinking maybe we didn't want to show certain logs to end users so i added this environment variable, we could just show them to everyone though.
about the color, i could have made the function only take certain values such as success, warning, error, info, but i'm fine with not having colors for now especially if we don't have cases for all these types of logs yet.

<Box display="flex" flexDirection="row" alignItems="center">
<CircularProgress size={16} color="inherit" sx={{ mr: 1 }} />
</Box>
{isSaveStateVisible ? (
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we should hide the icon. It will cause layout shift and prevent us from adding more things in the header

Copy link
Member Author

Choose a reason for hiding this comment

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

ok, i can use something like visibility: hidden

Copy link
Member

Choose a reason for hiding this comment

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

What's the reason to hide it exactly?

Copy link
Member Author

@apedroferreira apedroferreira Aug 31, 2022

Choose a reason for hiding this comment

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

oh i see, i was thinking the save state wasn't that helpful after a while so it could stay hidden - that's also what Bharat proposed and i implemented with the timeout (it disappears after a few seconds). but we can keep the green cloud there as long as it's saved too.

'orange',
);
} else if (previousUnsavedChanges > 0) {
debugLog('All changes saved!', 'green');
Copy link
Member

Choose a reason for hiding this comment

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

To reduce the amount of logs, perhaps we can just do one message "Saved X changes"?

Copy link
Member Author

@apedroferreira apedroferreira Aug 31, 2022

Choose a reason for hiding this comment

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

i can change it, just has a bit less visibility into changes that don't all happen together and the save state. maybe we don't need all that though.

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.

Toolpad shows 2 unsaved changes when adding a component
4 participants