-
Notifications
You must be signed in to change notification settings - Fork 72
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: Add message explaining that build logs are deleted after 180 days. #4402
fix: Add message explaining that build logs are deleted after 180 days. #4402
Conversation
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.
this looks awesome :)
If you want to try this out locally the easiest route is probably to hardcode a |
{buildTooOld(buildDetails) && ( | ||
<div> | ||
<SiteBuildLogTable buildLogs={['Builds more than 180 days old are deleted according to platform policy.']} /> | ||
</div> | ||
)} | ||
{(!logs || logs?.length === 0) && ( | ||
<div> | ||
<SiteBuildLogTable buildLogs={['This build does not have any build logs.']} /> |
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.
This should work, but I haven't run it locally
{buildTooOld(buildDetails) && ( | |
<div> | |
<SiteBuildLogTable buildLogs={['Builds more than 180 days old are deleted according to platform policy.']} /> | |
</div> | |
)} | |
{(!logs || logs?.length === 0) && ( | |
<div> | |
<SiteBuildLogTable buildLogs={['This build does not have any build logs.']} /> | |
{(!logs || logs?.length === 0) && ( | |
<div> | |
{buildTooOld(buildDetails) && ( | |
<SiteBuildLogTable buildLogs={['Builds more than 180 days old are deleted according to platform policy.']} /> | |
)} | |
{!buildTooOld(buildDetails) && ( | |
<SiteBuildLogTable buildLogs={['This build does not have any build logs.']} /> | |
)} |
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.
It just needs a little more to work:
{buildTooOld(buildDetails) && ( | |
<div> | |
<SiteBuildLogTable buildLogs={['Builds more than 180 days old are deleted according to platform policy.']} /> | |
</div> | |
)} | |
{(!logs || logs?.length === 0) && ( | |
<div> | |
<SiteBuildLogTable buildLogs={['This build does not have any build logs.']} /> | |
{(!logs || logs?.length === 0) && ( | |
<div> | |
{buildTooOld(buildDetails) && ( | |
<SiteBuildLogTable buildLogs={['Builds more than 180 days old are deleted according to platform policy.']} /> | |
)} | |
{!buildTooOld(buildDetails) && ( | |
<SiteBuildLogTable buildLogs={['This build does not have any build logs.']} /> | |
)} | |
</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.
Oh, I may have just snipped that in a different place from you. Never mind.
Here's the approach I came up with though:
{(() => {
if (!logs || logs?.length === 0) {
if (buildTooOld(buildDetails)) {
return (
<div>
<SiteBuildLogTable buildLogs={['Builds more than 180 days old are deleted according to platform policy.']} />
</div>
);
}
return (
<div>
<SiteBuildLogTable buildLogs={['This build does not have any build logs.']} />
</div>
);
}
return null;
})()}
Which do you think is more readable?
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.
oh i like this one just fine! you don't have to wrap the <SiteBuildLogTable>
in a <div>
if you don't need to for layout purposes. It's just that the return ()
statement can only have one parent node, so if you have two or more elements, you wrap them in a div or <>
. Each of these is in their own return, and only one element, so you could save yourself 4 lines if you like :)
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.
Good point, thanks!
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.
What about?
{buildTooOld(buildDetails) ? (
<SiteBuildLogTable
buildLogs={[
'Builds more than 180 days old are deleted according to platform policy.',
]}
/>
) : (
<>
{logs && logs?.length > 0 ? (
<SiteBuildLogTable buildLogs={logs} buildState={state} />
) : (
<SiteBuildLogTable
buildLogs={['This build does not have any build logs.']}
/>
)}
</>
)}
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.
Do you prefer this to what I pushed, @apburnes?
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 was wondering if a ternary operator would 1) work, 2) be easy to read. I could see a case for either approach; they're basically indistinguishable. I think ternaries are cool, but they're sometimes hard to read. I'm neutral on this :)
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.
Giving this a gentle bump, @apburnes. I think I'd already pushed my approach to this when you suggested another way here, but I don't know whether you'd like me to switch to your version or were just in the process of suggesting it when I applied mine.
tl/dr: Am I waiting for you to re-review or are you waiting for me to switch to your suggested implementation?
</div> | ||
)} | ||
{(() => { | ||
if (!logs || logs?.length === 0) { |
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.
Is there a scenario where there are build logs and the build is over 180 days?
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, the scenario you found on dev where the build log was still being shown on an old build that still had build logs: https://pages-dev.cloud.gov/sites/2/builds/5/logs
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.
That's why we made this change.
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 logic still shows both the 180 day message and the build logs.
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.
It only checks buildTooOld
if there are no build logs.
<SiteBuildLogTable buildLogs={['This build does not have any build logs.']} /> | ||
</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.
This is the only place in the frontend we use the closure syntax to display components. We don't have solid conventions for writing UI components but It is introducing another pattern for logic control. Should we settle on a convention and document it?
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 newest to React JSX, so I defer to y'all on which convention is wisest.
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 what the immediately invoked function does here so I'd remove if it isn't necessary
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.
Refactored into a separate function at Andrew's suggestion.
}); | ||
const { isLoading, buildDetails } = build; | ||
|
||
useEffect(() => { |
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.
Since we use this hook in two places, what do you think about creating a new build details hook in the hooks
directory and importing it to the paces we use it?
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.
OK, I'll see what I can do.
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.
Refactored into hooks
962526d
to
f0a1847
Compare
@@ -55,8 +55,19 @@ const SiteBuildTasks = () => { | |||
const buildId = parseInt(buildIdStr, 10); | |||
const [buildTasks, setBuildTasks] = useState([]); | |||
|
|||
const [build, setBuild] = useState({ |
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.
You can replace this useState and useEffect with the new buildDetails hook.
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.
Aw shoot I forgot about build tasks. On it.
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.
How 'bout now?
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.
LGTM. Thanks.
64c93be
to
8facede
Compare
Fixes #4379
Changes proposed in this pull request:
hooks
security considerations
None. Adds explanatory and status information to the user interface regarding details already present.