Skip to content
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

[Cortex Scaffolder] Plugins Confluence Plugin #23

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

cortex-app[bot]
Copy link

@cortex-app cortex-app bot commented Jan 25, 2024

Created by Cortex

@FoodProduct FoodProduct marked this pull request as draft January 26, 2024 14:39
@cremerfc cremerfc changed the title [Cortex Scaffolder] Creating new service: Plugins Confluence Plugin [Cortex Scaffolder] Plugins Confluence Plugin Feb 5, 2024
@cremerfc cremerfc marked this pull request as ready for review May 20, 2024 18:23
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please replace this boilerplate README with something that describes the functions and benefits of the plugin as well as how to configure it, and ideally includes a screenshot of it? 🙏

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be deleted

import { PluginProvider } from "@cortexapps/plugin-core/components";
import "../baseStyles.css";
import ErrorBoundary from "./ErrorBoundary";
// import Content from "./Content"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// import Content from "./Content"

{isNil(entityPage) ? (
<Box backgroundColor="light" padding={3} borderRadius={2}>
<Text>
We could not find any Confluence Page associated with this entity
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
We could not find any Confluence Page associated with this entity
We could not find any Confluence page associated with this entity

});
});

it("Shows a page if page is found", async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: these should read and be capitalized like sentences starting with "it"

Suggested change
it("Shows a page if page is found", async () => {
it("shows a page if page is found", async () => {

import { getEntityYaml } from "../api/Cortex";
import { getConfluenceDetailsFromEntity } from "../lib/parseEntity";

const baseJIRAUrl = "https://cortex-se-test.atlassian.net";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updating this should be in the plugin's README as instructions for users as to how to point it at their own Jira/Confluence instance. Also, shouldn't this be

Suggested change
const baseJIRAUrl = "https://cortex-se-test.atlassian.net";
const baseConfluenceUrl = "https://cortex-se-test.atlassian.net";

?

Lastly, Jira hasn't been stylized in all caps since 2017 😛


useEffect(() => {
const fetchEntityYaml = async (): Promise<void> => {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion

Comment on lines +34 to +39
setEntityPage(pageID?.pageID);
const jiraURL =
baseJIRAUrl +
"/wiki/rest/api/content/" +
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
pageID?.pageID +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eslint is making a valid complaint here saying that pageID?.pageID can be undefined, in which case this will evaluate to the string "undefined". I think it would be cleanest to handle this scenario explicitly

Suggested change
setEntityPage(pageID?.pageID);
const jiraURL =
baseJIRAUrl +
"/wiki/rest/api/content/" +
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
pageID?.pageID +
if (!pageID?.pageID) {
throw new Error('No Confluence details for entity')
}
setEntityPage(pageID.pageID);
const jiraURL = `${baseJIRAUrl}/wiki/rest/api/content/${pageID.pageID}?expand=body.view`;

Also, we can use string interpolation to make the URL building a bit cleaner

setPageContent(contentJSON.body.view.value);
setPageTitle(contentJSON.title);
} catch (e) {
console.error("Error fetching Confluence page: ", e);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a better UX would be to show an error in the HTML instead of having them see a blank screen and have to open up dev tools to parse what's happening.

<script
defer
type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.3.7/iframeResizer.contentWindow.js"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the cookiecutter template since this was created 🙂. This should now be

Suggested change
src="https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.3.7/iframeResizer.contentWindow.js"
src="https://cdn.jsdelivr.net/npm/@iframe-resizer/child"

@jreock jreock self-assigned this Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants