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

Strapi: Allow scheduling content to be published / unpublished #2008

Merged
merged 6 commits into from
Oct 2, 2023
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
17 changes: 17 additions & 0 deletions backend/config/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,23 @@ export default ({ env }) => {
},
},
},
publisher: {
enabled: true,
// See: https://market.strapi.io/plugins/strapi-plugin-publisher
config: {
components: {
dateTimePicker: {
step: 15,
},
},
hooks: {
beforePublish: async ({ strapi, uid, entity }) => {},
afterPublish: async ({ strapi, uid, entity }) => {},
beforeUnpublish: async ({ strapi, uid, entity }) => {},
afterUnpublish: async ({ strapi, uid, entity }) => {},
},
},
},
addons: {
enabled: true,
resolve: './src/plugins/addons',
Expand Down
3 changes: 3 additions & 0 deletions backend/config/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ export default ({ env }) => ({
// app: {
// keys: env.array('APP_KEYS'),
// },
cron: {
enabled: true,
},
});
3 changes: 2 additions & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"@strapi/provider-upload-aws-s3": "4.13.6",
"@strapi/strapi": "4.13.6",
"better-sqlite3": "7.5.2",
"pg": "8.7.1"
"pg": "8.7.1",
"strapi-plugin-publisher": "^1.4.1"
},
"author": {
"name": "A Strapi developer"
Expand Down
36 changes: 35 additions & 1 deletion backend/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,13 @@
dependencies:
regenerator-runtime "^0.14.0"

"@babel/runtime@^7.15.4":
version "7.23.1"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.23.1.tgz#72741dc4d413338a91dcb044a86f3c0bc402646d"
integrity sha512-hC2v6p8ZSI/W0HUzh3V8C5g+NwSKzKPtJwSpTjwl0o297GP9+ZLQSkdvHz46CM3LqyoXxq+5G9komY+eSqSO0g==
dependencies:
regenerator-runtime "^0.14.0"

"@babel/template@^7.22.15", "@babel/template@^7.22.5":
version "7.22.15"
resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.22.15.tgz#09576efc3830f0430f4548ef971dde1350ef2f38"
Expand Down Expand Up @@ -2333,6 +2340,11 @@
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.198.tgz#4d27465257011aedc741a809f1269941fa2c5d4c"
integrity sha512-trNJ/vtMZYMLhfN45uLq4ShQSw0/S7xCTLLVM+WM1rmFpba/VS42jVUgaO3w/NOLiWR/09lnYk0yMaA/atdIsg==

"@types/lodash@^4.14.175":
version "4.14.199"
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.199.tgz#c3edb5650149d847a277a8961a7ad360c474e9bf"
integrity sha512-Vrjz5N5Ia4SEzWWgIVwnHNEnb1UE1XMkvY5DGXrAeOGE9imk0hgTHh5GyDjLDJi9OTCn9oo9dXH1uToK1VRfrg==

"@types/long@^4.0.0":
version "4.0.2"
resolved "https://registry.yarnpkg.com/@types/long/-/long-4.0.2.tgz#b74129719fc8d11c01868010082d483b7545591a"
Expand Down Expand Up @@ -8291,7 +8303,7 @@ react-is@^18.0.0, react-is@^18.2.0:
resolved "https://registry.yarnpkg.com/react-is/-/react-is-18.2.0.tgz#199431eeaaa2e09f86427efbb4f1473edb47609b"
integrity sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==

react-query@3.39.3:
react-query@3.39.3, react-query@^3.39.3:
version "3.39.3"
resolved "https://registry.yarnpkg.com/react-query/-/react-query-3.39.3.tgz#4cea7127c6c26bdea2de5fb63e51044330b03f35"
integrity sha512-nLfLz7GiohKTJDuT4us4X3h/8unOh+00MLb2yJoGTPjxKs2bc1iDhkNx2bd5MKklXnOD3NrVZ+J2UXujA5In4g==
Expand Down Expand Up @@ -9272,6 +9284,15 @@ std-env@^3.0.1:
resolved "https://registry.yarnpkg.com/std-env/-/std-env-3.4.3.tgz#326f11db518db751c83fd58574f449b7c3060910"
integrity sha512-f9aPhy8fYBuMN+sNfakZV18U39PbalgjXG3lLB9WkaYTxijru61wb57V9wxxNthXM5Sd88ETBWi29qLAsHO52Q==

strapi-plugin-publisher@^1.4.1:
version "1.4.1"
resolved "https://registry.yarnpkg.com/strapi-plugin-publisher/-/strapi-plugin-publisher-1.4.1.tgz#0ecc470904d40bac755e68c43f43740341d4c399"
integrity sha512-V+5tq8MneGIOIbnnA6DRlB9OWU2RlZggIzgnQvMWurTHrJQFhsvigXnJLct9ojZchtju08v0yb5BjIQaZGBd+g==
dependencies:
lodash "^4.17.21"
react-query "^3.39.3"
yup "^0.32.9"

stream-chain@2.2.5, stream-chain@^2.2.5:
version "2.2.5"
resolved "https://registry.yarnpkg.com/stream-chain/-/stream-chain-2.2.5.tgz#b30967e8f14ee033c5b9a19bbe8a2cba90ba0d09"
Expand Down Expand Up @@ -10405,3 +10426,16 @@ yup@0.32.9:
nanoclone "^0.2.1"
property-expr "^2.0.4"
toposort "^2.0.2"

yup@^0.32.9:
version "0.32.11"
resolved "https://registry.yarnpkg.com/yup/-/yup-0.32.11.tgz#d67fb83eefa4698607982e63f7ca4c5ed3cf18c5"
integrity sha512-Z2Fe1bn+eLstG8DRR6FTavGD+MeAwyfmouhHsIUgaADz8jvFKbO/fXc2trJKZg+5EBjh4gGm3iU/t3onKlXHIg==
dependencies:
"@babel/runtime" "^7.15.4"
"@types/lodash" "^4.14.175"
lodash "^4.17.21"
lodash-es "^4.17.21"
nanoclone "^0.2.1"
property-expr "^2.0.4"
toposort "^2.0.2"
76 changes: 76 additions & 0 deletions frontend/lib/strapi-sdk/generated/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,7 @@ export type GenericMorph =
| Page
| Product
| ProductList
| PublisherAction
| ReusableSection
| SocialPost
| Store
Expand Down Expand Up @@ -1130,6 +1131,7 @@ export type Mutation = {
createProduct?: Maybe<ProductEntityResponse>;
createProductList?: Maybe<ProductListEntityResponse>;
createProductListLocalization?: Maybe<ProductListEntityResponse>;
createPublisherAction?: Maybe<PublisherActionEntityResponse>;
createReusableSection?: Maybe<ReusableSectionEntityResponse>;
createSocialPost?: Maybe<SocialPostEntityResponse>;
createStore?: Maybe<StoreEntityResponse>;
Expand All @@ -1147,6 +1149,7 @@ export type Mutation = {
deletePage?: Maybe<PageEntityResponse>;
deleteProduct?: Maybe<ProductEntityResponse>;
deleteProductList?: Maybe<ProductListEntityResponse>;
deletePublisherAction?: Maybe<PublisherActionEntityResponse>;
deleteReusableSection?: Maybe<ReusableSectionEntityResponse>;
deleteSocialPost?: Maybe<SocialPostEntityResponse>;
deleteStore?: Maybe<StoreEntityResponse>;
Expand Down Expand Up @@ -1176,6 +1179,7 @@ export type Mutation = {
updatePage?: Maybe<PageEntityResponse>;
updateProduct?: Maybe<ProductEntityResponse>;
updateProductList?: Maybe<ProductListEntityResponse>;
updatePublisherAction?: Maybe<PublisherActionEntityResponse>;
updateReusableSection?: Maybe<ReusableSectionEntityResponse>;
updateSocialPost?: Maybe<SocialPostEntityResponse>;
updateStore?: Maybe<StoreEntityResponse>;
Expand Down Expand Up @@ -1256,6 +1260,10 @@ export type MutationCreateProductListLocalizationArgs = {
locale?: InputMaybe<Scalars['I18NLocaleCode']>;
};

export type MutationCreatePublisherActionArgs = {
data: PublisherActionInput;
};

export type MutationCreateReusableSectionArgs = {
data: ReusableSectionInput;
};
Expand Down Expand Up @@ -1320,6 +1328,10 @@ export type MutationDeleteProductListArgs = {
locale?: InputMaybe<Scalars['I18NLocaleCode']>;
};

export type MutationDeletePublisherActionArgs = {
id: Scalars['ID'];
};

export type MutationDeleteReusableSectionArgs = {
id: Scalars['ID'];
};
Expand Down Expand Up @@ -1430,6 +1442,11 @@ export type MutationUpdateProductListArgs = {
locale?: InputMaybe<Scalars['I18NLocaleCode']>;
};

export type MutationUpdatePublisherActionArgs = {
data: PublisherActionInput;
id: Scalars['ID'];
};

export type MutationUpdateReusableSectionArgs = {
data: ReusableSectionInput;
id: Scalars['ID'];
Expand Down Expand Up @@ -1777,6 +1794,53 @@ export enum PublicationState {
Preview = 'PREVIEW',
}

export type PublisherAction = {
__typename?: 'PublisherAction';
createdAt?: Maybe<Scalars['DateTime']>;
entityId?: Maybe<Scalars['Int']>;
entitySlug?: Maybe<Scalars['String']>;
executeAt?: Maybe<Scalars['DateTime']>;
mode?: Maybe<Scalars['String']>;
updatedAt?: Maybe<Scalars['DateTime']>;
};

export type PublisherActionEntity = {
__typename?: 'PublisherActionEntity';
attributes?: Maybe<PublisherAction>;
id?: Maybe<Scalars['ID']>;
};

export type PublisherActionEntityResponse = {
__typename?: 'PublisherActionEntityResponse';
data?: Maybe<PublisherActionEntity>;
};

export type PublisherActionEntityResponseCollection = {
__typename?: 'PublisherActionEntityResponseCollection';
data: Array<PublisherActionEntity>;
meta: ResponseCollectionMeta;
};

export type PublisherActionFiltersInput = {
and?: InputMaybe<Array<InputMaybe<PublisherActionFiltersInput>>>;
createdAt?: InputMaybe<DateTimeFilterInput>;
entityId?: InputMaybe<IntFilterInput>;
entitySlug?: InputMaybe<StringFilterInput>;
executeAt?: InputMaybe<DateTimeFilterInput>;
id?: InputMaybe<IdFilterInput>;
mode?: InputMaybe<StringFilterInput>;
not?: InputMaybe<PublisherActionFiltersInput>;
or?: InputMaybe<Array<InputMaybe<PublisherActionFiltersInput>>>;
updatedAt?: InputMaybe<DateTimeFilterInput>;
};

export type PublisherActionInput = {
entityId?: InputMaybe<Scalars['Int']>;
entitySlug?: InputMaybe<Scalars['String']>;
executeAt?: InputMaybe<Scalars['DateTime']>;
mode?: InputMaybe<Scalars['String']>;
};

export type Query = {
__typename?: 'Query';
banner?: Maybe<BannerEntityResponse>;
Expand All @@ -1797,6 +1861,8 @@ export type Query = {
productList?: Maybe<ProductListEntityResponse>;
productLists?: Maybe<ProductListEntityResponseCollection>;
products?: Maybe<ProductEntityResponseCollection>;
publisherAction?: Maybe<PublisherActionEntityResponse>;
publisherActions?: Maybe<PublisherActionEntityResponseCollection>;
reusableSection?: Maybe<ReusableSectionEntityResponse>;
reusableSections?: Maybe<ReusableSectionEntityResponseCollection>;
socialPost?: Maybe<SocialPostEntityResponse>;
Expand Down Expand Up @@ -1913,6 +1979,16 @@ export type QueryProductsArgs = {
sort?: InputMaybe<Array<InputMaybe<Scalars['String']>>>;
};

export type QueryPublisherActionArgs = {
id?: InputMaybe<Scalars['ID']>;
};

export type QueryPublisherActionsArgs = {
filters?: InputMaybe<PublisherActionFiltersInput>;
pagination?: InputMaybe<PaginationArg>;
sort?: InputMaybe<Array<InputMaybe<Scalars['String']>>>;
};

export type QueryReusableSectionArgs = {
id?: InputMaybe<Scalars['ID']>;
};
Expand Down
34 changes: 34 additions & 0 deletions frontend/lib/strapi-sdk/generated/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ import {
ProductListFiltersInput,
ProductListInput,
PublicationState,
PublisherActionFiltersInput,
PublisherActionInput,
ReusableSectionFiltersInput,
ReusableSectionInput,
SocialPostFiltersInput,
Expand Down Expand Up @@ -901,6 +903,38 @@ export function ProductListInputSchema(): z.ZodObject<

export const PublicationStateSchema = z.nativeEnum(PublicationState);

export function PublisherActionFiltersInputSchema(): z.ZodObject<
Properties<PublisherActionFiltersInput>
> {
return z.object<Properties<PublisherActionFiltersInput>>({
and: z
.array(z.lazy(() => PublisherActionFiltersInputSchema().nullable()))
.nullish(),
createdAt: z.lazy(() => DateTimeFilterInputSchema().nullish()),
entityId: z.lazy(() => IntFilterInputSchema().nullish()),
entitySlug: z.lazy(() => StringFilterInputSchema().nullish()),
executeAt: z.lazy(() => DateTimeFilterInputSchema().nullish()),
id: z.lazy(() => IdFilterInputSchema().nullish()),
mode: z.lazy(() => StringFilterInputSchema().nullish()),
not: z.lazy(() => PublisherActionFiltersInputSchema().nullish()),
or: z
.array(z.lazy(() => PublisherActionFiltersInputSchema().nullable()))
.nullish(),
updatedAt: z.lazy(() => DateTimeFilterInputSchema().nullish()),
});
}

export function PublisherActionInputSchema(): z.ZodObject<
Properties<PublisherActionInput>
> {
return z.object<Properties<PublisherActionInput>>({
entityId: z.number().nullish(),
entitySlug: z.string().nullish(),
executeAt: z.unknown().nullish(),
mode: z.string().nullish(),
});
}

export function ReusableSectionFiltersInputSchema(): z.ZodObject<
Properties<ReusableSectionFiltersInput>
> {
Expand Down
18 changes: 13 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading