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 'Open Workspace' button when logfile does not exist #1617

Conversation

emilyanndavis
Copy link
Member

Description

Fixes #1598 by hiding the 'Open Workspace' button when there is no logfile

Checklist

  • Updated HISTORY.rst and link to any relevant issue (if these changes are user-facing)
  • [n/a] Updated the user's guide (if needed)
  • Tested the Workbench UI (if relevant)

Copy link
Contributor

@davemfish davemfish left a comment

Choose a reason for hiding this comment

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

Thanks, @emilyanndavis . This looks good to me. It did make me think of a case where logfile is defined, but the file does not exist. This could happen if a user deletes the logfile from the workspace after the model run, and then goes back to the list of "Recent Runs", and opens that model tab. In this case the "Open Workspace" button would display, but be non-functional (I tried it out).

This is a very rare case, so I don't really think we need to handle it right now, but curious what you think.

Also, the PR that I merged earlier is causing a conflict in HISTORY in this PR. That's the only thing that really needs changing here. Thanks!

@@ -208,7 +208,7 @@ class InvestTab extends React.Component {
return (<div />);
}

const logDisabled = !logfile;
const logDoesNotExist = !logfile;
Copy link
Contributor

Choose a reason for hiding this comment

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

That is a better name!

Copy link
Member Author

Choose a reason for hiding this comment

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

It did make me think of a case where logfile is defined, but the file does not exist. This could happen if a user deletes the logfile from the workspace after the model run, and then goes back to the list of "Recent Runs", and opens that model tab.

Interesting point. I agree, it seems like that would be a very rare scenario. Still, it makes me wonder if we could refactor the open workspace method so that it doesn't require a logfile at all. You'd know better than I why it was written to be dependent on the logfile, but if there's a way to pass in just the workspace path instead, this could also be a more elegant solution to the issue resolved in this PR. Instead of hiding the Open Workspace button, leaving the user with a total mystery, we could keep the button active, and when it opened the workspace, it would become immediately clear to the user that the workspace is empty (which would still leave them with a mystery, but at least there's a clue as well).

Copy link
Contributor

Choose a reason for hiding this comment

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

I completely agree, de-coupling this button from the logfile makes a lot of sense. And opening up to an empty workspace sounds just fine. There's still probably a case where the workspace folder never exists and we need some error-handling.

I can't say for sure why it is the way it is. I guess the logfile is the most reliable artifact left behind by running an invest model, so it's possible that we were just avoiding some redundancy by not storing both the logfile path and the workspace path in an InvestJob instance, for example.

Also, the available electron.shell APIs must have been a factor: https://www.electronjs.org/docs/latest/api/shell
Maybe shell.openPath would work instead of showItemInFolder if given a path to a directory.

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 tested shell.openPath, and it does open a folder in Finder, if you pass in a path to a directory (whereas if you pass in a file path, it will actually open the file). I'm going to try going down that (ahem) path and put this PR on hold. If the other approach works, I'll abandon this PR; if I run into a snag, we can merge this PR as a stopgap.

@emilyanndavis
Copy link
Member Author

emilyanndavis commented Aug 28, 2024

Closing this in favor of PR 1618

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.

Open Workspace button is enabled even when there is no workspace
2 participants