Skip to content

Commit

Permalink
ran yarn fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Fernando Cremer authored and Fernando Cremer committed Feb 2, 2024
1 parent 5b8f383 commit 069ceb6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 32 deletions.
49 changes: 18 additions & 31 deletions plugins/confluence-plugin/src/components/EntityInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,30 @@ import React, { useState, useEffect } from "react";
// import React from "react";
import { isEmpty, isNil } from "lodash";
import "../baseStyles.css";
import { Box,Text, usePluginContext } from "@cortexapps/plugin-core/components";
import {
Box,
Text,
usePluginContext,
} from "@cortexapps/plugin-core/components";
import { getEntityYaml } from "../api/Cortex";
import { getConfluenceDetailsFromEntity } from "../lib/parseEntity";


const EntityInfo: React.FC = () => {
const [pageContent, setPageContent] = useState<string | undefined>();
const [pageTitle, setPageTitle] = useState<string | undefined>();
const [entityPage, setEntityPage] = useState<any | string>();
const [entityYaml, setEntityYaml] = useState<
Record<string, any> | undefined
>();

const context = usePluginContext();

useEffect(() => {
const fetchEntityYaml = async (): Promise<void> => {
console.log("about to get the yaml");
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const entityTag = context.entity?.tag;
console.log(entityTag);
if (!isNil(entityTag)) {
const yaml = await getEntityYaml(context.apiBaseUrl, entityTag);
console.log(yaml);
setEntityYaml(yaml);
console.log("about to shoe yaml");
console.log(entityYaml);
const pageID = isEmpty(yaml)
? undefined
: getConfluenceDetailsFromEntity(yaml);
console.log(pageID);
setEntityPage(pageID?.pageID);
const baseJIRAUrl = "https://cortex-se-test.atlassian.net";
const jiraURL =
Expand All @@ -42,11 +36,8 @@ const EntityInfo: React.FC = () => {
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
pageID?.pageID +
"?expand=body.view";
console.log(jiraURL);
const contentResult = await fetch(jiraURL);
console.log(contentResult);
const contentJSON = await contentResult.json();
console.log(contentJSON);
setPageContent(contentJSON.body.view.value);
setPageTitle(contentJSON.title);
}
Expand All @@ -56,22 +47,18 @@ const EntityInfo: React.FC = () => {

return (
<div>
<Text>Helo</Text>
<br />
<Text>{entityPage}</Text>
{isNil(entityPage) ?(
<Box backgroundColor="light" padding={3} borderRadius={2}>
<Text>
We could not find any Confluence Page associated with this entity
</Text>
</Box>
): (
<div>
<h1 dangerouslySetInnerHTML={{ __html: pageTitle as string }}></h1>
<p dangerouslySetInnerHTML={{ __html: pageContent as string }}></p>
</div>
) }

{isNil(entityPage) ? (
<Box backgroundColor="light" padding={3} borderRadius={2}>
<Text>
We could not find any Confluence Page associated with this entity
</Text>
</Box>
) : (
<div>
<h1 dangerouslySetInnerHTML={{ __html: pageTitle as string }}></h1>
<p dangerouslySetInnerHTML={{ __html: pageContent as string }}></p>
</div>
)}
</div>
);
};
Expand Down
1 change: 0 additions & 1 deletion plugins/confluence-plugin/src/lib/parseEntity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ export const getConfluenceDetailsFromEntity = (
entity: Record<string, any>
): { pageID: string } | undefined => {
const pageID = entity.info["x-cortex-confluence"]?.pageID;
console.log(pageID);
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
if (!pageID) {
return undefined;
Expand Down

0 comments on commit 069ceb6

Please sign in to comment.