Skip to content

Commit

Permalink
[TM-1531] Merge branch 'staging' into feat/TM-1531-add-job-service
Browse files Browse the repository at this point in the history
  • Loading branch information
egrojMonroy committed Dec 18, 2024
2 parents 9fbece2 + 8f92486 commit 9d45753
Show file tree
Hide file tree
Showing 89 changed files with 3,596 additions and 1,245 deletions.
1 change: 0 additions & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: pull-request
on:
pull_request:
branches: [main, staging, release/**]
jobs:
test:
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ const userSentryWebpackPluginOptions = {
// Suppresses source map uploading logs during build
silent: true,

org: process.env.SENTRY_ORG || "3-sided-cube",
project: process.env.SENTRY_PROJECT || "wri-web-platform-version-2",
org: process.env.SENTRY_ORG ?? "wri-terramatch",
project: process.env.SENTRY_PROJECT ?? "terramatch-frontend",
authToken: process.env.SENTRY_AUTH_TOKEN
};

Expand Down
20 changes: 14 additions & 6 deletions openapi-codegen.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,33 +28,39 @@ type Environment = {
apiBaseUrl: string;
userServiceUrl: string;
jobServiceUrl: string;
entityServiceUrl: string;
};

const ENVIRONMENTS: { [Property in EnvironmentName]: Environment } = {
local: {
apiBaseUrl: "http://localhost:8080",
userServiceUrl: "http://localhost:4010",
jobServiceUrl: "http://localhost:4020"
jobServiceUrl: "http://localhost:4020",
entityServiceUrl: "http://localhost:4050"
},
dev: {
apiBaseUrl: "https://api-dev.terramatch.org",
userServiceUrl: "https://api-dev.terramatch.org",
jobServiceUrl: "https://api-dev.terramatch.org"
jobServiceUrl: "https://api-dev.terramatch.org",
entityServiceUrl: "https://api-dev.terramatch.org"
},
test: {
apiBaseUrl: "https://api-test.terramatch.org",
userServiceUrl: "https://api-test.terramatch.org",
jobServiceUrl: "https://api-test.terramatch.org"
jobServiceUrl: "https://api-test.terramatch.org",
entityServiceUrl: "https://api-test.terramatch.org"
},
staging: {
apiBaseUrl: "https://api-staging.terramatch.org",
userServiceUrl: "https://api-staging.terramatch.org",
jobServiceUrl: "https://api-staging.terramatch.org"
jobServiceUrl: "https://api-staging.terramatch.org",
entityServiceUrl: "https://api-staging.terramatch.org"
},
prod: {
apiBaseUrl: "https://api.terramatch.org",
userServiceUrl: "https://api.terramatch.org",
jobServiceUrl: "https://api.terramatch.org"
jobServiceUrl: "https://api.terramatch.org",
entityServiceUrl: "https://api.terramatch.org"
}
};

Expand All @@ -67,14 +73,16 @@ const DEFAULTS = ENVIRONMENTS[declaredEnv];
const apiBaseUrl = process.env.NEXT_PUBLIC_API_BASE_URL ?? DEFAULTS.apiBaseUrl;
const userServiceUrl = process.env.NEXT_PUBLIC_USER_SERVICE_URL ?? DEFAULTS.userServiceUrl;
const jobServiceUrl = process.env.NEXT_PUBLIC_JOB_SERVICE_URL ?? DEFAULTS.jobServiceUrl;
const entityServiceUrl = process.env.NEXT_PUBLIC_ENTITY_SERVICE_URL ?? DEFAULTS.entityServiceUrl;

// The services defined in the v3 Node BE codebase. Although the URL path for APIs in the v3 space
// are namespaced by feature set rather than service (a service may contain multiple namespaces), we
// isolate the generated API integration by service to make it easier for a developer to find where
// the associated BE code is for a given FE API integration.
const SERVICES = {
"user-service": userServiceUrl,
"job-service": jobServiceUrl
"job-service": jobServiceUrl,
"entity-service": entityServiceUrl
};

const config: Record<string, Config> = {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"generate:api": "openapi-codegen gen api",
"generate:jobService": "openapi-codegen gen jobService",
"generate:userService": "openapi-codegen gen userService",
"generate:services": "yarn generate:userService && yarn generate:jobService",
"generate:entityService": "openapi-codegen gen entityService",
"generate:services": "yarn generate:userService && yarn generate:entityService && yarn generate:jobService",
"tx:push": "eval $(grep '^TRANSIFEX_TOKEN' .env) && eval $(grep '^TRANSIFEX_SECRET' .env) && txjs-cli push --key-generator=hash src/ --token=$TRANSIFEX_TOKEN --secret=$TRANSIFEX_SECRET",
"tx:pull": "eval $(grep '^TRANSIFEX_TOKEN' .env) && eval $(grep '^TRANSIFEX_SECRET' .env) && txjs-cli pull --token=$TRANSIFEX_TOKEN --secret=$TRANSIFEX_SECRET"
},
Expand Down
53 changes: 28 additions & 25 deletions src/admin/components/EntityEdit/EntityEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useNavigate, useParams } from "react-router-dom";
import modules from "@/admin/modules";
import WizardForm from "@/components/extensive/WizardForm";
import LoadingContainer from "@/components/generic/Loading/LoadingContainer";
import EntityProvider from "@/context/entity.provider";
import FrameworkProvider, { Framework } from "@/context/framework.provider";
import {
GetV2FormsENTITYUUIDResponse,
Expand Down Expand Up @@ -73,31 +74,33 @@ export const EntityEdit = () => {
<div className="mx-auto w-full max-w-7xl">
<LoadingContainer loading={isLoading}>
<FrameworkProvider frameworkKey={framework}>
<WizardForm
steps={formSteps!}
errors={error}
onBackFirstStep={() => navigate("..")}
onChange={data =>
updateEntity({
pathParams: { uuid: entityUUID, entity: entityName },
body: { answers: normalizedFormData(data, formSteps!) }
})
}
formStatus={isSuccess ? "saved" : isUpdating ? "saving" : undefined}
onSubmit={() => navigate(createPath({ resource, id, type: "show" }))}
defaultValues={defaultValues}
title={title}
tabOptions={{
markDone: true,
disableFutureTabs: true
}}
summaryOptions={{
title: "Review Details",
downloadButtonText: "Download"
}}
roundedCorners
hideSaveAndCloseButton
/>
<EntityProvider entityUuid={entityUUID} entityName={entityName}>
<WizardForm
steps={formSteps!}
errors={error}
onBackFirstStep={() => navigate("..")}
onChange={data =>
updateEntity({
pathParams: { uuid: entityUUID, entity: entityName },
body: { answers: normalizedFormData(data, formSteps!) }
})
}
formStatus={isSuccess ? "saved" : isUpdating ? "saving" : undefined}
onSubmit={() => navigate(createPath({ resource, id, type: "show" }))}
defaultValues={defaultValues}
title={title}
tabOptions={{
markDone: true,
disableFutureTabs: true
}}
summaryOptions={{
title: "Review Details",
downloadButtonText: "Download"
}}
roundedCorners
hideSaveAndCloseButton
/>
</EntityProvider>
</FrameworkProvider>
</LoadingContainer>
</div>
Expand Down
31 changes: 31 additions & 0 deletions src/admin/components/ResourceTabs/AuditLogTab/AuditLogTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { NURSERY_REPORT, PROJECT_REPORT, SITE_REPORT } from "@/constants/entitie
import useAuditLogActions from "@/hooks/AuditStatus/useAuditLogActions";

import AuditLogSiteTabSelection from "./components/AuditLogSiteTabSelection";
import AuditLogTable from "./components/AuditLogTable";
import SiteAuditLogEntityStatus from "./components/SiteAuditLogEntityStatus";
import SiteAuditLogEntityStatusSide from "./components/SiteAuditLogEntityStatusSide";
import SiteAuditLogProjectStatus from "./components/SiteAuditLogProjectStatus";
Expand Down Expand Up @@ -58,6 +59,10 @@ const AuditLogTab: FC<IProps> = ({ label, entity, ...rest }) => {
loadEntityList();
}, [buttonToggle]);

const isSite = buttonToggle === AuditLogButtonStates.SITE;
const redirectTo = `${basename}/${modules.site.ResourceName}/${selected?.uuid}/show/6`;
const title = () => selected?.title ?? selected?.name;

const verifyEntity = ["reports", "nursery"].some(word => ReverseButtonStates2[entity!].includes(word));

const verifyEntityReport = () => {
Expand Down Expand Up @@ -133,6 +138,32 @@ const AuditLogTab: FC<IProps> = ({ label, entity, ...rest }) => {
/>
</Grid>
</Grid>
<div className="px-2 py-2">
<When condition={buttonToggle === AuditLogButtonStates.PROJECT && !record?.project}>
<Text variant="text-16-bold" className="mb-6">
History and Discussion for {record && record?.name}
</Text>
{auditLogData && <AuditLogTable auditLogData={auditLogData} auditData={auditData} refresh={refetch} />}
</When>
<When condition={buttonToggle !== AuditLogButtonStates.PROJECT || verifyEntity}>
<>
<div className="mb-6">
{!isSite && !verifyEntity && <Text variant="text-16-bold">History and Discussion for {title()}</Text>}
{(isSite || verifyEntity) && (
<Text variant="text-16-bold">
History and Discussion for{" "}
<Link className="text-16-bold !text-[#000000DD]" to={redirectTo}>
{title()}
</Link>
</Text>
)}
</div>
<When condition={!!auditLogData}>
<AuditLogTable auditLogData={auditLogData!} auditData={auditData} refresh={refetch} />
</When>
</>
</When>
</div>
</TabbedShowLayout.Tab>
</When>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,24 +63,26 @@ const SiteAuditLogEntityStatus: FC<SiteAuditLogEntityStatusProps> = ({
</Text>
<CommentarySection record={record} entity={entityType} refresh={refresh} viewCommentsList={false} />
</div>
<div>
{!isSite && !verifyEntity && <Text variant="text-16-bold">History and Discussion for {title()}</Text>}
{(isSite || verifyEntity) && (
<Text variant="text-16-bold">
History and Discussion for{" "}
{viewPD ? (
<Link className="text-16-bold !text-[#000000DD]" href={redirectTo}>
{title()}
</Link>
) : (
<RaLink className="text-16-bold !text-[#000000DD]" to={redirectTo}>
{title()}
</RaLink>
)}
</Text>
)}
</div>
<When condition={!!auditLogData}>
<When condition={viewPD}>
<div>
{!isSite && !verifyEntity && <Text variant="text-16-bold">History and Discussion for {title()}</Text>}
{(isSite || verifyEntity) && (
<Text variant="text-16-bold">
History and Discussion for{" "}
{viewPD ? (
<Link className="text-16-bold !text-[#000000DD]" href={redirectTo}>
{title()}
</Link>
) : (
<RaLink className="text-16-bold !text-[#000000DD]" to={redirectTo}>
{title()}
</RaLink>
)}
</Text>
)}
</div>
</When>
<When condition={!!auditLogData && viewPD}>
<AuditLogTable auditLogData={auditLogData!} auditData={auditData} refresh={refresh} />
</When>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { FC } from "react";
import { When } from "react-if";

import Text from "@/components/elements/Text/Text";
import { AuditStatusResponse, ProjectLiteRead } from "@/generated/apiSchemas";
Expand All @@ -10,13 +11,15 @@ export interface SiteAuditLogProjectStatusProps {
auditLogData?: { data: AuditStatusResponse[] };
auditData?: { entity: string; entity_uuid: string };
refresh?: () => void;
viewPD?: boolean;
}

const SiteAuditLogProjectStatus: FC<SiteAuditLogProjectStatusProps> = ({
record,
auditLogData,
auditData,
refresh
refresh,
viewPD = false
}) => (
<div className="flex flex-col gap-6">
<div>
Expand All @@ -27,8 +30,10 @@ const SiteAuditLogProjectStatus: FC<SiteAuditLogProjectStatusProps> = ({
Update the project status, view updates, or add comments
</Text>
</div>
<Text variant="text-16-bold">History and Discussion for {record && record?.name}</Text>
{auditLogData && <AuditLogTable auditLogData={auditLogData} auditData={auditData} refresh={refresh} />}
<When condition={viewPD}>
<Text variant="text-16-bold">History and Discussion for {record && record?.name}</Text>
{auditLogData && <AuditLogTable auditLogData={auditLogData} auditData={auditData} refresh={refresh} />}
</When>
</div>
);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import { FC } from "react";
import { TabbedShowLayout, TabProps } from "react-admin";

import { EntityName } from "@/types/common";

import DataCard from "./components/DataCard";
import HeaderMonitoredTab from "./components/HeaderMonitoredTab";

interface IProps extends Omit<TabProps, "label" | "children"> {
label?: string;
type: EntityName;
}

const MonitoredTab: FC<IProps> = ({ label, ...rest }) => {
const MonitoredTab: FC<IProps> = ({ label, type, ...rest }) => {
return (
<TabbedShowLayout.Tab label={label ?? "Monitored Data"} {...rest}>
<div className="flex w-full flex-col gap-4 p-3">
<HeaderMonitoredTab />
<DataCard />
<HeaderMonitoredTab type={type} />
<DataCard type={type} />
</div>
</TabbedShowLayout.Tab>
);
Expand Down
Loading

0 comments on commit 9d45753

Please sign in to comment.