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

revert moving messaging template endpoints #5093

Merged
merged 3 commits into from
Jul 17, 2024
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
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ The types of changes are:
- Updated System's page to display a table that uses a paginated endpoint [#5084](https://github.com/ethyca/fides/pull/5084)
- Messaging page now shows a notice if you have properties without any templates [#5077](https://github.com/ethyca/fides/pull/5077)
- Endpoints for listing systems (GET /system) and datasets (GET /dataset) now support optional pagination [#5071](https://github.com/ethyca/fides/pull/5071)
- Moves some endpoints for property-specific messaging from OSS -> plus [#5069](https://github.com/ethyca/fides/pull/5069)
- Messaging page will now show a notice about using global mode [#5090](https://github.com/ethyca/fides/pull/5090)
- URL for deployment instructions when the webserver is running [#5088](https://github.com/ethyca/fides/pull/5088)

Expand Down
6 changes: 3 additions & 3 deletions clients/admin-ui/cypress/e2e/messaging.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe("Messaging", () => {
cy.login();
stubPlus(true);

cy.intercept("/api/v1/plus/messaging/templates/summary?*", {
cy.intercept("/api/v1/messaging/templates/summary?*", {
fixture: "messaging/summary.json",
}).as("getEmailTemplatesSummary");

Expand All @@ -20,13 +20,13 @@ describe("Messaging", () => {
fixture: "properties/properties.json",
}).as("getProperties");

cy.intercept("PATCH", "/api/v1/plus/messaging/templates/*", {}).as(
cy.intercept("PATCH", "/api/v1/messaging/templates/*", {}).as(
"patchTemplate"
);

cy.intercept(
"POST",
"/api/v1/plus/messaging/templates/privacy_request_complete_access",
"/api/v1/messaging/templates/privacy_request_complete_access",
{}
).as("postTemplate");
});
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { baseApi } from "~/features/common/api.slice";
import { MinimalProperty } from "~/types/api";
import {
MinimalProperty,
Page_MessagingTemplateWithPropertiesSummary_,
} from "~/types/api";
import { BulkUpdateFailed } from "~/types/api/models/BulkUpdateFailed";

export type MessagingTemplate = {
Expand Down Expand Up @@ -67,6 +70,17 @@ const messagingTemplatesApi = baseApi.injectEndpoints({
query: () => ({ url: `messaging/templates` }),
providesTags: () => ["Messaging Templates"],
}),
getSummaryMessagingTemplates: build.query<
Page_MessagingTemplateWithPropertiesSummary_,
any
>({
query: (params) => ({
method: "GET",
url: `messaging/templates/summary`,
params,
}),
providesTags: () => ["Property-Specific Messaging Templates"],
}),
updateMessagingTemplates: build.mutation<
BulkPutMessagingTemplateResponse,
MessagingTemplate[]
Expand All @@ -76,7 +90,7 @@ const messagingTemplatesApi = baseApi.injectEndpoints({
method: "PUT",
body: templates,
}),
invalidatesTags: () => ["Messaging Templates"],
invalidatesTags: () => ["Property-Specific Messaging Templates"],
}),
// Render data from existing template- GET by id
getMessagingTemplateById: build.query<MessagingTemplateResponse, string>({
Expand All @@ -85,6 +99,30 @@ const messagingTemplatesApi = baseApi.injectEndpoints({
}),
providesTags: () => ["Property-Specific Messaging Templates"],
}),
// Update existing template
putMessagingTemplateById: build.mutation<
MessagingTemplateResponse,
MessagingTemplateUpdate
>({
query: ({ templateId, template }) => ({
url: `/messaging/templates/${templateId}`,
method: "PUT",
body: template,
}),
invalidatesTags: () => ["Property-Specific Messaging Templates"],
}),
// Update existing template
patchMessagingTemplateById: build.mutation<
MessagingTemplateResponse,
MessagingTemplatePatch
>({
query: ({ templateId, template }) => ({
url: `/messaging/templates/${templateId}`,
method: "PATCH",
body: template,
}),
invalidatesTags: () => ["Property-Specific Messaging Templates"],
}),
// endpoint for rendering data for default template- GET by type
getMessagingTemplateDefault: build.query<
MessagingTemplateDefaultResponse,
Expand All @@ -94,6 +132,18 @@ const messagingTemplatesApi = baseApi.injectEndpoints({
url: `/messaging/templates/default/${templateType}`,
}),
}),
// endpoint for creating new messaging template- POST by type
createMessagingTemplateByType: build.mutation<
MessagingTemplateResponse,
MessagingTemplateCreate
>({
query: ({ templateType, template }) => ({
url: `/messaging/templates/${templateType}`,
method: "POST",
body: template,
}),
invalidatesTags: () => ["Property-Specific Messaging Templates"],
}),
// delete template by id
deleteMessagingTemplateById: build.mutation<void, string>({
query: (templateId: string) => ({
Expand All @@ -108,7 +158,11 @@ const messagingTemplatesApi = baseApi.injectEndpoints({
export const {
useGetMessagingTemplatesQuery,
useUpdateMessagingTemplatesMutation,
useGetSummaryMessagingTemplatesQuery,
useGetMessagingTemplateByIdQuery,
usePutMessagingTemplateByIdMutation,
useGetMessagingTemplateDefaultQuery,
useCreateMessagingTemplateByTypeMutation,
useDeleteMessagingTemplateByIdMutation,
usePatchMessagingTemplateByIdMutation,
} = messagingTemplatesApi;
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useToast } from "fidesui";
import { useCallback } from "react";

import { errorToastParams, successToastParams } from "~/features/common/toast";
import { usePatchMessagingTemplateByIdMutation } from "~/features/messaging-templates/messaging-templates.slice.plus";
import { usePatchMessagingTemplateByIdMutation } from "~/features/messaging-templates/messaging-templates.slice";
import { isErrorResult } from "~/types/errors";

const useMessagingTemplateToggle = () => {
Expand Down
2 changes: 1 addition & 1 deletion clients/admin-ui/src/pages/messaging/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import {
MessagingTemplateCreateOrUpdate,
useDeleteMessagingTemplateByIdMutation,
useGetMessagingTemplateByIdQuery,
usePutMessagingTemplateByIdMutation,
} from "~/features/messaging-templates/messaging-templates.slice";
import { usePutMessagingTemplateByIdMutation } from "~/features/messaging-templates/messaging-templates.slice.plus";
import PropertySpecificMessagingTemplateForm, {
FormValues,
} from "~/features/messaging-templates/PropertySpecificMessagingTemplateForm";
Expand Down
2 changes: 1 addition & 1 deletion clients/admin-ui/src/pages/messaging/add-template.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import Layout from "~/features/common/Layout";
import { errorToastParams, successToastParams } from "~/features/common/toast";
import {
MessagingTemplateCreateOrUpdate,
useCreateMessagingTemplateByTypeMutation,
useGetMessagingTemplateDefaultQuery,
} from "~/features/messaging-templates/messaging-templates.slice";
import { useCreateMessagingTemplateByTypeMutation } from "~/features/messaging-templates/messaging-templates.slice.plus";
import PropertySpecificMessagingTemplateForm, {
FormValues,
} from "~/features/messaging-templates/PropertySpecificMessagingTemplateForm";
Expand Down
2 changes: 1 addition & 1 deletion clients/admin-ui/src/pages/messaging/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { PaginationBar } from "~/features/common/table/v2/PaginationBar";
import AddMessagingTemplateModal from "~/features/messaging-templates/AddMessagingTemplateModal";
import { CustomizableMessagingTemplatesEnum } from "~/features/messaging-templates/CustomizableMessagingTemplatesEnum";
import CustomizableMessagingTemplatesLabelEnum from "~/features/messaging-templates/CustomizableMessagingTemplatesLabelEnum";
import { useGetSummaryMessagingTemplatesQuery } from "~/features/messaging-templates/messaging-templates.slice.plus";
import { useGetSummaryMessagingTemplatesQuery } from "~/features/messaging-templates/messaging-templates.slice";
import useMessagingTemplateToggle from "~/features/messaging-templates/useMessagingTemplateToggle";
import { useGetConfigurationSettingsQuery } from "~/features/privacy-requests";
import { useGetAllPropertiesQuery } from "~/features/properties";
Expand Down
Loading
Loading