Skip to content

Commit 02534ea

Browse files
andyclaude
andcommitted
Organizer: offer Upload File only inside a calculation (#97)
Upload was offered for any expandable node, so it appeared on projects and on the server root as well as on jobs -- where it reads like a general-purpose file manager action and nobody could say what it was for. Reported from a live session: "The File/Upload File is not clear in terms of what it is supposed to be used for ... Could be in Tools", then clarified: it should appear only when you are in a job. Now gated on the selected node being a calculation. Download is unchanged -- still offered for anything that is not a collection, i.e. an actual file -- and a project or the server root now gets neither, which is the point. Null-guarded: getResource() can legitimately return 0 on a node whose resource failed to load, a shape this file has been bitten by before. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFMUNbw2UpRPmgsqviAowb
1 parent 993acb9 commit 02534ea

1 file changed

Lines changed: 27 additions & 6 deletions

File tree

‎src/apps/organizer/CalcMgr.C‎

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2370,13 +2370,34 @@ void CalcMgr::getFileMenu(wxMenu & menu, WxResourceTreeItemData * itemData)
23702370
// (The import entry used to be added here, gated on the selected node
23712371
// being a "project". It is now added unconditionally below -- see there.)
23722372

2373+
// Upload only makes sense inside a calculation -- putting a file into a
2374+
// job's own directory. It used to be offered for ANY expandable node,
2375+
// so it also appeared on projects and on the server root, where it
2376+
// reads like a general-purpose file manager action and nobody could say
2377+
// what it was for. Reported from a live session 2026-09-22.
2378+
//
2379+
// Download is unchanged: it is offered for anything that is not a
2380+
// collection, i.e. an actual file.
23732381
bool isCollection = p_treeCtrl->setExpandable(itemData);
2374-
wxMenuItem * tmpMenuItem = new wxMenuItem(&menu,
2375-
isCollection ? wxID_UPLOAD : wxID_DOWNLOAD,
2376-
_(isCollection ? "&Upload File..." : "&Download File..."),
2377-
_T(""), wxITEM_NORMAL);
2378-
// tmpMenuItem->SetBitmap(ewxBitmap(isCollection?"upload.xpm":"download.xpm"));
2379-
menu.Append(tmpMenuItem);
2382+
bool isCalculation = false;
2383+
Resource *menuRes = itemData->getResource();
2384+
if (menuRes != (Resource*)0) {
2385+
isCalculation = (menuRes->getContentType() ==
2386+
ResourceDescriptor::CT_CALCULATION);
2387+
}
2388+
2389+
wxMenuItem * tmpMenuItem = (wxMenuItem*)0;
2390+
if (isCollection && isCalculation) {
2391+
tmpMenuItem = new wxMenuItem(&menu, wxID_UPLOAD, _("&Upload File..."),
2392+
_T(""), wxITEM_NORMAL);
2393+
} else if (!isCollection) {
2394+
tmpMenuItem = new wxMenuItem(&menu, wxID_DOWNLOAD,
2395+
_("&Download File..."),
2396+
_T(""), wxITEM_NORMAL);
2397+
}
2398+
if (tmpMenuItem != (wxMenuItem*)0) {
2399+
menu.Append(tmpMenuItem);
2400+
}
23802401

23812402
menu.AppendSeparator();
23822403
}

0 commit comments

Comments
 (0)