@yimingliao/cms 0.0.155 → 0.0.157
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/export/client/components/resources/index.js +17 -0
- package/dist/src/client/applications/resources/seo-metadata/seo-metadata-empty-translation.js +54 -0
- package/dist/src/client/applications/resources/seo-metadata/use-upsert-form-data.js +15 -0
- package/dist/src/client/interfaces/components/resources/category/category-relations-section.js +3 -11
- package/dist/src/client/interfaces/components/resources/folder/file-manager/file-manager-header.js +115 -0
- package/dist/src/client/interfaces/components/resources/folder/file-manager-list.js +127 -0
- package/dist/src/client/interfaces/components/resources/folder/folder-card.js +62 -0
- package/dist/src/client/interfaces/components/resources/folder/folder-full-path.js +40 -0
- package/dist/src/client/interfaces/components/resources/folder/folder-list.js +156 -0
- package/dist/src/client/interfaces/components/resources/folder/folder-relations-section.js +75 -0
- package/dist/src/client/interfaces/components/resources/seo-metadata/seo-form/fields/base-tags.js +187 -0
- package/dist/src/client/interfaces/components/resources/seo-metadata/seo-form/fields/json-ld-tags.js +78 -0
- package/dist/src/client/interfaces/components/resources/seo-metadata/seo-form/fields/open-graph-tags.js +441 -0
- package/dist/src/client/interfaces/components/resources/seo-metadata/seo-form/fields/twitter-tags.js +125 -0
- package/dist/src/client/interfaces/components/resources/seo-metadata/seo-form/reference-card.js +85 -0
- package/dist/src/client/interfaces/components/resources/seo-metadata/seo-form/seo-form-side-fields.js +56 -0
- package/dist/src/client/interfaces/components/resources/seo-metadata/seo-form/seo-form.js +186 -0
- package/dist/src/client/interfaces/components/resources/seo-metadata/seo-metadata-dialog.js +69 -0
- package/dist/src/client/interfaces/components/resources/tag/tag-card.js +78 -0
- package/dist/src/client/interfaces/components/resources/tag/tag-list.js +142 -0
- package/dist/src/client/interfaces/components/resources/tag/tag-relations-section.js +70 -0
- package/dist/src/client/interfaces/components/resources/topic/topic-card.js +91 -0
- package/dist/src/client/interfaces/components/resources/topic/topic-list.js +141 -0
- package/dist/src/client/interfaces/components/resources/topic/topic-relations-section.js +104 -0
- package/dist/types/export/client/components/resources/index.d.ts +1 -1
- package/dist/types/export/client/components/resources/index.d.ts.map +1 -1
- package/dist/types/src/client/applications/resources/seo-metadata/index.d.ts +2 -0
- package/dist/types/src/client/applications/resources/seo-metadata/index.d.ts.map +1 -0
- package/dist/types/src/client/applications/resources/seo-metadata/seo-metadata-empty-translation.d.ts +34 -0
- package/dist/types/src/client/applications/resources/seo-metadata/seo-metadata-empty-translation.d.ts.map +1 -0
- package/dist/types/src/client/applications/resources/seo-metadata/use-upsert-form-data.d.ts +79 -0
- package/dist/types/src/client/applications/resources/seo-metadata/use-upsert-form-data.d.ts.map +1 -0
- package/dist/types/src/client/interfaces/components/resources/category/category-relations-section.d.ts.map +1 -1
- package/dist/types/src/client/interfaces/components/resources/file/file-list.d.ts +1 -1
- package/dist/types/src/client/interfaces/components/resources/file/file-list.d.ts.map +1 -1
- package/dist/types/src/client/interfaces/components/resources/folder/file-manager/file-manager-header.d.ts +8 -0
- package/dist/types/src/client/interfaces/components/resources/folder/file-manager/file-manager-header.d.ts.map +1 -0
- package/dist/types/src/client/interfaces/components/resources/folder/file-manager-list.d.ts +28 -0
- package/dist/types/src/client/interfaces/components/resources/folder/file-manager-list.d.ts.map +1 -0
- package/dist/types/src/client/interfaces/components/resources/folder/folder-card.d.ts +13 -0
- package/dist/types/src/client/interfaces/components/resources/folder/folder-card.d.ts.map +1 -0
- package/dist/types/src/client/interfaces/components/resources/folder/folder-full-path.d.ts +9 -0
- package/dist/types/src/client/interfaces/components/resources/folder/folder-full-path.d.ts.map +1 -0
- package/dist/types/src/client/interfaces/components/resources/folder/folder-list.d.ts +26 -0
- package/dist/types/src/client/interfaces/components/resources/folder/folder-list.d.ts.map +1 -0
- package/dist/types/src/client/interfaces/components/resources/folder/folder-relations-section.d.ts +10 -0
- package/dist/types/src/client/interfaces/components/resources/folder/folder-relations-section.d.ts.map +1 -0
- package/dist/types/src/client/interfaces/components/resources/folder/index.d.ts +6 -0
- package/dist/types/src/client/interfaces/components/resources/folder/index.d.ts.map +1 -0
- package/dist/types/src/client/interfaces/components/resources/index.d.ts +4 -0
- package/dist/types/src/client/interfaces/components/resources/index.d.ts.map +1 -1
- package/dist/types/src/client/interfaces/components/resources/seo-metadata/index.d.ts +3 -0
- package/dist/types/src/client/interfaces/components/resources/seo-metadata/index.d.ts.map +1 -0
- package/dist/types/src/client/interfaces/components/resources/seo-metadata/seo-form/fields/base-tags.d.ts +11 -0
- package/dist/types/src/client/interfaces/components/resources/seo-metadata/seo-form/fields/base-tags.d.ts.map +1 -0
- package/dist/types/src/client/interfaces/components/resources/seo-metadata/seo-form/fields/index.d.ts +5 -0
- package/dist/types/src/client/interfaces/components/resources/seo-metadata/seo-form/fields/index.d.ts.map +1 -0
- package/dist/types/src/client/interfaces/components/resources/seo-metadata/seo-form/fields/json-ld-tags.d.ts +9 -0
- package/dist/types/src/client/interfaces/components/resources/seo-metadata/seo-form/fields/json-ld-tags.d.ts.map +1 -0
- package/dist/types/src/client/interfaces/components/resources/seo-metadata/seo-form/fields/open-graph-tags.d.ts +13 -0
- package/dist/types/src/client/interfaces/components/resources/seo-metadata/seo-form/fields/open-graph-tags.d.ts.map +1 -0
- package/dist/types/src/client/interfaces/components/resources/seo-metadata/seo-form/fields/twitter-tags.d.ts +9 -0
- package/dist/types/src/client/interfaces/components/resources/seo-metadata/seo-form/fields/twitter-tags.d.ts.map +1 -0
- package/dist/types/src/client/interfaces/components/resources/seo-metadata/seo-form/index.d.ts +3 -0
- package/dist/types/src/client/interfaces/components/resources/seo-metadata/seo-form/index.d.ts.map +1 -0
- package/dist/types/src/client/interfaces/components/resources/seo-metadata/seo-form/reference-card.d.ts +2 -0
- package/dist/types/src/client/interfaces/components/resources/seo-metadata/seo-form/reference-card.d.ts.map +1 -0
- package/dist/types/src/client/interfaces/components/resources/seo-metadata/seo-form/seo-form-side-fields.d.ts +8 -0
- package/dist/types/src/client/interfaces/components/resources/seo-metadata/seo-form/seo-form-side-fields.d.ts.map +1 -0
- package/dist/types/src/client/interfaces/components/resources/seo-metadata/seo-form/seo-form.d.ts +28 -0
- package/dist/types/src/client/interfaces/components/resources/seo-metadata/seo-form/seo-form.d.ts.map +1 -0
- package/dist/types/src/client/interfaces/components/resources/seo-metadata/seo-metadata-dialog.d.ts +11 -0
- package/dist/types/src/client/interfaces/components/resources/seo-metadata/seo-metadata-dialog.d.ts.map +1 -0
- package/dist/types/src/client/interfaces/components/resources/tag/index.d.ts +4 -0
- package/dist/types/src/client/interfaces/components/resources/tag/index.d.ts.map +1 -0
- package/dist/types/src/client/interfaces/components/resources/tag/tag-card.d.ts +11 -0
- package/dist/types/src/client/interfaces/components/resources/tag/tag-card.d.ts.map +1 -0
- package/dist/types/src/client/interfaces/components/resources/tag/tag-list.d.ts +18 -0
- package/dist/types/src/client/interfaces/components/resources/tag/tag-list.d.ts.map +1 -0
- package/dist/types/src/client/interfaces/components/resources/tag/tag-relations-section.d.ts +9 -0
- package/dist/types/src/client/interfaces/components/resources/tag/tag-relations-section.d.ts.map +1 -0
- package/dist/types/src/client/interfaces/components/resources/topic/index.d.ts +4 -0
- package/dist/types/src/client/interfaces/components/resources/topic/index.d.ts.map +1 -0
- package/dist/types/src/client/interfaces/components/resources/topic/topic-card.d.ts +11 -0
- package/dist/types/src/client/interfaces/components/resources/topic/topic-card.d.ts.map +1 -0
- package/dist/types/src/client/interfaces/components/resources/topic/topic-list.d.ts +17 -0
- package/dist/types/src/client/interfaces/components/resources/topic/topic-list.d.ts.map +1 -0
- package/dist/types/src/client/interfaces/components/resources/topic/topic-relations-section.d.ts +12 -0
- package/dist/types/src/client/interfaces/components/resources/topic/topic-relations-section.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import 'react';
|
|
4
|
+
import 'ua-parser-js';
|
|
5
|
+
import { cn } from '../../../../../applications/shadcn/utils.js';
|
|
6
|
+
import 'next/navigation';
|
|
7
|
+
import 'intor/react';
|
|
8
|
+
import 'lucide-react';
|
|
9
|
+
import '@radix-ui/react-avatar';
|
|
10
|
+
import '../../../shadcn/badge.js';
|
|
11
|
+
import '../../../shadcn/button.js';
|
|
12
|
+
import '@radix-ui/react-collapsible';
|
|
13
|
+
import '@radix-ui/react-dialog';
|
|
14
|
+
import '@radix-ui/react-dropdown-menu';
|
|
15
|
+
import '../../../shadcn/input-group.js';
|
|
16
|
+
import '../../../shadcn/item.js';
|
|
17
|
+
import '@radix-ui/react-label';
|
|
18
|
+
import '@radix-ui/react-select';
|
|
19
|
+
import '@radix-ui/react-separator';
|
|
20
|
+
import '../../../shadcn/sidebar.js';
|
|
21
|
+
import 'next-themes';
|
|
22
|
+
import 'sonner';
|
|
23
|
+
import '@radix-ui/react-tabs';
|
|
24
|
+
import '@radix-ui/react-tooltip';
|
|
25
|
+
import 'next/link';
|
|
26
|
+
import '../../../../../../constants/paths/auth.js';
|
|
27
|
+
import '../../../../../../constants/paths/main.js';
|
|
28
|
+
import '../../../../../../constants/paths/resources.js';
|
|
29
|
+
import '../../../../../../constants/redirect-paths.js';
|
|
30
|
+
import 'mime-types';
|
|
31
|
+
import { ActionButtonsCard } from '../../../ui/cards/action-buttons-card.js';
|
|
32
|
+
import '../../../../../../domain/resources/admin/constants.js';
|
|
33
|
+
import 'next/image';
|
|
34
|
+
import { ReferenceCard } from './reference-card.js';
|
|
35
|
+
|
|
36
|
+
function SeoFormSideFields({
|
|
37
|
+
hasBeenCreated,
|
|
38
|
+
isLoading,
|
|
39
|
+
isTriggering,
|
|
40
|
+
setIsOpen
|
|
41
|
+
}) {
|
|
42
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("sticky top-0", "h-fit w-max", "flex flex-col gap-6"), children: [
|
|
43
|
+
/* @__PURE__ */ jsx(
|
|
44
|
+
ActionButtonsCard,
|
|
45
|
+
{
|
|
46
|
+
action: hasBeenCreated ? "update" : "create",
|
|
47
|
+
isInitializing: isLoading,
|
|
48
|
+
isProcessing: isTriggering,
|
|
49
|
+
cancelButtonProps: { onClick: () => setIsOpen(false) }
|
|
50
|
+
}
|
|
51
|
+
),
|
|
52
|
+
/* @__PURE__ */ jsx(ReferenceCard, {})
|
|
53
|
+
] });
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { SeoFormSideFields };
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import { useEffect } from 'react';
|
|
4
|
+
import '../../../../../../constants/paths/auth.js';
|
|
5
|
+
import '../../../../../../constants/paths/main.js';
|
|
6
|
+
import '../../../../../../constants/paths/resources.js';
|
|
7
|
+
import { CACHE_KEYS } from '../../../../../../constants/cache-keys.js';
|
|
8
|
+
import '../../../../../../constants/redirect-paths.js';
|
|
9
|
+
import '../../../../../../domain/resources/admin/constants.js';
|
|
10
|
+
import { POST_TYPES } from '../../../../../../domain/resources/post/props.js';
|
|
11
|
+
import 'mime-types';
|
|
12
|
+
import { datetimeToUi } from '../../../../../../shared/form/normalizers/datetime-to-ui.js';
|
|
13
|
+
import { jsonArrayToUi } from '../../../../../../shared/form/normalizers/json-array-to-ui.js';
|
|
14
|
+
import { ensureArray } from '../../../../../../shared/utils/ensure-array.js';
|
|
15
|
+
import { useSeoMetadataUpsertFormData } from '../../../../../applications/resources/seo-metadata/use-upsert-form-data.js';
|
|
16
|
+
import 'intor/react';
|
|
17
|
+
import 'lucide-react';
|
|
18
|
+
import 'ua-parser-js';
|
|
19
|
+
import 'clsx';
|
|
20
|
+
import 'tailwind-merge';
|
|
21
|
+
import 'next/navigation';
|
|
22
|
+
import '@radix-ui/react-avatar';
|
|
23
|
+
import '../../../shadcn/badge.js';
|
|
24
|
+
import '../../../shadcn/button.js';
|
|
25
|
+
import '@radix-ui/react-collapsible';
|
|
26
|
+
import '@radix-ui/react-dialog';
|
|
27
|
+
import '@radix-ui/react-dropdown-menu';
|
|
28
|
+
import '../../../shadcn/input-group.js';
|
|
29
|
+
import '../../../shadcn/item.js';
|
|
30
|
+
import '@radix-ui/react-label';
|
|
31
|
+
import '@radix-ui/react-select';
|
|
32
|
+
import '@radix-ui/react-separator';
|
|
33
|
+
import '../../../shadcn/sidebar.js';
|
|
34
|
+
import 'next-themes';
|
|
35
|
+
import 'sonner';
|
|
36
|
+
import '@radix-ui/react-tabs';
|
|
37
|
+
import '@radix-ui/react-tooltip';
|
|
38
|
+
import 'next/link';
|
|
39
|
+
import { Form } from '../../../ui/form/form.js';
|
|
40
|
+
import { FieldsContainer } from '../../../ui/form/containers/fields-container.js';
|
|
41
|
+
import 'next/image';
|
|
42
|
+
import { SeoFormSideFields } from './seo-form-side-fields.js';
|
|
43
|
+
|
|
44
|
+
function createSeoForm({
|
|
45
|
+
postFindFullAction,
|
|
46
|
+
seoMetadataUpsertAction,
|
|
47
|
+
useQuery,
|
|
48
|
+
useCommand,
|
|
49
|
+
buildTranslations,
|
|
50
|
+
BaseTags,
|
|
51
|
+
JsonLdTags,
|
|
52
|
+
OpenGraphTags,
|
|
53
|
+
TwitterTags
|
|
54
|
+
}) {
|
|
55
|
+
return function SeoForm({
|
|
56
|
+
id,
|
|
57
|
+
type = POST_TYPES.POST,
|
|
58
|
+
slug,
|
|
59
|
+
setIsOpen
|
|
60
|
+
}) {
|
|
61
|
+
const {
|
|
62
|
+
data: post,
|
|
63
|
+
isFetching,
|
|
64
|
+
refetch
|
|
65
|
+
} = useQuery(
|
|
66
|
+
() => postFindFullAction({
|
|
67
|
+
...id && { id },
|
|
68
|
+
type,
|
|
69
|
+
...slug && { slug }
|
|
70
|
+
}),
|
|
71
|
+
[CACHE_KEYS.findFull, id, type, slug],
|
|
72
|
+
{ select: (data) => data?.post, enabled: !!(id || slug) }
|
|
73
|
+
);
|
|
74
|
+
const postTranslations = ensureArray(post?.translations);
|
|
75
|
+
const seoMetadatas = ensureArray(post?.seoMetadatas);
|
|
76
|
+
const hasBeenCreated = seoMetadatas.length > 0;
|
|
77
|
+
const { formData, setFormData } = useSeoMetadataUpsertFormData({
|
|
78
|
+
...id && { id },
|
|
79
|
+
buildTranslations
|
|
80
|
+
});
|
|
81
|
+
const { execute, isPending, errors } = useCommand(
|
|
82
|
+
() => seoMetadataUpsertAction({ formData }),
|
|
83
|
+
{ onSuccess: () => void refetch() }
|
|
84
|
+
);
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
if (post && seoMetadatas.length > 0) {
|
|
87
|
+
queueMicrotask(
|
|
88
|
+
() => setFormData({
|
|
89
|
+
postId: post.id,
|
|
90
|
+
translations: seoMetadatas.map((s) => {
|
|
91
|
+
return {
|
|
92
|
+
...s,
|
|
93
|
+
ogType: s.ogType,
|
|
94
|
+
twitterCard: s.twitterCard,
|
|
95
|
+
// Datetime to UI
|
|
96
|
+
ogArticlePublishedTime: datetimeToUi(s.ogArticlePublishedTime),
|
|
97
|
+
ogArticleModifiedTime: datetimeToUi(s.ogArticleModifiedTime),
|
|
98
|
+
// Json Array to UI
|
|
99
|
+
jsonLd: jsonArrayToUi(s.jsonLd)
|
|
100
|
+
};
|
|
101
|
+
})
|
|
102
|
+
})
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
}, [post, seoMetadatas, setFormData]);
|
|
106
|
+
useEffect(() => {
|
|
107
|
+
if (post && !hasBeenCreated && postTranslations) {
|
|
108
|
+
queueMicrotask(
|
|
109
|
+
() => setFormData((prev) => ({
|
|
110
|
+
...prev,
|
|
111
|
+
postId: post.id,
|
|
112
|
+
translations: prev.translations.map((prevTranslation) => {
|
|
113
|
+
const t = postTranslations.find(
|
|
114
|
+
(pt) => pt.locale === prevTranslation.locale
|
|
115
|
+
);
|
|
116
|
+
if (!t)
|
|
117
|
+
return {
|
|
118
|
+
...prevTranslation,
|
|
119
|
+
ogArticlePublishedTime: datetimeToUi(
|
|
120
|
+
(/* @__PURE__ */ new Date()).toISOString()
|
|
121
|
+
),
|
|
122
|
+
ogArticleModifiedTime: datetimeToUi((/* @__PURE__ */ new Date()).toISOString())
|
|
123
|
+
};
|
|
124
|
+
const title = t.title ?? prevTranslation.title;
|
|
125
|
+
const description = t.description ?? prevTranslation.description;
|
|
126
|
+
return {
|
|
127
|
+
...prevTranslation,
|
|
128
|
+
title,
|
|
129
|
+
description,
|
|
130
|
+
ogArticlePublishedTime: datetimeToUi((/* @__PURE__ */ new Date()).toISOString()),
|
|
131
|
+
ogArticleModifiedTime: datetimeToUi((/* @__PURE__ */ new Date()).toISOString())
|
|
132
|
+
};
|
|
133
|
+
})
|
|
134
|
+
}))
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
}, [post, hasBeenCreated, postTranslations, type, setFormData]);
|
|
138
|
+
return /* @__PURE__ */ jsx(Form, { onSubmit: () => void execute(), children: /* @__PURE__ */ jsxs(FieldsContainer, { children: [
|
|
139
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-1 flex-col gap-6 pb-64", children: [
|
|
140
|
+
/* @__PURE__ */ jsx(
|
|
141
|
+
BaseTags,
|
|
142
|
+
{
|
|
143
|
+
formData,
|
|
144
|
+
setFormData,
|
|
145
|
+
errors
|
|
146
|
+
}
|
|
147
|
+
),
|
|
148
|
+
/* @__PURE__ */ jsx(
|
|
149
|
+
OpenGraphTags,
|
|
150
|
+
{
|
|
151
|
+
formData,
|
|
152
|
+
setFormData,
|
|
153
|
+
errors
|
|
154
|
+
}
|
|
155
|
+
),
|
|
156
|
+
/* @__PURE__ */ jsx(
|
|
157
|
+
TwitterTags,
|
|
158
|
+
{
|
|
159
|
+
formData,
|
|
160
|
+
setFormData,
|
|
161
|
+
errors
|
|
162
|
+
}
|
|
163
|
+
),
|
|
164
|
+
/* @__PURE__ */ jsx(
|
|
165
|
+
JsonLdTags,
|
|
166
|
+
{
|
|
167
|
+
formData,
|
|
168
|
+
setFormData,
|
|
169
|
+
errors
|
|
170
|
+
}
|
|
171
|
+
)
|
|
172
|
+
] }),
|
|
173
|
+
/* @__PURE__ */ jsx(
|
|
174
|
+
SeoFormSideFields,
|
|
175
|
+
{
|
|
176
|
+
hasBeenCreated,
|
|
177
|
+
isLoading: isFetching,
|
|
178
|
+
isTriggering: isPending,
|
|
179
|
+
setIsOpen
|
|
180
|
+
}
|
|
181
|
+
)
|
|
182
|
+
] }) });
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export { createSeoForm };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useTranslator } from 'intor/react';
|
|
4
|
+
import { useState } from 'react';
|
|
5
|
+
import '@radix-ui/react-avatar';
|
|
6
|
+
import 'ua-parser-js';
|
|
7
|
+
import 'clsx';
|
|
8
|
+
import 'tailwind-merge';
|
|
9
|
+
import 'next/navigation';
|
|
10
|
+
import '../../shadcn/badge.js';
|
|
11
|
+
import '../../shadcn/button.js';
|
|
12
|
+
import '@radix-ui/react-collapsible';
|
|
13
|
+
import { Dialog, DialogTrigger, DialogContent, DialogTitle } from '../../shadcn/dialog.js';
|
|
14
|
+
import '@radix-ui/react-dropdown-menu';
|
|
15
|
+
import 'lucide-react';
|
|
16
|
+
import '../../shadcn/input-group.js';
|
|
17
|
+
import '../../shadcn/item.js';
|
|
18
|
+
import '@radix-ui/react-label';
|
|
19
|
+
import '@radix-ui/react-select';
|
|
20
|
+
import '@radix-ui/react-separator';
|
|
21
|
+
import '@radix-ui/react-dialog';
|
|
22
|
+
import '../../shadcn/sidebar.js';
|
|
23
|
+
import 'next-themes';
|
|
24
|
+
import 'sonner';
|
|
25
|
+
import '@radix-ui/react-tabs';
|
|
26
|
+
import '@radix-ui/react-tooltip';
|
|
27
|
+
import { Button } from '../../ui/buttons/button.js';
|
|
28
|
+
import 'next/link';
|
|
29
|
+
import '../../../../../constants/paths/auth.js';
|
|
30
|
+
import '../../../../../constants/paths/main.js';
|
|
31
|
+
import '../../../../../constants/paths/resources.js';
|
|
32
|
+
import '../../../../../constants/redirect-paths.js';
|
|
33
|
+
import 'mime-types';
|
|
34
|
+
import '../../../../../domain/resources/admin/constants.js';
|
|
35
|
+
import 'next/image';
|
|
36
|
+
|
|
37
|
+
function createSeoMetadataDialog({
|
|
38
|
+
SeoForm
|
|
39
|
+
}) {
|
|
40
|
+
return function SeoMetadataDialog({
|
|
41
|
+
id,
|
|
42
|
+
type,
|
|
43
|
+
slug,
|
|
44
|
+
// ui states
|
|
45
|
+
isLoading = false,
|
|
46
|
+
isDisabled = false
|
|
47
|
+
}) {
|
|
48
|
+
const { t } = useTranslator();
|
|
49
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
50
|
+
return /* @__PURE__ */ jsxs(Dialog, { open: isOpen, onOpenChange: setIsOpen, children: [
|
|
51
|
+
/* @__PURE__ */ jsx(DialogTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
52
|
+
Button,
|
|
53
|
+
{
|
|
54
|
+
variant: "outline",
|
|
55
|
+
isLoading,
|
|
56
|
+
isDisabled,
|
|
57
|
+
onClick: () => setIsOpen(true),
|
|
58
|
+
children: t("resources.seo-metadata.text")
|
|
59
|
+
}
|
|
60
|
+
) }),
|
|
61
|
+
/* @__PURE__ */ jsxs(DialogContent, { className: "container h-[80%]", children: [
|
|
62
|
+
/* @__PURE__ */ jsx(DialogTitle, { className: "sr-only", children: "Dialog" }),
|
|
63
|
+
/* @__PURE__ */ jsx("div", { className: "size-full overflow-y-scroll pr-6", children: !!(id || type && slug) && /* @__PURE__ */ jsx(SeoForm, { id, type, slug, setIsOpen }) })
|
|
64
|
+
] })
|
|
65
|
+
] });
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export { createSeoMetadataDialog };
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import { useTranslator } from 'intor/react';
|
|
4
|
+
import { File, Tag } from 'lucide-react';
|
|
5
|
+
import { PATHS } from '../../../../../constants/paths/index.js';
|
|
6
|
+
import '../../../../../constants/redirect-paths.js';
|
|
7
|
+
import 'mime-types';
|
|
8
|
+
import { findTranslation } from '../../../../../shared/translation/find-translation.js';
|
|
9
|
+
import 'react';
|
|
10
|
+
import 'ua-parser-js';
|
|
11
|
+
import { cn } from '../../../../applications/shadcn/utils.js';
|
|
12
|
+
import 'next/navigation';
|
|
13
|
+
import '@radix-ui/react-avatar';
|
|
14
|
+
import '../../shadcn/badge.js';
|
|
15
|
+
import '../../shadcn/button.js';
|
|
16
|
+
import '@radix-ui/react-collapsible';
|
|
17
|
+
import '@radix-ui/react-dialog';
|
|
18
|
+
import '@radix-ui/react-dropdown-menu';
|
|
19
|
+
import '../../shadcn/input-group.js';
|
|
20
|
+
import '../../shadcn/item.js';
|
|
21
|
+
import '@radix-ui/react-label';
|
|
22
|
+
import '@radix-ui/react-select';
|
|
23
|
+
import '@radix-ui/react-separator';
|
|
24
|
+
import '../../shadcn/sidebar.js';
|
|
25
|
+
import 'next-themes';
|
|
26
|
+
import 'sonner';
|
|
27
|
+
import '@radix-ui/react-tabs';
|
|
28
|
+
import '@radix-ui/react-tooltip';
|
|
29
|
+
import { ResourceCard } from '../../ui/cards/resource-card/resource-card.js';
|
|
30
|
+
import 'next/link';
|
|
31
|
+
import '../../../../../domain/resources/admin/constants.js';
|
|
32
|
+
import 'next/image';
|
|
33
|
+
import { PostStatusBarIcons } from '../post/post-status-bar-icons.js';
|
|
34
|
+
|
|
35
|
+
function TagCard({
|
|
36
|
+
tag,
|
|
37
|
+
// Link Props
|
|
38
|
+
openNewTab = false,
|
|
39
|
+
anchorProps,
|
|
40
|
+
// Base
|
|
41
|
+
className = ""
|
|
42
|
+
}) {
|
|
43
|
+
const { t, locale } = useTranslator();
|
|
44
|
+
const title = findTranslation(tag?.translations, locale)?.title ?? "";
|
|
45
|
+
const { isActive, isSlugActive, index } = tag || {};
|
|
46
|
+
return /* @__PURE__ */ jsx(
|
|
47
|
+
ResourceCard,
|
|
48
|
+
{
|
|
49
|
+
className: cn(className, "w-72!"),
|
|
50
|
+
href: `${PATHS.resources.tag.path}/${tag?.id}`,
|
|
51
|
+
openNewTab,
|
|
52
|
+
anchorProps,
|
|
53
|
+
cardStatusBarProps: {
|
|
54
|
+
badge: /* @__PURE__ */ jsx("span", { className: "flex-center px-4", children: /* @__PURE__ */ jsx(Tag, { className: "size-4" }) }),
|
|
55
|
+
children: /* @__PURE__ */ jsx(
|
|
56
|
+
PostStatusBarIcons,
|
|
57
|
+
{
|
|
58
|
+
isActive,
|
|
59
|
+
index,
|
|
60
|
+
isSlugActive
|
|
61
|
+
}
|
|
62
|
+
)
|
|
63
|
+
},
|
|
64
|
+
cardTextContentProps: {
|
|
65
|
+
title,
|
|
66
|
+
children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
|
|
67
|
+
/* @__PURE__ */ jsx(File, { className: "size-4" }),
|
|
68
|
+
/* @__PURE__ */ jsxs("p", { className: "truncate", children: [
|
|
69
|
+
":\xA0",
|
|
70
|
+
tag && "taggedPosts" in tag ? tag.taggedPosts?.length : /* @__PURE__ */ jsx("span", { className: "text-xs opacity-50", children: t("resources.see-in-details.text") })
|
|
71
|
+
] })
|
|
72
|
+
] })
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export { TagCard };
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { useState, useMemo, useEffect } from 'react';
|
|
3
|
+
import '../../../../../constants/paths/auth.js';
|
|
4
|
+
import '../../../../../constants/paths/main.js';
|
|
5
|
+
import '../../../../../constants/paths/resources.js';
|
|
6
|
+
import { CACHE_KEYS } from '../../../../../constants/cache-keys.js';
|
|
7
|
+
import '../../../../../constants/redirect-paths.js';
|
|
8
|
+
import 'mime-types';
|
|
9
|
+
import { debounce } from '../../../../../shared/utils/debounce.js';
|
|
10
|
+
import { ensureArray } from '../../../../../shared/utils/ensure-array.js';
|
|
11
|
+
import 'ua-parser-js';
|
|
12
|
+
import { cn } from '../../../../applications/shadcn/utils.js';
|
|
13
|
+
import 'next/navigation';
|
|
14
|
+
import 'intor/react';
|
|
15
|
+
import 'lucide-react';
|
|
16
|
+
import '@radix-ui/react-avatar';
|
|
17
|
+
import '../../shadcn/badge.js';
|
|
18
|
+
import '../../shadcn/button.js';
|
|
19
|
+
import '@radix-ui/react-collapsible';
|
|
20
|
+
import '@radix-ui/react-dialog';
|
|
21
|
+
import '@radix-ui/react-dropdown-menu';
|
|
22
|
+
import '../../shadcn/input-group.js';
|
|
23
|
+
import '../../shadcn/item.js';
|
|
24
|
+
import '@radix-ui/react-label';
|
|
25
|
+
import '@radix-ui/react-select';
|
|
26
|
+
import '@radix-ui/react-separator';
|
|
27
|
+
import '../../shadcn/sidebar.js';
|
|
28
|
+
import 'next-themes';
|
|
29
|
+
import 'sonner';
|
|
30
|
+
import '@radix-ui/react-tabs';
|
|
31
|
+
import '@radix-ui/react-tooltip';
|
|
32
|
+
import { ListCardsContainer } from '../../ui/blocks/list-cards-container/list-cards-container.js';
|
|
33
|
+
import 'next/link';
|
|
34
|
+
import '../../../../../domain/resources/admin/constants.js';
|
|
35
|
+
import 'next/image';
|
|
36
|
+
import { Tick } from '../../ui/features/tick.js';
|
|
37
|
+
import { ControlFieldsButtons } from '../post/control-fields-buttons.js';
|
|
38
|
+
import { TagCard } from './tag-card.js';
|
|
39
|
+
|
|
40
|
+
function createTagList({
|
|
41
|
+
useQuery,
|
|
42
|
+
postFindListCardsAction
|
|
43
|
+
}) {
|
|
44
|
+
return function TagList({
|
|
45
|
+
usableFields,
|
|
46
|
+
//
|
|
47
|
+
setItemStates,
|
|
48
|
+
// Link Props
|
|
49
|
+
openNewTab = false,
|
|
50
|
+
// Pick Mode
|
|
51
|
+
pickedItems,
|
|
52
|
+
handleClick
|
|
53
|
+
}) {
|
|
54
|
+
const [page, setPage] = useState(1);
|
|
55
|
+
const [pageSize, setPageSize] = useState(20);
|
|
56
|
+
const [searchString, setSearchString] = useState("");
|
|
57
|
+
const debouncedSetSearchString = useMemo(
|
|
58
|
+
() => debounce((v) => setSearchString(v), 300),
|
|
59
|
+
[]
|
|
60
|
+
);
|
|
61
|
+
const [controlFields, setControlFields] = useState({
|
|
62
|
+
isActive: false,
|
|
63
|
+
isIndexActive: false,
|
|
64
|
+
isSlugActive: false
|
|
65
|
+
});
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
queueMicrotask(() => setPage(1));
|
|
68
|
+
}, [controlFields, setPage]);
|
|
69
|
+
const { data, isFetching } = useQuery(
|
|
70
|
+
() => postFindListCardsAction({
|
|
71
|
+
type: "TAG",
|
|
72
|
+
page,
|
|
73
|
+
pageSize,
|
|
74
|
+
searchString
|
|
75
|
+
}),
|
|
76
|
+
[
|
|
77
|
+
CACHE_KEYS.findListCards("tag"),
|
|
78
|
+
page,
|
|
79
|
+
pageSize,
|
|
80
|
+
searchString,
|
|
81
|
+
JSON.stringify(controlFields)
|
|
82
|
+
]
|
|
83
|
+
);
|
|
84
|
+
const tags = useMemo(() => ensureArray(data?.items), [data?.items]);
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
setItemStates?.({
|
|
87
|
+
items: tags,
|
|
88
|
+
count: data?.total ?? 0,
|
|
89
|
+
isFetching
|
|
90
|
+
});
|
|
91
|
+
}, [data?.total, isFetching, tags, setItemStates]);
|
|
92
|
+
return /* @__PURE__ */ jsx(
|
|
93
|
+
ListCardsContainer,
|
|
94
|
+
{
|
|
95
|
+
page,
|
|
96
|
+
setPage,
|
|
97
|
+
pageSize,
|
|
98
|
+
setPageSize,
|
|
99
|
+
total: data?.total ?? 0,
|
|
100
|
+
searchString,
|
|
101
|
+
setSearchString: debouncedSetSearchString,
|
|
102
|
+
isFetching,
|
|
103
|
+
headerChildren: /* @__PURE__ */ jsx(
|
|
104
|
+
ControlFieldsButtons,
|
|
105
|
+
{
|
|
106
|
+
usableFields,
|
|
107
|
+
controlFields,
|
|
108
|
+
setControlFields
|
|
109
|
+
}
|
|
110
|
+
),
|
|
111
|
+
children: tags.map((tag) => {
|
|
112
|
+
const isPicked = pickedItems?.some((item) => item.id === tag.id);
|
|
113
|
+
return /* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
114
|
+
/* @__PURE__ */ jsx(
|
|
115
|
+
TagCard,
|
|
116
|
+
{
|
|
117
|
+
tag,
|
|
118
|
+
openNewTab,
|
|
119
|
+
className: cn(pickedItems && !isPicked && "opacity-50"),
|
|
120
|
+
anchorProps: handleClick && {
|
|
121
|
+
onClick: (e) => {
|
|
122
|
+
e.preventDefault();
|
|
123
|
+
handleClick(tag);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
),
|
|
128
|
+
pickedItems && /* @__PURE__ */ jsx(
|
|
129
|
+
Tick,
|
|
130
|
+
{
|
|
131
|
+
isPicked: isPicked ?? false,
|
|
132
|
+
className: "absolute top-2 right-2"
|
|
133
|
+
}
|
|
134
|
+
)
|
|
135
|
+
] }, tag.id);
|
|
136
|
+
})
|
|
137
|
+
}
|
|
138
|
+
);
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export { createTagList };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useTranslator } from 'intor/react';
|
|
4
|
+
import 'mime-types';
|
|
5
|
+
import { ensureArray } from '../../../../../shared/utils/ensure-array.js';
|
|
6
|
+
import 'lucide-react';
|
|
7
|
+
import 'react';
|
|
8
|
+
import 'ua-parser-js';
|
|
9
|
+
import 'clsx';
|
|
10
|
+
import 'tailwind-merge';
|
|
11
|
+
import 'next/navigation';
|
|
12
|
+
import '@radix-ui/react-avatar';
|
|
13
|
+
import '../../shadcn/badge.js';
|
|
14
|
+
import '../../shadcn/button.js';
|
|
15
|
+
import '@radix-ui/react-collapsible';
|
|
16
|
+
import '@radix-ui/react-dialog';
|
|
17
|
+
import '@radix-ui/react-dropdown-menu';
|
|
18
|
+
import '../../shadcn/input-group.js';
|
|
19
|
+
import '../../shadcn/item.js';
|
|
20
|
+
import '@radix-ui/react-label';
|
|
21
|
+
import '@radix-ui/react-select';
|
|
22
|
+
import '@radix-ui/react-separator';
|
|
23
|
+
import '../../shadcn/sidebar.js';
|
|
24
|
+
import 'next-themes';
|
|
25
|
+
import 'sonner';
|
|
26
|
+
import '@radix-ui/react-tabs';
|
|
27
|
+
import '@radix-ui/react-tooltip';
|
|
28
|
+
import 'next/link';
|
|
29
|
+
import '../../../../../constants/paths/auth.js';
|
|
30
|
+
import '../../../../../constants/paths/main.js';
|
|
31
|
+
import '../../../../../constants/paths/resources.js';
|
|
32
|
+
import '../../../../../constants/redirect-paths.js';
|
|
33
|
+
import { Accordion } from '../../ui/features/accordion/accordion.js';
|
|
34
|
+
import { AccordionContainer } from '../../ui/features/accordion/accordion-container.js';
|
|
35
|
+
import '../../../../../domain/resources/admin/constants.js';
|
|
36
|
+
import 'next/image';
|
|
37
|
+
|
|
38
|
+
function createTagRelationsSection({
|
|
39
|
+
PostList
|
|
40
|
+
}) {
|
|
41
|
+
return function TagRelationsSection({
|
|
42
|
+
tag,
|
|
43
|
+
usableFields = ["isActive", "isIndexActive", "isSlugActive"]
|
|
44
|
+
}) {
|
|
45
|
+
const { t } = useTranslator();
|
|
46
|
+
const posts = ensureArray(tag?.taggedPosts);
|
|
47
|
+
return /* @__PURE__ */ jsx(AccordionContainer, { children: /* @__PURE__ */ jsx(
|
|
48
|
+
Accordion,
|
|
49
|
+
{
|
|
50
|
+
hasBorder: true,
|
|
51
|
+
accordionHeaderProps: {
|
|
52
|
+
count: posts.length,
|
|
53
|
+
isRelated: true,
|
|
54
|
+
children: t("resources.post.text")
|
|
55
|
+
},
|
|
56
|
+
children: /* @__PURE__ */ jsx(
|
|
57
|
+
PostList,
|
|
58
|
+
{
|
|
59
|
+
postIds: posts.map((p) => p.id),
|
|
60
|
+
openNewTab: true,
|
|
61
|
+
type: null,
|
|
62
|
+
usableFields
|
|
63
|
+
}
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
) });
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export { createTagRelationsSection };
|