-
Notifications
You must be signed in to change notification settings - Fork 76
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: refresh ursadb page and add alert about successful submit #448
base: master
Are you sure you want to change the base?
Conversation
@@ -130,11 +269,14 @@ class IndexPageInner extends Component { | |||
<div className="my-2">{`Newest file in the queue: ${this.state.newestFile}`}</div> | |||
)} | |||
{this.state.oldestFile && ( | |||
<div className="my-2">{`Oldest file in the queue`}</div> | |||
<div className="my-2">{`Oldest file in the queue: ${this.state.oldestFile}`}</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 missed that previously
@@ -130,11 +269,14 @@ class IndexPageInner extends Component { | |||
<div className="my-2">{`Newest file in the queue: ${this.state.newestFile}`}</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at it more deeply, the message looks like:
Newest file in the queue: 2025-03-04T12:58:25.030027
The date format is a bit over the top (I know it's the ISO format). JS is not very good at formatting dates, but maybe we
can convert it to 2025-03-04 12:58
at least?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I also remove seconds or maybe they are still relevant? For now maybe I'll leave seconds, later this can easily be changed by changing slicing index.
fileOrFiles(length) { | ||
return `file${length > 1 ? "s" : ""}`; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, I wondered about suggesting this refactoring in the previous PR.
But it's usually handled a bit differently, with a helper like pluralize
:
const pluralize = (count, noun) =>
`${count} ${noun}${count !== 1 ? "s" : ''}`;
This is a bit more generouns, as you can use it for things other than file. More importantly, you don't have to do
${this.state.alertShowFileLen} ${this.fileOrFiles(this.state.alertShowFileLen)}!
and instead can just
${pluralize("files", this.state.alertShowFileLen}}!
which is nice I guess
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I'll generalize this function to all nouns, but I think it would be better to leave first ${count} out of this function.
)} | ||
{this.state.alertShowCleared && ( | ||
<IndexClearedPage | ||
msg={`Successfully cleared ${ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully cleared false file from queue default!
I think the variable here should be alertShowCleared
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if I understand - this alert won't show if alertShowCleared
is false (this variable is boolean). Variable alertShowFileLen
stores amount of submitted files and this is the value we want to return in feedback. Is something not presenting correctly on your version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
step one: add 1 file
step two: add 2 files
now there are three files in the queue (verify by select * from queuedfile;
)
step three: clear queue
this should clear three fules, but the result is either:
or
depending on if the previous banner was closed. Also in the latter situation, I can now add one file again, and get:
so I believe there is some variable confusion here 🦆
You're right that my comment was wrong, I think that the issue is that handleClearQueue
doesn't set FileLen? But I leave this to you, anyway something's wrong I belive
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I mistakenly used the same variable used to store sent files to also show amount of cleared files. Unfortunately I think the best way to handle this issue was to simplify cleared queue alert not to use any numbers, since it's non-obvious how many files are currently in queue after submitting some amount (and later if queued files would happen to change status server-side whilst page would not update).
{`Add to queue${ | ||
fileLen > 0 | ||
? ` (${fileLen} file${ | ||
fileLen > 1 ? "s" : "" | ||
})` | ||
? ` (${fileLen} ${this.fileOrFiles( | ||
fileLen | ||
)})` | ||
: "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same comment about pluralize here - it will work if you reorder it to add N files to queue
which also makes it a bit more idiomatic english
src/mqueryfront/src/App.css
Outdated
top: 50%; | ||
left: 50%; | ||
transform: translate(-50%, -50%); | ||
z-index: auto; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't z-index: auto
the default value? Unless there's some inheritance going on here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leftover from modal styling 😁 Will clear this.
)} | ||
{this.state.alertShowCleared && ( | ||
<IndexClearedPage | ||
msg={`Successfully cleared ${ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
step one: add 1 file
step two: add 2 files
now there are three files in the queue (verify by select * from queuedfile;
)
step three: clear queue
this should clear three fules, but the result is either:
or
depending on if the previous banner was closed. Also in the latter situation, I can now add one file again, and get:
so I believe there is some variable confusion here 🦆
You're right that my comment was wrong, I think that the issue is that handleClearQueue
doesn't set FileLen? But I leave this to you, anyway something's wrong I belive
Your checklist for this pull request
What is the current behaviour?
Currently theres no feedback to user about successful submit to UrsaDB page.
What is the new behaviour?
This PR introduces new alert about successful POST request and clears form upon submission
Test plan
Click through new page and check for any unexpected behavior
Closing issues
fixes #issuenumber