Skip to content

Commit 538518e

Browse files
briantangSanjeevani19
authored andcommitted
DHFPROD-9614: Disable Concept Actions Based on ML Version
1 parent c1f6537 commit 538518e

File tree

13 files changed

+172
-39
lines changed

13 files changed

+172
-39
lines changed

marklogic-data-hub-central/src/main/java/com/marklogic/hub/central/controllers/EnvironmentController.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ public SystemInfo getSystemInfo(HttpSession session) {
9696
info.stagingDb = versionInfo.getStagingDbName();
9797
info.finalDb = versionInfo.getFinalDbName();
9898
info.jobsDb = versionInfo.getJobsDbName();
99+
info.supportConcepts = versionInfo.getSupportConcepts();
99100
info.pendoKey = pendoKeyProvider.getPendoKey();
100101
info.sessionTimeout = environment.getProperty("server.servlet.session.timeout");
101102
Object hubCentralSessionToken = session.getAttribute("hubCentralSessionToken");
@@ -121,6 +122,7 @@ public static class SystemInfo {
121122
public String sessionTimeout;
122123
public String sessionToken;
123124
public String pendoKey;
125+
public Boolean supportConcepts;
124126
}
125127
}
126128

marklogic-data-hub-central/ui/e2e/cypress/integration/curation/run/runFlow.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,8 @@ describe("Run Tile tests", () => {
225225
runPage.clickStepInsidePopover("#merge-xml-person");
226226

227227
runPage.clickStepInsidePopover("#mapPersonXML");
228-
runPage.clickStepInsidePopover("#match-xml-person");
229228
runPage.clickStepInsidePopover("#master-person");
229+
runPage.clickStepInsidePopover("#match-xml-person");
230230

231231
cy.log("**Run Flow with selected steps**");
232232
cy.intercept("GET", "/api/jobs/**").as("runResponse");

marklogic-data-hub-central/ui/e2e/cypress/integration/explore/crudQueriesfromExplore.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ describe("save/manage queries scenarios, developer role", () => {
256256
browsePage.getResetConfirmationNoClick();
257257
entitiesSidebar.openBaseEntityDropdown();
258258
entitiesSidebar.selectBaseEntityOption("Person");
259-
entitiesSidebar.getBaseEntityOption("Person").should("be.visible");
259+
entitiesSidebar.getBaseEntityOption("Person").scrollIntoView().should("be.visible");
260260
entitiesSidebar.openBaseEntityFacets("Person");
261261
browsePage.getFacetItemCheckbox("lname", "Bates").click();
262262
browsePage.getSelectedFacets().should("exist");

marklogic-data-hub-central/ui/e2e/cypress/integration/explore/jsonTableViewValidations.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ describe("json scenario for table on browse documents page", () => {
123123
entitiesSidebar.getMainPanelSearchInput("10248");
124124
entitiesSidebar.openBaseEntityDropdown();
125125
entitiesSidebar.selectBaseEntityOption("All Entities");
126-
entitiesSidebar.getBaseEntityOption("All Entities").should("be.visible");
126+
entitiesSidebar.getBaseEntityOption("All Entities").scrollIntoView().should("be.visible");
127127
entitiesSidebar.getApplyFacetsButton().click();
128128
browsePage.waitForSpinnerToDisappear();
129129
browsePage.totalNumberDocuments("1");

marklogic-data-hub-central/ui/src/components/common/hc-checkbox/hc-checkbox.tsx

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import HCTooltip from "../hc-tooltip/hc-tooltip";
44

55
interface Props {
66
id: string;
7-
tooltip?: string;
7+
tooltip?: any;
88
handleClick: Function;
99
value: any;
1010
label?: string;
@@ -42,16 +42,30 @@ const HCCheckbox: React.FC<Props> = (props) => {
4242
style={cursorDisabled ? {marginTop: "0", verticalAlign: "middle", cursor: "not-allowed"} : {marginTop: "0", verticalAlign: "middle"}}
4343
/>
4444
:
45-
<FormCheck.Input
46-
type="checkbox"
47-
value={value}
48-
checked={checked}
49-
onChange={(e) => handleClick(e)}
50-
onClick={(e) => e.stopPropagation()}
51-
data-testid={dataTestId}
52-
aria-label={ariaLabel}
53-
style={cursorDisabled ? {marginTop: "0", verticalAlign: "middle", cursor: "not-allowed"} : {marginTop: "0", verticalAlign: "middle"}}
54-
/>
45+
tooltip ?
46+
<HCTooltip text={tooltip} placement={placementTooltip ? placementTooltip: "top"} id={`${id}-tooltip`}>
47+
<FormCheck.Input
48+
type="checkbox"
49+
value={value}
50+
checked={checked}
51+
onChange={(e) => handleClick(e)}
52+
onClick={(e) => e.stopPropagation()}
53+
data-testid={dataTestId}
54+
aria-label={ariaLabel}
55+
style={cursorDisabled ? {marginTop: "0", verticalAlign: "middle", cursor: "not-allowed"} : {marginTop: "0", verticalAlign: "middle"}}
56+
/>
57+
</HCTooltip>
58+
:
59+
<FormCheck.Input
60+
type="checkbox"
61+
value={value}
62+
checked={checked}
63+
onChange={(e) => handleClick(e)}
64+
onClick={(e) => e.stopPropagation()}
65+
data-testid={dataTestId}
66+
aria-label={ariaLabel}
67+
style={cursorDisabled ? {marginTop: "0", verticalAlign: "middle", cursor: "not-allowed"} : {marginTop: "0", verticalAlign: "middle"}}
68+
/>
5569
}
5670
{label ? getLabel() : children}
5771
</FormCheck>;

marklogic-data-hub-central/ui/src/components/explore/graph-view-explore.tsx renamed to marklogic-data-hub-central/ui/src/components/explore/graph-view-explore/graph-view-explore.tsx

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import {getViewSettings, setViewSettings} from "@util/user-context";
44

55
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
66
import FormCheck from "react-bootstrap/FormCheck";
7-
import GraphExploreSidePanel from "./graph-explore-side-panel/graph-explore-side-panel";
8-
import GraphVisExplore from "./graph-vis-explore/graph-vis-explore";
7+
import GraphExploreSidePanel from "../graph-explore-side-panel/graph-explore-side-panel";
8+
import GraphVisExplore from "../graph-vis-explore/graph-vis-explore";
99
import {ModelingTooltips} from "@config/tooltips.config";
1010
import {QuestionCircleFill} from "react-bootstrap-icons";
1111
import {SearchContext} from "@util/search-context";
@@ -14,9 +14,11 @@ import {faFileExport} from "@fortawesome/free-solid-svg-icons";
1414
import styles from "./graph-view-explore.module.scss";
1515
import {themeColors} from "@config/themes.config";
1616
import tooltipsConfig from "@config/explorer-tooltips.config";
17+
import {getEnvironment} from "@util/environment";
1718

1819
type Props = {
1920
entityTypeInstances: any;
21+
graphConceptsSearchSupported: boolean;
2022
graphView: any;
2123
setViewConcepts: (viewConcepts: boolean) => void;
2224
setPhysicsAnimation: (physicsAnimation: boolean) => void;
@@ -35,6 +37,8 @@ const GraphViewExplore: React.FC<Props> = (props) => {
3537
const [exportPngButtonClicked, setExportPngButtonClicked] = useState(false);
3638
const [viewConcepts, toggleConcepts] = useState(storage.explore?.graphView?.concepts !== undefined ? storage.explore?.graphView?.concepts : true);
3739
const [physicsAnimation, togglePhysicsAnimation] = useState(storage.explore?.graphView?.physicsAnimation !== undefined? storage.explore?.graphView?.physicsAnimation : true);
40+
const {exploreSidebar} = tooltipsConfig;
41+
3842

3943
const {
4044
savedNode,
@@ -141,13 +145,28 @@ const GraphViewExplore: React.FC<Props> = (props) => {
141145
id="toggle-concepts"
142146
type="switch"
143147
>
144-
<HCCheckbox
145-
id="concepts-switch"
146-
label="Concepts"
147-
value={viewConcepts}
148-
checked={viewConcepts}
149-
handleClick={(e) => handleConceptsView(e)}
150-
/>
148+
{!props.graphConceptsSearchSupported ?
149+
<HCCheckbox
150+
id="concepts-switch"
151+
label="Concepts"
152+
ariaLabel="concepts-switch"
153+
value={false}
154+
checked={false}
155+
cursorDisabled={true}
156+
tooltip={exploreSidebar.versionLimitedConcepts(getEnvironment().marklogicVersion)}
157+
handleClick={() => { return; }}
158+
/>
159+
:
160+
<HCCheckbox
161+
id="concepts-switch"
162+
label="Concepts"
163+
ariaLabel="concepts-switch"
164+
tooltip={null}
165+
value={viewConcepts}
166+
checked={viewConcepts}
167+
handleClick={(e) => handleConceptsView(e)}
168+
/>
169+
}
151170
</FormCheck>
152171
<HCTooltip id="concept" text={graphViewTooltips.concept} placement="top">
153172
<QuestionCircleFill aria-label="icon: question-circle" color={themeColors.defaults.questionCircle} size={13} className={styles.infoIcon} />

marklogic-data-hub-central/ui/src/components/sidebar/sidebar.test.tsx

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from "react";
2-
import {fireEvent, render} from "@testing-library/react";
2+
import {fireEvent, render, wait} from "@testing-library/react";
33
import Sidebar from "./sidebar";
44
import searchPayloadFacets from "../../assets/mock-data/explore/search-payload-facets";
55
import {entityFromJSON, entityParser} from "../../util/data-conversion";
@@ -48,10 +48,72 @@ describe("Sidebar createdOn face time window dropdown", () => {
4848
currentBaseEntities={[]}
4949
setCurrentBaseEntities={jest.fn()}
5050
entityIndicatorData={entityIndicatorData}
51+
graphConceptsSearchSupported={true}
5152
/>);
5253
expect(getByText("Select time")).toBeInTheDocument();
5354
});
5455

56+
test("Verify version disabled/enabled concepts", async () => {
57+
const {getByTestId, getByLabelText, rerender, queryByLabelText} = render(<Sidebar
58+
entityDefArray={entityDefArray}
59+
facets={searchPayloadFacets}
60+
selectedEntities={[]}
61+
facetRender = {jest.fn()}
62+
checkFacetRender = {jest.fn()}
63+
currentRelatedEntities={new Map<string, any>()}
64+
currentRelatedConcepts={conceptsMap}
65+
viewConcepts={true}
66+
setCurrentRelatedConcepts={jest.fn()}
67+
setHubArtifactsVisibilityPreferences={jest.fn()}
68+
hideDataHubArtifacts={false}
69+
graphView={true}
70+
cardView={false}
71+
setDatabasePreferences={jest.fn()}
72+
greyFacets={[]}
73+
setEntitySpecificPanel={jest.fn()}
74+
entitiesWithRelatedConcepts={{}}
75+
entityRelationships={{}}
76+
setCurrentRelatedEntities={jest.fn()}
77+
currentBaseEntities={[]}
78+
setCurrentBaseEntities={jest.fn()}
79+
entityIndicatorData={entityIndicatorData}
80+
graphConceptsSearchSupported={false}
81+
/>);
82+
fireEvent.mouseOver(getByTestId("related-concepts-panel"));
83+
await wait(() => expect(getByLabelText(`concepts-version-tooltip`)).toBeInTheDocument());
84+
expect(getByLabelText("related-concepts-checkbox")).toBeDisabled();
85+
86+
//verify positive scenario where concepts are enabled
87+
rerender(<Sidebar
88+
entityDefArray={entityDefArray}
89+
facets={searchPayloadFacets}
90+
selectedEntities={[]}
91+
facetRender = {jest.fn()}
92+
checkFacetRender = {jest.fn()}
93+
currentRelatedEntities={new Map<string, any>()}
94+
currentRelatedConcepts={conceptsMap}
95+
viewConcepts={true}
96+
setCurrentRelatedConcepts={jest.fn()}
97+
setHubArtifactsVisibilityPreferences={jest.fn()}
98+
hideDataHubArtifacts={false}
99+
graphView={true}
100+
cardView={false}
101+
setDatabasePreferences={jest.fn()}
102+
greyFacets={[]}
103+
setEntitySpecificPanel={jest.fn()}
104+
entitiesWithRelatedConcepts={{}}
105+
entityRelationships={{}}
106+
setCurrentRelatedEntities={jest.fn()}
107+
currentBaseEntities={[]}
108+
setCurrentBaseEntities={jest.fn()}
109+
entityIndicatorData={entityIndicatorData}
110+
graphConceptsSearchSupported={true}
111+
/>);
112+
113+
fireEvent.mouseOver(getByTestId("related-concepts-panel"));
114+
await wait(() => expect(queryByLabelText(`concepts-version-tooltip`)).not.toBeInTheDocument());
115+
});
116+
55117
test("Verify createdOn dropdown is selected", () => {
56118
const {getByText, getByPlaceholderText, getByLabelText} = render(<Sidebar
57119
entityDefArray={entityDefArray}
@@ -76,6 +138,7 @@ describe("Sidebar createdOn face time window dropdown", () => {
76138
currentBaseEntities={[]}
77139
setCurrentBaseEntities={jest.fn()}
78140
entityIndicatorData={entityIndicatorData}
141+
graphConceptsSearchSupported={true}
79142
/>);
80143
expect(getByText("Select time")).toBeInTheDocument();
81144
fireEvent.keyDown(getByLabelText("date-select"), {key: "ArrowDown"});
@@ -108,6 +171,7 @@ describe("Sidebar createdOn face time window dropdown", () => {
108171
currentBaseEntities={[]}
109172
setCurrentBaseEntities={jest.fn()}
110173
entityIndicatorData={entityIndicatorData}
174+
graphConceptsSearchSupported={true}
111175
/>);
112176
expect(document.querySelector("#hub-properties .accordion-button")).toHaveAttribute("aria-expanded", "true");
113177
userEvent.click(getByText("Hub Properties"));
@@ -169,6 +233,7 @@ describe("Sidebar createdOn face time window dropdown", () => {
169233
currentBaseEntities={[]}
170234
setCurrentBaseEntities={jest.fn()}
171235
entityIndicatorData={entityIndicatorData}
236+
graphConceptsSearchSupported={true}
172237
/>
173238
);
174239

@@ -221,6 +286,7 @@ describe("Sidebar createdOn face time window dropdown", () => {
221286
currentBaseEntities={[]}
222287
setCurrentBaseEntities={jest.fn()}
223288
entityIndicatorData={entityIndicatorData}
289+
graphConceptsSearchSupported={true}
224290
/>
225291
);
226292
expect(document.querySelector("#database .accordion-button.after-indicator")).toHaveAttribute("aria-expanded", "true");
@@ -261,6 +327,7 @@ describe("Sidebar createdOn face time window dropdown", () => {
261327
currentBaseEntities={[]}
262328
setCurrentBaseEntities={jest.fn()}
263329
entityIndicatorData={entityIndicatorData}
330+
graphConceptsSearchSupported={true}
264331
/>
265332
);
266333
expect(document.querySelector("#database .accordion-button.after-indicator")).toHaveAttribute("aria-expanded", "true");
@@ -296,6 +363,7 @@ describe("Sidebar createdOn face time window dropdown", () => {
296363
currentBaseEntities={[]}
297364
setCurrentBaseEntities={jest.fn()}
298365
entityIndicatorData={entityIndicatorData}
366+
graphConceptsSearchSupported={true}
299367
/>
300368
);
301369

marklogic-data-hub-central/ui/src/components/sidebar/sidebar.tsx

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ interface Props {
3434
checkFacetRender: (facets: any) => void;
3535
setDatabasePreferences: (option: string) => void;
3636
greyFacets: any;
37+
graphConceptsSearchSupported: boolean;
3738
setHubArtifactsVisibilityPreferences: any;
3839
hideDataHubArtifacts: boolean;
3940
cardView: boolean;
@@ -56,7 +57,6 @@ const PLACEHOLDER: string = "Select a saved query";
5657
const Sidebar: React.FC<Props> = (props) => {
5758
const stagingDbName: string = getEnvironment().stagingDb ? getEnvironment().stagingDb : "Staging";
5859
const finalDbName: string = getEnvironment().finalDb ? getEnvironment().finalDb : "Final";
59-
6060
const componentIsMounted = useRef(true);
6161
const entitiesArrayRef = useRef<any[]>();
6262

@@ -937,10 +937,26 @@ const Sidebar: React.FC<Props> = (props) => {
937937
<HCDivider className={"mt-0 mb-2"} style={{backgroundColor: "#ccc"}} />
938938
</div>
939939
}
940-
{props.currentRelatedConcepts?.size > 0 &&
940+
{!props.graphConceptsSearchSupported ?
941+
<div className={styles.relatedEntityPanel}>
942+
<HCTooltip text={exploreSidebar.versionLimitedConcepts(getEnvironment().marklogicVersion)} aria-label="disabled-related-concept-tooltip" id="disabled-related-concept-tooltip" placement="bottom">
943+
<Accordion id="related-concepts" data-testid={"related-concepts-panel"} className={"w-100 accordion-sidebar"} flush activeKey={""} defaultActiveKey={activeKey.includes("related-concepts") ? "related-concepts" : ""}>
944+
<Accordion.Item eventKey="related-concepts" className={"bg-transparent"}>
945+
<div className={"p-0 d-flex"}>
946+
<Accordion.Button className={`after-indicator ${styles.disabledTitleCheckbox}`}>{
947+
panelTitle(<span><span className={styles.disabledCheckbox}><HCCheckbox ariaLabel="related-concepts-checkbox" id="check-all" value="check-all" disabled={!props.graphConceptsSearchSupported} cursorDisabled={!props.graphConceptsSearchSupported} handleClick={() => { return; }} checked={true} /></span>related concepts</span>, ExploreGraphViewToolTips.relatedConcepts)}
948+
</Accordion.Button>
949+
</div>
950+
</Accordion.Item>
951+
</Accordion>
952+
</HCTooltip>
953+
<HCDivider className={"mt-0 mb-2"} style={{backgroundColor: "#ccc"}} />
954+
</div>
955+
:
956+
props.currentRelatedConcepts?.size > 0 &&
941957
<div className={styles.relatedEntityPanel}>
942958
<HCTooltip text={!props.graphView ? exploreSidebar.disabledRelatedConcepts : !props.viewConcepts ? exploreSidebar.relatedConceptsToggledOff : ""} aria-label="disabled-related-concept-tooltip" id="disabled-related-concept-tooltip" placement="bottom">
943-
<Accordion id="related-concepts" data-testid={"related-concept-panel"} className={"w-100 accordion-sidebar"} flush activeKey={activeKey.includes("related-concepts") && props.graphView && props.viewConcepts? "related-concepts" : ""} defaultActiveKey={activeKey.includes("related-concepts") ? "related-concepts" : ""}>
959+
<Accordion id="related-concepts" data-testid={"related-concepts-panel"} className={"w-100 accordion-sidebar"} flush activeKey={activeKey.includes("related-concepts") && props.graphView && props.viewConcepts? "related-concepts" : ""} defaultActiveKey={activeKey.includes("related-concepts") ? "related-concepts" : ""}>
944960
<Accordion.Item eventKey="related-concepts" className={"bg-transparent"}>
945961
<div className={"p-0 d-flex"}>
946962
<Accordion.Button className={(!props.graphView || !props.viewConcepts) ? `after-indicator ${styles.disabledTitleCheckbox}` : `after-indicator ${styles.titleCheckbox}`} onClick={() => setActiveAccordion("related-concepts")}>{

marklogic-data-hub-central/ui/src/config/explorer-tooltips.config.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,18 @@ const tooltipsConfig = {
2020
baseEntities: "Base entities filters will filter out related entities.",
2121
relatedEntities:
2222
"Related entity filters only filter on their respective entity type and will not affect base entity results.",
23-
disabledRelatedEntities: "Related entities are only available in the Graph View",
24-
disabledRelatedConcepts: "Related concepts are only available in the Graph View",
25-
relatedConceptsToggledOff: "Concepts have been toggled off in the Graph View"
23+
disabledRelatedEntities: "Related entities are only available in the Graph View.",
24+
disabledRelatedConcepts: "Related concepts are only available in the Graph View.",
25+
relatedConceptsToggledOff: "Concepts have been toggled off in the Graph View.",
26+
versionLimitedConcepts: function (versionNum) {
27+
return <span aria-label="concepts-version-tooltip">Concepts are limited in the current version of Marklogic <strong>{(versionNum)}</strong>. Please upgrade the Marklogic version to at least <strong>10.0-9</strong> for the full functionality.</span>
28+
},
2629
},
2730
exploreSidebarQueries: {
28-
saveNewQuery: "Save the current query",
29-
saveChanges: "Save changes",
31+
saveNewQuery: "Save the current query.",
32+
saveChanges: "Save changes.",
3033
disabledSaveButton: "You cannot save a query because you have not created one. To save a query, start a query by selecting an option below and clicking 'Search'.",
31-
saveWithoutPermisions: "Save Query: Contact your security administrator to get the roles and permissions to access this functionality"
34+
saveWithoutPermisions: "Save Query: Contact your security administrator to get the roles and permissions to access this functionality."
3235
},
3336
manageQueries: {
3437
disabledExport: "You cannot export your data because there are no results that match your query. Please try another query."

0 commit comments

Comments
 (0)