mirror of
https://github.com/strapi/strapi.git
synced 2025-08-22 07:38:41 +00:00
feat(content-releases): add publish webhook (#19515)
* feat(content-releases): add publish webhook * apply Marks feedback
This commit is contained in:
parent
8d3598965d
commit
4af8963f68
@ -1 +1,5 @@
|
||||
module.exports = ({ env }) => ({});
|
||||
module.exports = ({ env }) => ({
|
||||
future: {
|
||||
contentReleasesScheduling: env('STRAPI_FUTURE_CONTENT_RELEASES_SCHEDULING', false),
|
||||
},
|
||||
});
|
||||
|
@ -1,11 +1,21 @@
|
||||
import { Events } from '../../../../../../../../admin/src/pages/Settings/pages/Webhooks/components/Events';
|
||||
|
||||
const events = {
|
||||
'review-workflows': ['review-workflows.updateEntryStage'],
|
||||
const eeTables = {
|
||||
'review-workflows': {
|
||||
'review-workflows': ['review-workflows.updateEntryStage'],
|
||||
},
|
||||
releases: {
|
||||
releases: ['releases.publish'],
|
||||
},
|
||||
};
|
||||
|
||||
const getHeaders = () => {
|
||||
return [{ id: 'review-workflows.updateEntryStage', defaultMessage: 'Stage Change' }];
|
||||
const getHeaders = (table: keyof typeof eeTables) => {
|
||||
switch (table) {
|
||||
case 'review-workflows':
|
||||
return () => [{ id: 'review-workflows.updateEntryStage', defaultMessage: 'Stage Change' }];
|
||||
case 'releases':
|
||||
return () => [{ id: 'releases.publish', defaultMessage: 'Publish' }];
|
||||
}
|
||||
};
|
||||
|
||||
const EventsTableEE = () => {
|
||||
@ -13,8 +23,12 @@ const EventsTableEE = () => {
|
||||
<Events.Root>
|
||||
<Events.Headers />
|
||||
<Events.Body />
|
||||
<Events.Headers getHeaders={getHeaders} />
|
||||
<Events.Body providedEvents={events} />
|
||||
{(Object.keys(eeTables) as Array<keyof typeof eeTables>).map((table) => (
|
||||
<>
|
||||
<Events.Headers getHeaders={getHeaders(table)} />
|
||||
<Events.Body providedEvents={eeTables[table]} />
|
||||
</>
|
||||
))}
|
||||
</Events.Root>
|
||||
);
|
||||
};
|
||||
|
@ -84,6 +84,9 @@ describe('bootstrap', () => {
|
||||
log: {
|
||||
error: jest.fn(),
|
||||
},
|
||||
webhookStore: {
|
||||
addAllowedEvent: jest.fn(),
|
||||
},
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
import type { LoadedStrapi, Entity as StrapiEntity } from '@strapi/types';
|
||||
|
||||
import { RELEASE_ACTION_MODEL_UID } from './constants';
|
||||
import { ALLOWED_WEBHOOK_EVENTS, RELEASE_ACTION_MODEL_UID } from './constants';
|
||||
import { getService } from './utils';
|
||||
|
||||
const { features } = require('@strapi/strapi/dist/utils/ee');
|
||||
@ -69,6 +69,10 @@ export const bootstrap = async ({ strapi }: { strapi: LoadedStrapi }) => {
|
||||
|
||||
throw err;
|
||||
});
|
||||
|
||||
Object.entries(ALLOWED_WEBHOOK_EVENTS).forEach(([key, value]) => {
|
||||
strapi.webhookStore.addAllowedEvent(key, value);
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -45,3 +45,7 @@ export const ACTIONS = [
|
||||
pluginName: 'content-releases',
|
||||
},
|
||||
];
|
||||
|
||||
export const ALLOWED_WEBHOOK_EVENTS = {
|
||||
RELEASES_PUBLISH: 'releases.publish',
|
||||
};
|
||||
|
@ -26,6 +26,9 @@ const baseStrapiMock = {
|
||||
isEnabled: jest.fn().mockReturnValue(true),
|
||||
},
|
||||
},
|
||||
eventHub: {
|
||||
emit: jest.fn(),
|
||||
},
|
||||
telemetry: {
|
||||
send: jest.fn().mockReturnValue(true),
|
||||
},
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user