Skip to content

Commit

Permalink
Merge pull request #104 from atlassian/main
Browse files Browse the repository at this point in the history
[pull] main from atlassian:main
  • Loading branch information
ammar-ahmed-butt authored Jan 21, 2024
2 parents bdf9146 + 332b5ae commit 8589870
Show file tree
Hide file tree
Showing 28 changed files with 1,326 additions and 239 deletions.
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ services:
POSTGRES_HOST_AUTH_METHOD: trust

ngrok:
image: wernight/ngrok
image: ngrok/ngrok:latest
container_name: ngrok
extra_hosts:
- "host.docker.internal:host-gateway"
ports:
- "4040:4040"
command: ngrok http -log stdout --authtoken $NGROK_AUTHTOKEN host.docker.internal:8080
command: http --log stdout --authtoken=$NGROK_AUTHTOKEN host.docker.internal:8080

localstack:
image: localstack/localstack:1.0.4
Expand Down
4 changes: 4 additions & 0 deletions spa/src/api/subscriptions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import { RestSyncReqBody } from "~/src/rest-interfaces";

export default {
getSubscriptions: () => axiosRest.get("/rest/subscriptions"),
deleteGHEServer: (serverUrl: string) =>
axiosRest.delete(`/rest/ghes-servers/${serverUrl}`),
deleteGHEApp: (uuid: string) =>
axiosRest.delete(`/rest/app/${uuid}`),
deleteSubscription: (subscriptionId: number) =>
axiosRest.delete(`/rest/app/cloud/subscriptions/${subscriptionId}`),
syncSubscriptions: (subscriptionId: number, reqBody: RestSyncReqBody) =>
Expand Down
8 changes: 4 additions & 4 deletions spa/src/common/Wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,24 @@ const navHeight = 56;
const wrapperStyle = css`
padding: 20px 40px 0px 40px;
`;
const wrapperCenterStyle = css`
const getWrapperCenterStyle = (width: string | undefined) => css`
margin: 0 auto;
max-width: 580px;
max-width: ${width ? width: "580px"};
height: calc(100vh - ${navHeight * 2}px);
display: flex;
flex-direction: column;
justify-content: center;
`;

export const Wrapper = (attr: { hideClosedBtn?: boolean, children?: ReactNode | undefined }) => {
export const Wrapper = (attr: { hideClosedBtn?: boolean, children?: ReactNode | undefined, width?:string }) => {
const navigateToHomePage = () => {
analyticsClient.sendUIEvent({ actionSubject: "dropExperienceViaBackButton", action: "clicked" });
AP.getLocation((location: string) => {
const locationUrl = new URL(location);
AP.navigator.go( "site", { absoluteUrl: `${locationUrl.origin}/jira/marketplace/discover/app/com.github.integration.production` });
});
};
const wrapperCenterStyle = getWrapperCenterStyle(attr.width || undefined);

return (
<div css={wrapperStyle}>
Expand All @@ -37,7 +38,6 @@ export const Wrapper = (attr: { hideClosedBtn?: boolean, children?: ReactNode |
onClick={navigateToHomePage}
/>
}

<div css={wrapperCenterStyle}>{attr.children}</div>
</div>
);
Expand Down
54 changes: 12 additions & 42 deletions spa/src/pages/Connections/GHCloudConnections/index.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
/** @jsxImportSource @emotion/react */
import { useState } from "react";
import { Box, xcss } from "@atlaskit/primitives";
import { DynamicTableStateless } from "@atlaskit/dynamic-table";
import {
head,
getGHSubscriptionsRows,
} from "../../../utils/dynamicTableHelper";
import { BackfillPageModalTypes, GhCloudSubscriptions } from "../../../rest-interfaces";
import { Box, xcss } from "@atlaskit/primitives";
import { SuccessfulConnection } from "rest-interfaces";
import DisconnectSubscriptionModal from "../Modals/DisconnectSubscriptionModal";
import RestartBackfillModal from "../Modals/RestartBackfillModal";
import { ModalTransition } from "@atlaskit/modal-dialog";
import {
BackfillPageModalTypes,
GhCloudSubscriptions, SuccessfulConnection,
} from "../../../rest-interfaces";

const containerStyles = xcss({
display: "flex",
Expand All @@ -19,58 +17,30 @@ const containerStyles = xcss({

type GitHubCloudConnectionsProps = {
ghCloudSubscriptions: GhCloudSubscriptions;
refetch: () => void;
setDataForModal: (dataForModal: SuccessfulConnection | undefined) => void,
setSelectedModal: (selectedModal:BackfillPageModalTypes) => void,
setIsModalOpened: (isModalOpen: boolean) => void,
};

const GitHubCloudConnections = ({
ghCloudSubscriptions,
refetch,
setIsModalOpened,
setDataForModal,
setSelectedModal,
}: GitHubCloudConnectionsProps) => {
const [isModalOpened, setIsModalOpened] = useState(false);
const [subscriptionForModal, setSubscriptionForModal] = useState<SuccessfulConnection | undefined>(undefined);
const [selectedModal, setSelectedModal] = useState<BackfillPageModalTypes>("BACKFILL");

const openedModal = (refetch: () => void) => {
switch (selectedModal) {
case "BACKFILL":
return (<RestartBackfillModal
subscription={subscriptionForModal as SuccessfulConnection}
setIsModalOpened={setIsModalOpened}
refetch={refetch}
/>);
case "DISCONNECT_SUBSCRIPTION":
return <DisconnectSubscriptionModal
subscription={subscriptionForModal as SuccessfulConnection}
setIsModalOpened={setIsModalOpened}
refetch={refetch}
/>;
// TODO: Create modals for GHE later
case "DISCONNECT_SERVER":
case "DISCONNECT_SERVER_APP":
default:
return <></>;
}
};

return (
<>
<Box xcss={containerStyles}>
<DynamicTableStateless
head={head}
rows={getGHSubscriptionsRows(
ghCloudSubscriptions.successfulCloudConnections,
{ setIsModalOpened, setSubscriptionForModal, setSelectedModal }
{ setIsModalOpened, setDataForModal, setSelectedModal }
)}
rowsPerPage={5}
page={1}
/>
</Box>

<ModalTransition>
{
isModalOpened && subscriptionForModal && openedModal(refetch)
}
</ModalTransition>
</>
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/** @jsxImportSource @emotion/react */
import DropdownMenu, {
DropdownItem,
DropdownItemGroup,
} from "@atlaskit/dropdown-menu";
import Button from "@atlaskit/button";
import { Flex, xcss } from "@atlaskit/primitives";
import MoreIcon from "@atlaskit/icon/glyph/more";
import Heading from "@atlaskit/heading";
import ChevronRightIcon from "@atlaskit/icon/glyph/chevron-right";
import ChevronDownIcon from "@atlaskit/icon/glyph/chevron-down";
import {
BackfillPageModalTypes,
GitHubEnterpriseApplication,
SuccessfulConnection,
} from "../../../rest-interfaces";
import { css } from "@emotion/react";

const applicationHeaderStyle = css`
cursor: pointer;
display: flex;
align-items: center;
justify-content: flex-start;
width: 100%;
`;

const appHeaderContainerStyle = xcss({
width: "100%",
justifyContent: "space-between",
marginBottom: "20px",
});

type GitHubEnterpriseApplicationProps = {
application: GitHubEnterpriseApplication;
setDataForModal: (dataForModal: SuccessfulConnection | GitHubEnterpriseApplication) => void;
setSelectedModal: (selectedModal: BackfillPageModalTypes) => void;
setIsModalOpened: (isModalOpen: boolean) => void;
showAppContent: boolean;
toggleShowAppContent: () => void;
};

const GHEnterpriseAppHeader = ({
application,
setIsModalOpened,
setDataForModal,
setSelectedModal,
showAppContent,
toggleShowAppContent
}: GitHubEnterpriseApplicationProps) => {

const onEditGitHubApp = () =>{
const uuid = application.uuid;
AP.navigator.go(
"addonmodule",
{
moduleKey: "github-edit-app-page",
customData: { uuid }
}
);
};
return (
<Flex xcss={appHeaderContainerStyle}>
<div
css={applicationHeaderStyle}
onClick={() => {
toggleShowAppContent();
}}
>
{showAppContent ? (
<ChevronDownIcon label="" />
) : (
<ChevronRightIcon label="" />
)}
<Heading level="h400">{application.gitHubAppName}</Heading>
</div>
<div>
<DropdownMenu
trigger={({ triggerRef, ...props }) => (
<Button
{...props}
appearance="subtle"
iconBefore={<MoreIcon label="more" size="small" />}
ref={triggerRef}
/>
)}
>
<DropdownItemGroup>
<DropdownItem onClick={onEditGitHubApp}>Edit</DropdownItem>
<DropdownItem onClick={()=>{
setIsModalOpened(true);
setDataForModal(application);
setSelectedModal("DISCONNECT_SERVER_APP");
}}>Disconnect</DropdownItem>
</DropdownItemGroup>
</DropdownMenu>
</div>
</Flex>
);
};

export default GHEnterpriseAppHeader;
Loading

0 comments on commit 8589870

Please sign in to comment.