Skip to content

Commit

Permalink
Merge pull request #949 from wri/release/youthful-yucca
Browse files Browse the repository at this point in the history
[RELEASE] Youthful Yucca
  • Loading branch information
roguenet authored Feb 20, 2025
2 parents 46e6e94 + d135965 commit f09808d
Show file tree
Hide file tree
Showing 235 changed files with 7,110 additions and 2,644 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ module.exports = {
}
],
"no-unused-vars": "off",
"react-hooks/exhaustive-deps": "warn",
"react-hooks/exhaustive-deps": "error",
"prettier/prettier": [
"error",
{},
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"nookies": "^2.5.2",
"prettier-plugin-tailwindcss": "^0.2.2",
"query-string": "^7.1.1",
"quill": "2.0.3",
"ra-input-rich-text": "^4.12.2",
"react": "18.2.0",
"react-admin": "^4.7.4",
Expand Down
Binary file added public/images/Impact Story - Landing Page.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/impact-story-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/impact-story-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/mask.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/maskRight.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions src/admin/apiProvider/authProvider.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { AuthProvider } from "react-admin";
import { AuthProvider, UserIdentity } from "react-admin";

import { loadLogin, logout } from "@/connections/Login";
import { loadMyUser } from "@/connections/User";
import Log from "@/utils/log";

export type TMUserIdentity = UserIdentity & { primaryRole: string };

export const authProvider: AuthProvider = {
login: async () => {
Log.error("Admin app does not support direct login");
Expand All @@ -29,7 +31,7 @@ export const authProvider: AuthProvider = {
const { user } = await loadMyUser();
if (user == null) throw "No user logged in.";

return { id: user.uuid, fullName: user.fullName ?? undefined, primaryRole: user.primaryRole };
return { id: user.uuid, fullName: user.fullName ?? undefined, primaryRole: user.primaryRole } as TMUserIdentity;
},

// get the user permissions (optional)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ export const fundingProgrammeDataProvider: FundingDataProvider = {
}
});
}

await handleUploads(params, uploadKeys, {
//@ts-ignore
uuid: resp.data.uuid,
Expand Down
115 changes: 115 additions & 0 deletions src/admin/apiProvider/dataProviders/impactStoriesDataProvider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
import lo from "lodash";
import { DataProvider } from "react-admin";

import {
DeleteV2AdminImpactStoriesIdError,
fetchDeleteV2AdminImpactStoriesId,
fetchGetV2AdminImpactStories,
fetchGetV2AdminImpactStoriesId,
fetchPostV2AdminImpactStories,
fetchPostV2AdminImpactStoriesBulkDelete,
fetchPutV2AdminImpactStoriesId,
GetV2AdminImpactStoriesError,
GetV2AdminImpactStoriesIdError,
PostV2AdminImpactStoriesBulkDeleteError,
PostV2AdminImpactStoriesError,
PutV2AdminImpactStoriesIdError
} from "@/generated/apiComponents";

import { getFormattedErrorForRA } from "../utils/error";
import { apiListResponseToRAListResult, raListParamsToQueryParams } from "../utils/listing";
import { handleUploads } from "../utils/upload";

// @ts-ignore
export const impactStoriesDataProvider: DataProvider = {
async getList(_, params) {
try {
const response = await fetchGetV2AdminImpactStories({
queryParams: raListParamsToQueryParams(params, [])
});
return apiListResponseToRAListResult(response);
} catch (err) {
throw getFormattedErrorForRA(err as GetV2AdminImpactStoriesError);
}
},
// @ts-ignore
async getOne(_, params) {
try {
const list = await fetchGetV2AdminImpactStoriesId({
pathParams: { id: params.id }
});
const response = { data: list };
//@ts-ignore
return { data: { ...response.data, id: response.data.id } };
} catch (err) {
throw getFormattedErrorForRA(err as GetV2AdminImpactStoriesIdError);
}
},
//@ts-ignore
async create(__, params) {
const uploadKeys = ["thumbnail"];
const body: any = lo.omit(params.data, uploadKeys);
try {
const response = await fetchPostV2AdminImpactStories({
body: body
});
// @ts-expect-error
const uuid = response.data.uuid as string;
await handleUploads(params, uploadKeys, {
uuid,
model: "impact-story"
});
// @ts-expect-error
return { data: { ...response.data, id: response.id } };
} catch (err) {
throw getFormattedErrorForRA(err as PostV2AdminImpactStoriesError);
}
},
//@ts-ignore
async update(__, params) {
const uuid = params.id as string;
const uploadKeys = ["thumbnail"];
const body = lo.omit(params.data, uploadKeys);

try {
await handleUploads(params, uploadKeys, {
uuid,
model: "impact-story"
});

const response = await fetchPutV2AdminImpactStoriesId({
body,
pathParams: { id: uuid }
});

console.log("Params", params.data);
// @ts-expect-error
return { data: { ...response.data, id: response.data.uuid } };
} catch (err) {
throw getFormattedErrorForRA(err as PutV2AdminImpactStoriesIdError);
}
},

//@ts-ignore
async delete(__, params) {
try {
await fetchDeleteV2AdminImpactStoriesId({
pathParams: { id: params.id as string }
});
return { data: { id: params.id } };
} catch (err) {
throw getFormattedErrorForRA(err as DeleteV2AdminImpactStoriesIdError);
}
},
// @ts-ignore
async deleteMany(_, params) {
try {
await fetchPostV2AdminImpactStoriesBulkDelete({
body: { uuids: params.ids.map(String) }
});
return { data: params.ids };
} catch (err) {
throw getFormattedErrorForRA(err as PostV2AdminImpactStoriesBulkDeleteError);
}
}
};
4 changes: 4 additions & 0 deletions src/admin/apiProvider/dataProviders/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { applicationDataProvider } from "./applicationDataProvider";
import { auditDataProvider } from "./auditDataProvider";
import { formDataProvider } from "./formDataProvider";
import { fundingProgrammeDataProvider } from "./fundingProgrammeDataProvider";
import { impactStoriesDataProvider } from "./impactStoriesDataProvider";
import { nurseryDataProvider } from "./nurseryDataProvider";
import { nurseryReportDataProvider } from "./nurseryReportDataProvider";
import { organisationDataProvider } from "./organisationDataProvider";
Expand Down Expand Up @@ -70,6 +71,9 @@ export const dataProvider = combineDataProviders(resource => {
case modules.audit.ResourceName:
return auditDataProvider;

case modules.impactStories.ResourceName:
return impactStoriesDataProvider;

default:
throw new Error(`Unknown resource: ${resource}`);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ export const organisationDataProvider: OrganisationDataProvider = {
const uuid = params.id as string;
const uploadKeys = ["logo", "cover", "legal_registration", "reference", "additional"];
const body = lo.omit(params.data, uploadKeys);

await handleUploads(params, uploadKeys, {
uuid,
model: "organisation"
Expand Down
19 changes: 19 additions & 0 deletions src/admin/components/Actions/ListActionsImpactStories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import DownloadIcon from "@mui/icons-material/GetApp";
import { Button, CreateButton, FilterButton, TopToolbar } from "react-admin";
import { When } from "react-if";

interface ListActionsProps {
onExport?: () => void;
}

const ListActionsImpactStories = (props: ListActionsProps) => (
<TopToolbar>
<FilterButton className="filter-button-page-admin" />
<When condition={!!props.onExport}>
<Button className="button-page-admin" label="Export" startIcon={<DownloadIcon />} onClick={props.onExport} />
</When>
<CreateButton className="filter-button-page-admin-blue" label="Add Story" />
</TopToolbar>
);

export default ListActionsImpactStories;
18 changes: 6 additions & 12 deletions src/admin/components/Actions/ShowActions.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { Box, Typography } from "@mui/material";
import { get } from "lodash";
import {
Button,
DeleteWithConfirmButton,
DeleteWithConfirmButtonProps,
EditButton,
Link,
RaRecord,
TopToolbar,
useGetRecordRepresentation,
useRecordContext,
useResourceContext
} from "react-admin";
Expand All @@ -19,8 +18,6 @@ import Icon, { IconNames } from "@/components/extensive/Icon/Icon";
import ShowTitle from "../ShowTitle";

interface IProps {
titleSource?: string;
getTitle?: (record: RaRecord) => string;
resourceName?: string;
moduleName?: string;
hasDelete?: boolean;
Expand All @@ -30,8 +27,6 @@ interface IProps {
}

const ShowActions = ({
titleSource,
getTitle,
resourceName,
moduleName,
hasDelete = true,
Expand All @@ -41,11 +36,10 @@ const ShowActions = ({
}: IProps) => {
const record = useRecordContext<any>();
const resource = useResourceContext();
const title = useGetRecordRepresentation(resource)(record);

const title = titleSource ? get(record, titleSource) : "";

if (titleSource && resourceName) {
deleteProps.confirmTitle = `Delete ${resourceName} ${record?.[titleSource]}`;
if (resourceName != null) {
deleteProps.confirmTitle = `Delete ${resourceName} ${title}`;
deleteProps.confirmContent = `You are about to delete this ${resourceName}. This action will permanently remove the item from the system, and it cannot be undone. Are you sure you want to delete this item?`;
}

Expand All @@ -58,9 +52,9 @@ const ShowActions = ({
<Icon name={IconNames.CHEVRON_LEFT_PA} className="mr-2 h-10 w-9" />
</Link>
</When>
<When condition={!!(title || getTitle)}>
<When condition={title != null}>
<Typography variant="h4" component="h2" sx={{ flexGrow: 1 }}>
<ShowTitle moduleName={moduleName} getTitle={getTitle ? getTitle : () => title} />
<ShowTitle moduleName={moduleName} />
</Typography>
</When>
<TopToolbar sx={{ marginBottom: 2, marginLeft: "auto" }}>
Expand Down
80 changes: 0 additions & 80 deletions src/admin/components/Alerts/DelayedJobsProgressAlert.tsx

This file was deleted.

Loading

0 comments on commit f09808d

Please sign in to comment.