-
Notifications
You must be signed in to change notification settings - Fork 162
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
AF-2700: Create Heatmap internal component #1080
Merged
Merged
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c0c9185
AF-2700: Create Heatmap internal component
jesuino 8cab465
Only used external components are exported
jesuino de1683e
Review changes
jesuino ea974ce
Adding test for listAllComponents
jesuino 070a9aa
Removing static functions and using a class for component Api
jesuino bcbc832
improving process selector
jesuino 5e23b58
Making process selector expanded again
jesuino 014ca57
increasing version and removing sample logo
jesuino File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
...d/dashbuilder-services/src/main/java/org/dashbuilder/transfer/LayoutComponentsHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright 2019 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.dashbuilder.transfer; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.function.Predicate; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.Stream; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
import javax.inject.Inject; | ||
|
||
import org.dashbuilder.external.model.ExternalComponent; | ||
import org.uberfire.ext.layout.editor.api.PerspectiveServices; | ||
import org.uberfire.ext.layout.editor.api.editor.LayoutComponent; | ||
import org.uberfire.ext.layout.editor.api.editor.LayoutRow; | ||
import org.uberfire.ext.layout.editor.api.editor.LayoutTemplate; | ||
|
||
@ApplicationScoped | ||
public class LayoutComponentsHelper { | ||
|
||
@Inject | ||
private PerspectiveServices perspectiveServices; | ||
|
||
public List<String> findComponentsInTemplates(Predicate<String> pageFilter) { | ||
return perspectiveServices.listLayoutTemplates() | ||
.stream() | ||
.filter(lt -> pageFilter.test(lt.getName())) | ||
.map(LayoutTemplate::getRows) | ||
.flatMap(this::allComponentsStream) | ||
.map(lt -> lt.getProperties().get(ExternalComponent.COMPONENT_ID_KEY)) | ||
.filter(Objects::nonNull) | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
private Stream<LayoutComponent> allComponentsStream(List<LayoutRow> row) { | ||
return row.stream() | ||
.flatMap(r -> r.getLayoutColumns().stream()) | ||
.flatMap(cl -> Stream.concat(cl.getLayoutComponents().stream(), | ||
allComponentsStream(cl.getRows()))); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -96,6 +96,8 @@ public class DataTransferServicesTest { | |||
DataSetDefJSONMarshaller dataSetDefJSONMarshaller; | ||||
@Mock | ||||
ComponentLoader externalComponentLoader; | ||||
@Mock | ||||
LayoutComponentsHelper layoutComponentsHelper; | ||||
|
||||
Path componentsDir; | ||||
|
||||
|
@@ -124,7 +126,8 @@ public void setup() { | |||
pluginAddedEvent, | ||||
navTreeChangedEvent, | ||||
navTreeStorage, | ||||
externalComponentLoader); | ||||
externalComponentLoader, | ||||
layoutComponentsHelper); | ||||
} | ||||
|
||||
@After | ||||
|
@@ -301,8 +304,8 @@ public void testDoExportWithoutNavigation() throws Exception { | |||
|
||||
@Test | ||||
public void testDoExportWithComponents() throws Exception { | ||||
when(externalComponentLoader.loadExternal()).thenReturn(asList(component("c1"))); | ||||
|
||||
when(layoutComponentsHelper.findComponentsInTemplates((any()))).thenReturn(asList("c1")); | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Please remove these extra spaces. |
||||
createFile(perspectivesFS, "page1/perspective_layout", ""); | ||||
createFile(perspectivesFS, "page1/perspective_layout.plugin", ""); | ||||
|
||||
|
@@ -314,6 +317,13 @@ public void testDoExportWithComponents() throws Exception { | |||
// lost file in component Dir that should be ignored | ||||
createComponentFile("lost", "lostfile", "ignore-me-import"); | ||||
|
||||
// Other component that is not used so it should not be exported | ||||
createComponentFile("c2", "manifest.json", "manifest"); | ||||
createComponentFile("c2", "index.html", "html"); | ||||
createComponentFile("c2", "css/style.css", "style"); | ||||
createComponentFile("c2", "js/index.js", "js"); | ||||
|
||||
|
||||
dataTransferServices.doExport(DataTransferExportModel.exportAll()); | ||||
|
||||
ZipInputStream zis = getZipInputStream(); | ||||
|
95 changes: 95 additions & 0 deletions
95
...shbuilder-services/src/test/java/org/dashbuilder/transfer/LayoutComponentsHelperTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* | ||
* Copyright 2020 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.dashbuilder.transfer; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import org.dashbuilder.external.model.ExternalComponent; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.runners.MockitoJUnitRunner; | ||
import org.uberfire.ext.layout.editor.api.PerspectiveServices; | ||
import org.uberfire.ext.layout.editor.api.editor.LayoutColumn; | ||
import org.uberfire.ext.layout.editor.api.editor.LayoutComponent; | ||
import org.uberfire.ext.layout.editor.api.editor.LayoutRow; | ||
import org.uberfire.ext.layout.editor.api.editor.LayoutTemplate; | ||
|
||
import static java.util.Collections.singletonList; | ||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertTrue; | ||
import static org.mockito.Mockito.when; | ||
|
||
@RunWith(MockitoJUnitRunner.class) | ||
public class LayoutComponentsHelperTest { | ||
|
||
@Mock | ||
PerspectiveServices perspectiveServices; | ||
|
||
@InjectMocks | ||
LayoutComponentsHelper layoutComponentsHelper; | ||
|
||
@Test | ||
public void testComponentId() { | ||
String c1 = "c1"; | ||
String c2 = "c2"; | ||
LayoutTemplate lt = createLayoutTemplate("lt", c1, c2); | ||
when(perspectiveServices.listLayoutTemplates()).thenReturn(singletonList(lt)); | ||
|
||
List<String> components = layoutComponentsHelper.findComponentsInTemplates(p -> true); | ||
|
||
assertEquals(2, components.size()); | ||
assertEquals(components, Arrays.asList(c1, c2)); | ||
} | ||
|
||
public void testNoComponentId() { | ||
LayoutTemplate lt = createLayoutTemplate("lt"); | ||
when(perspectiveServices.listLayoutTemplates()).thenReturn(singletonList(lt)); | ||
|
||
List<String> components = layoutComponentsHelper.findComponentsInTemplates(p -> true); | ||
|
||
assertTrue(components.isEmpty()); | ||
} | ||
|
||
public void testPageFilter() { | ||
String c1 = "c1"; | ||
LayoutTemplate lt = createLayoutTemplate("lt", c1); | ||
when(perspectiveServices.listLayoutTemplates()).thenReturn(singletonList(lt)); | ||
|
||
List<String> components = layoutComponentsHelper.findComponentsInTemplates(p -> false); | ||
|
||
assertTrue(components.isEmpty()); | ||
} | ||
|
||
private LayoutTemplate createLayoutTemplate(String name, String... componentIds) { | ||
LayoutTemplate lt = new LayoutTemplate(name); | ||
LayoutRow lr = new LayoutRow(); | ||
LayoutColumn lc = new LayoutColumn(""); | ||
|
||
lr.add(lc); | ||
lt.addRow(lr); | ||
for (String componentId : componentIds) { | ||
LayoutComponent lComp = new LayoutComponent(); | ||
lComp.addProperty(ExternalComponent.COMPONENT_ID_KEY, componentId); | ||
lc.add(lComp); | ||
} | ||
return lt; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 0 additions & 59 deletions
59
...r-editor/src/main/java/org/dashbuilder/client/editor/external/ComponentGroupProvider.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.