Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jay-hodgson committed Jan 24, 2025
1 parent 957d38c commit 8869e29
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -675,10 +675,21 @@ public void showSelectedTabs() {
projectHeader.getId(),
getTabVisibilityCallback(EntityArea.WIKI, wikiTab.asTab())
);
synapseJavascriptClient.isFileOrFolder(
projectHeader.getId(),
// SWC-7233: It's possible that the Project has no children visible to the current user.
// But show the tab if the filesEntityBundle points to a target FileEntity or Folder
if (
currentTargetEntityBundle != null &&
(currentTargetEntityBundle.getEntity() instanceof FileEntity ||
currentTargetEntityBundle.getEntity() instanceof Folder)
) {
getTabVisibilityCallback(EntityArea.FILES, filesTab.asTab())
);
.onSuccess(true);
} else {
synapseJavascriptClient.isFileOrFolder(
projectHeader.getId(),
getTabVisibilityCallback(EntityArea.FILES, filesTab.asTab())
);
}
synapseJavascriptClient.isEntityRefCollectionView(
projectHeader.getId(),
getTabVisibilityCallback(EntityArea.DATASETS, datasetsTab.asTab())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.sagebionetworks.repo.model.EntityHeader;
import org.sagebionetworks.repo.model.EntityPath;
import org.sagebionetworks.repo.model.FileEntity;
import org.sagebionetworks.repo.model.Folder;
import org.sagebionetworks.repo.model.Link;
import org.sagebionetworks.repo.model.Project;
import org.sagebionetworks.repo.model.Reference;
Expand Down Expand Up @@ -94,6 +95,9 @@ public class EntityPageTopTest {
@Mock
FileEntity mockFileEntity;

@Mock
Folder mockFolderEntity;

@Mock
TableEntity mockTableEntity;

Expand Down Expand Up @@ -1272,6 +1276,54 @@ public void testContentOneTabShown() {
verify(mockDockerInnerTab, atLeastOnce()).setTabListItemVisible(false);
}

// SWC-7233 (File test)
@Test
public void testFilesTabShownIfFileConfigured() {
Synapse.EntityArea area = null;
String areaToken = null;
Long versionNumber = null;
AsyncMockStubber
.callSuccessWith(false)
.when(mockSynapseJavascriptClient)
.isFileOrFolder(anyString(), any(AsyncCallback.class));

when(mockEntityBundle.getEntity()).thenReturn(mockFileEntity);
pageTop.configure(
mockEntityBundle,
versionNumber,
mockProjectHeader,
area,
areaToken
);
verify(mockSynapseJavascriptClient, never())
.isFileOrFolder(anyString(), any(AsyncCallback.class));
verify(mockFilesInnerTab, atLeastOnce()).setTabListItemVisible(true);
}

// SWC-7233 (Folder test)
@Test
public void testFilesTabShownIfFolderConfigured() {
Synapse.EntityArea area = null;
String areaToken = null;
Long versionNumber = null;
AsyncMockStubber
.callSuccessWith(false)
.when(mockSynapseJavascriptClient)
.isFileOrFolder(anyString(), any(AsyncCallback.class));

when(mockEntityBundle.getEntity()).thenReturn(mockFolderEntity);
pageTop.configure(
mockEntityBundle,
versionNumber,
mockProjectHeader,
area,
areaToken
);
verify(mockSynapseJavascriptClient, never())
.isFileOrFolder(anyString(), any(AsyncCallback.class));
verify(mockFilesInnerTab, atLeastOnce()).setTabListItemVisible(true);
}

@Test
public void testUpdateEntityBundleToLink() {
Synapse.EntityArea area = null;
Expand Down

0 comments on commit 8869e29

Please sign in to comment.