Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
161 changes: 92 additions & 69 deletions core/app/c/[communitySlug]/stages/components/StageList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,86 +5,109 @@ import { Fragment } from "react";
import { Button } from "ui";
import PubRow from "~/app/components/PubRow";
import { getPubUsers } from "~/lib/permissions";
import { StagePayload, UserLoginData } from "~/lib/types";
import { StageIndex, StagePayload, UserLoginData } from "~/lib/types";
import { StagePubActions } from "./StagePubActions";
import { stageSources } from "~/lib/pubStages";

type Props = { stages: StagePayload[]; token: string; loginData: UserLoginData };
type Props = {
stageWorkflows: StagePayload[][];
stageIndex: StageIndex;
token: string;
loginData: UserLoginData;
};
type IntegrationAction = { text: string; href: string; kind?: "stage" };

const StageList: React.FC<Props> = function ({ stages, token, loginData }) {
function StageList(props: Props) {
return (
<div>
{stages.map((stage) => {
const users = getPubUsers(stage.permissions);
const sources = stage.moveConstraintSources.map(
(stage) => stages.find((s) => s.id === stage.stageId)!
);
const destinations = stage.moveConstraints.map((stage) => stage.destination);
return (
<div key={stage.id} className="mb-20">
<div className="flex flex-row justify-between">
<h3 className="font-semibold text-lg mb-2">{stage.name}</h3>
{stage.integrationInstances.map((instance) => {
if (!Array.isArray(instance.integration.actions)) {
return null;
}
{
props.stageWorkflows.map((stages) => {
return (
<div>
{stages.map((stage) => {
const users = getPubUsers(stage.permissions);
const sources = stageSources(stage, props.stageIndex);
const destinations = stage.moveConstraints.map(
(stage) => stage.destination
);
return (
<Fragment key={instance.id}>
{instance.integration.actions?.map(
(action: IntegrationAction) => {
if (action.kind === "stage") {
const href = new URL(action.href);
href.searchParams.set(
"instanceId",
instance.id
);
href.searchParams.set("token", token);
return (
<Button
key={action.text}
variant="outline"
size="sm"
asChild
>
<Link href={href.toString()}>
{action.text}
</Link>
</Button>
);
<div key={stage.id} className="mb-20">
<div className="flex flex-row justify-between">
<h3 className="font-semibold text-lg mb-2">
{stage.name}
</h3>
{stage.integrationInstances.map((instance) => {
if (!Array.isArray(instance.integration.actions)) {
return null;
}
}
)}
</Fragment>
return (
<Fragment key={instance.id}>
{instance.integration.actions?.map(
(action: IntegrationAction) => {
if (action.kind === "stage") {
const href = new URL(
action.href
);
href.searchParams.set(
"instanceId",
instance.id
);
href.searchParams.set(
"token",
props.token
);
return (
<Button
key={action.text}
variant="outline"
size="sm"
asChild
>
<Link
href={href.toString()}
>
{action.text}
</Link>
</Button>
);
}
}
)}
</Fragment>
);
})}
</div>
{stage.pubs.map((pub, index, list) => {
return (
<Fragment key={pub.id}>
<PubRow
key={pub.id}
pub={pub}
token={props.token}
actions={
<StagePubActions
key={stage.id}
pub={pub}
stage={stage}
users={users}
loginData={props.loginData}
moveTo={destinations}
moveFrom={sources}
/>
}
/>
{index < list.length - 1 && <hr />}
</Fragment>
);
})}
</div>
);
})}
</div>
{stage.pubs.map((pub, index, list) => {
return (
<Fragment key={pub.id}>
<PubRow
key={pub.id}
pub={pub}
token={token}
actions={
<StagePubActions
key={stage.id}
pub={pub}
stage={stage}
users={users}
loginData={loginData}
moveTo={destinations}
moveFrom={sources}
/>
}
/>
{index < list.length - 1 && <hr />}
</Fragment>
);
})}
</div>
);
})}
);
})[0]
}
</div>
);
};
}
export default StageList;
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
import { useState } from "react";
import { Button, Input, Tabs, TabsContent, TabsList, TabsTrigger } from "ui";
import StagesEditor from "./StagesEditor";
import { StagePayload, StageIndex } from "~/lib/types";

type Props = {
community: any;
stages: any;
stageWorkflows: StagePayload[][];
stageIndex: StageIndex;
};

export default function StageManagement(props: Props) {
Expand Down Expand Up @@ -42,7 +44,10 @@ export default function StageManagement(props: Props) {
<TabsContent value="1">
<div className="relative flex flex-col text-left lg:text-left">
<div className="relative inline-flex flex-col">
<StagesEditor stages={props.stages} />
<StagesEditor
stageWorkflows={props.stageWorkflows}
stageIndex={props.stageIndex}
/>
</div>
</div>
</TabsContent>
Expand Down
Loading