studiocms 0.3.0 → 0.4.0
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/CHANGELOG.md +83 -0
- package/dist/cli/add/index.d.ts +2 -2
- package/dist/cli/add/npm-utils.d.ts +6 -6
- package/dist/cli/add/tryToInstallPlugins.d.ts +1 -1
- package/dist/cli/add/updateStudioCMSConfig.d.ts +1 -1
- package/dist/cli/add/validatePlugins.d.ts +1 -1
- package/dist/cli/crypto/genJWT/index.d.ts +1 -1
- package/dist/cli/crypto/index.d.ts +1 -1
- package/dist/cli/init/steps/env.js +12 -2
- package/dist/cli/init/steps/next.d.ts +1 -1
- package/dist/cli/migrator/index.d.ts +1 -1
- package/dist/cli/users/index.d.ts +1 -1
- package/dist/cli/users/steps/createUsers.js +3 -3
- package/dist/cli/users/steps/next.d.ts +1 -1
- package/dist/cli/utils/context.d.ts +1 -1
- package/dist/cli/utils/getCliDbClient.d.ts +1 -1
- package/dist/cli/utils/intro.d.ts +1 -1
- package/dist/cli/utils/loadConfig.d.ts +54 -49
- package/dist/cli/utils/loadConfig.js +5 -8
- package/dist/cli/utils/user-utils.d.ts +1 -1
- package/dist/client/apiClient.d.ts +4923 -0
- package/dist/client/apiClient.js +72 -0
- package/dist/config.d.ts +1734 -1
- package/dist/consts.d.ts +5 -5
- package/dist/consts.js +3 -2
- package/dist/db/plugins.d.ts +1 -1
- package/dist/db/plugins.js +5 -8
- package/dist/handlers/frontend/routes.d.ts +4 -18
- package/dist/handlers/frontend/routes.js +13 -152
- package/dist/handlers/frontend/types.d.ts +1 -1
- package/dist/handlers/frontend/utils.js +0 -18
- package/dist/handlers/pluginHandler.d.ts +34 -257
- package/dist/handlers/pluginHandler.js +92 -46
- package/dist/handlers/routeHandler.js +32 -11
- package/dist/handlers/setupDbStudio.d.ts +1 -1
- package/dist/handlers/storage-manager/core/effectify-astro-context.d.ts +25 -0
- package/dist/handlers/storage-manager/core/effectify-astro-context.js +78 -0
- package/dist/handlers/storage-manager/no-op.d.ts +2 -2
- package/dist/handlers/storage-manager/no-op.js +2 -3
- package/dist/index.d.ts +0 -1
- package/dist/index.js +9 -5
- package/dist/integrations/robots/index.d.ts +2 -2
- package/dist/integrations/robots/index.js +1 -3
- package/dist/integrations/robots/schema.d.ts +102 -273
- package/dist/integrations/robots/schema.js +220 -209
- package/dist/plugins/analytics/assets/schemas.d.ts +14 -9
- package/dist/plugins/analytics/assets/schemas.js +25 -17
- package/dist/plugins/analytics/db-client.d.ts +1 -1
- package/dist/plugins/analytics/index.d.ts +823 -3
- package/dist/plugins/analytics/index.js +4 -5
- package/dist/plugins/analytics/schemas.d.ts +54 -62
- package/dist/plugins/analytics/schemas.js +64 -13
- package/dist/plugins/analytics/table.d.ts +1 -1
- package/dist/plugins.d.ts +0 -1
- package/dist/schemas/config/api.d.ts +17 -0
- package/dist/schemas/config/api.js +14 -0
- package/dist/schemas/config/auth.d.ts +55 -59
- package/dist/schemas/config/auth.js +34 -11
- package/dist/schemas/config/dashboard.d.ts +43 -79
- package/dist/schemas/config/dashboard.js +43 -12
- package/dist/schemas/config/db.d.ts +15 -17
- package/dist/schemas/config/db.js +13 -5
- package/dist/schemas/config/developer.d.ts +33 -45
- package/dist/schemas/config/developer.js +22 -5
- package/dist/schemas/config/index.d.ts +398 -521
- package/dist/schemas/config/index.js +115 -57
- package/dist/schemas/config/sdk.d.ts +50 -196
- package/dist/schemas/config/sdk.js +61 -73
- package/dist/schemas/custom.d.ts +40 -0
- package/dist/schemas/custom.js +41 -0
- package/dist/schemas/external-schemas.d.ts +171 -0
- package/dist/schemas/external-schemas.js +179 -0
- package/dist/schemas/index.d.ts +2 -0
- package/dist/schemas/index.js +2 -0
- package/dist/schemas/plugins/i18n.d.ts +59 -39
- package/dist/schemas/plugins/i18n.js +42 -5
- package/dist/schemas/plugins/index.d.ts +7126 -10296
- package/dist/schemas/plugins/index.js +260 -276
- package/dist/schemas/plugins/shared.d.ts +1293 -3718
- package/dist/schemas/plugins/shared.js +320 -329
- package/dist/test-utils.d.ts +15 -4
- package/dist/test-utils.js +27 -11
- package/dist/toolbar/db-viewer/db-shared-types.d.ts +6 -6
- package/dist/toolbar/db-viewer/viewer.js +20 -21
- package/dist/types.d.ts +30 -0
- package/dist/utils/effects/smtp.d.ts +1 -1
- package/dist/utils/lang-helper.d.ts +10 -2
- package/dist/virtual.d.ts +23 -0
- package/dist/virtuals/auth/core.d.ts +5 -5
- package/dist/virtuals/auth/verify-email.d.ts +6 -6
- package/dist/virtuals/components/Generator.astro +2 -2
- package/dist/virtuals/components/Renderer.astro +9 -1
- package/dist/virtuals/components/renderFn.d.ts +3 -1
- package/dist/virtuals/components/renderFn.js +18 -0
- package/dist/virtuals/lib/headDefaults.d.ts +4 -2
- package/dist/virtuals/lib/headDefaults.js +0 -2
- package/dist/virtuals/lib/routeMap.d.ts +0 -12
- package/dist/virtuals/lib/routeMap.js +2 -14
- package/dist/virtuals/mailer/index.d.ts +3 -3
- package/dist/virtuals/notifier/index.d.ts +5 -5
- package/dist/virtuals/plugins/dashboard-pages.d.ts +2 -64
- package/dist/virtuals/scripts/StorageFileBrowser.d.ts +1 -172
- package/dist/virtuals/scripts/StorageFileBrowser.js +216 -119
- package/dist/virtuals/template-engine/index.d.ts +4 -4
- package/frontend/components/dashboard/configuration/ConfigForm.astro +218 -110
- package/frontend/components/dashboard/content-mgmt/ContentSearch.astro +21 -22
- package/frontend/components/dashboard/content-mgmt/CreateFolder.astro +66 -54
- package/frontend/components/dashboard/content-mgmt/CreatePage.astro +58 -104
- package/frontend/components/dashboard/content-mgmt/EditFolder.astro +65 -67
- package/frontend/components/dashboard/content-mgmt/EditPage.astro +86 -134
- package/frontend/components/dashboard/content-mgmt/InnerSidebarElement.astro +0 -1
- package/frontend/components/dashboard/content-mgmt/PageHeader.astro +33 -52
- package/frontend/components/dashboard/content-mgmt/PageTypeHandler.astro +2 -2
- package/frontend/components/dashboard/profile/APITokens.astro +219 -158
- package/frontend/components/dashboard/profile/BasicInfo.astro +165 -106
- package/frontend/components/dashboard/profile/Notifications.astro +27 -18
- package/frontend/components/dashboard/profile/UpdatePassword.astro +134 -94
- package/frontend/components/dashboard/sidebar/VersionCheck.astro +31 -16
- package/frontend/components/dashboard/sidebar/VersionCheckChangelog.astro +18 -11
- package/frontend/components/dashboard/sidebar-modals/VersionModal.astro +2 -2
- package/frontend/components/dashboard/smtp-config/TemplateEditor.astro +14 -14
- package/frontend/components/dashboard/taxonomy/InnerSidebarElement.astro +0 -1
- package/frontend/components/dashboard/taxonomy/MetaContainer.astro +0 -2
- package/frontend/components/dashboard/taxonomy/PageHeader.astro +16 -24
- package/frontend/components/dashboard/taxonomy/TaxonomySearch.astro +23 -27
- package/frontend/components/dashboard/user-mgmt/InnerSidebarElement.astro +111 -104
- package/frontend/components/dashboard/user-mgmt/UserListItem.astro +9 -22
- package/frontend/components/dashboard/user-mgmt/UserListItems.astro +18 -0
- package/frontend/components/first-time-setup/snippets/{opt2-studiocms.config.diff → studiocms.config.diff} +1 -0
- package/frontend/components/shared/Code.astro +1 -4
- package/frontend/components/shared/DynamicSettingsRenderer.astro +1 -1
- package/frontend/components/shared/SSRUser.astro +2 -4
- package/frontend/components/shared/foldertree/FolderTreeNode.astro +0 -6
- package/frontend/components/shared/storage-manager/StorageCopyOutput.astro +0 -1
- package/frontend/components/shared/taxonomy/TaxonomyTreeNode.astro +0 -6
- package/frontend/layouts/DashboardLayout.astro +0 -9
- package/frontend/layouts/TaxonomyLayout.astro +0 -1
- package/frontend/middleware/index.ts +102 -61
- package/frontend/pages/404.astro +0 -1
- package/frontend/pages/[dashboard]/[...pluginPage].astro +10 -1
- package/frontend/pages/[dashboard]/configuration.astro +10 -1
- package/frontend/pages/[dashboard]/content-management/createfolder.astro +10 -1
- package/frontend/pages/[dashboard]/content-management/createpage.astro +10 -1
- package/frontend/pages/[dashboard]/content-management/diff.astro +39 -14
- package/frontend/pages/[dashboard]/content-management/editfolder.astro +10 -1
- package/frontend/pages/[dashboard]/content-management/editpage.astro +10 -1
- package/frontend/pages/[dashboard]/content-management/index.astro +10 -1
- package/frontend/pages/[dashboard]/index.astro +10 -1
- package/frontend/pages/[dashboard]/login.astro +86 -25
- package/frontend/pages/[dashboard]/password-reset.astro +22 -16
- package/frontend/pages/[dashboard]/plugins/[plugin].astro +10 -1
- package/frontend/pages/[dashboard]/profile.astro +10 -1
- package/frontend/pages/[dashboard]/signup.astro +153 -52
- package/frontend/pages/[dashboard]/smtp-configuration.astro +77 -75
- package/frontend/pages/[dashboard]/system-management.astro +10 -1
- package/frontend/pages/[dashboard]/taxonomy/categories.astro +30 -41
- package/frontend/pages/[dashboard]/taxonomy/index.astro +10 -0
- package/frontend/pages/[dashboard]/taxonomy/tags.astro +33 -43
- package/frontend/pages/[dashboard]/unverified-email.astro +29 -21
- package/frontend/pages/[dashboard]/user-management/edit.astro +170 -90
- package/frontend/pages/[dashboard]/user-management/index.astro +10 -1
- package/frontend/pages/studiocms_api/[...all].ts +106 -0
- package/frontend/pages/studiocms_api/_handlers/_utils/auth.ts +26 -0
- package/frontend/pages/studiocms_api/_handlers/_utils/changelog.ts +147 -0
- package/frontend/pages/studiocms_api/_handlers/_utils/db-studio-driver.ts +46 -0
- package/frontend/pages/studiocms_api/_handlers/_utils/parseLogLevel.ts +27 -0
- package/frontend/pages/studiocms_api/_handlers/auth/auth.ts +459 -0
- package/frontend/pages/studiocms_api/_handlers/auth/index.ts +17 -0
- package/frontend/pages/studiocms_api/_handlers/auth/oauth.ts +91 -0
- package/frontend/pages/studiocms_api/_handlers/dashboard/_shared.ts +57 -0
- package/frontend/pages/studiocms_api/_handlers/dashboard/apiTokens.ts +134 -0
- package/frontend/pages/studiocms_api/_handlers/dashboard/config.ts +64 -0
- package/frontend/pages/studiocms_api/_handlers/dashboard/content.ts +741 -0
- package/frontend/pages/studiocms_api/_handlers/dashboard/create.ts +480 -0
- package/frontend/pages/studiocms_api/_handlers/dashboard/emailNotifications.ts +49 -0
- package/frontend/pages/studiocms_api/_handlers/dashboard/index.ts +45 -0
- package/frontend/pages/studiocms_api/_handlers/dashboard/mailer.ts +136 -0
- package/frontend/pages/studiocms_api/_handlers/dashboard/plugins.ts +80 -0
- package/frontend/pages/studiocms_api/_handlers/dashboard/profile.ts +275 -0
- package/frontend/pages/studiocms_api/_handlers/dashboard/resetPassword.ts +140 -0
- package/frontend/pages/studiocms_api/_handlers/dashboard/search.ts +63 -0
- package/frontend/pages/studiocms_api/_handlers/dashboard/taxonomy.ts +285 -0
- package/frontend/pages/studiocms_api/_handlers/dashboard/templates.ts +75 -0
- package/frontend/pages/studiocms_api/_handlers/dashboard/users.ts +312 -0
- package/frontend/pages/studiocms_api/_handlers/dashboard/verifyEndpoints.ts +307 -0
- package/frontend/pages/studiocms_api/_handlers/integration/dbStudio.ts +98 -0
- package/frontend/pages/studiocms_api/_handlers/integration/index.ts +17 -0
- package/frontend/pages/studiocms_api/_handlers/integration/storageManager.ts +107 -0
- package/frontend/pages/studiocms_api/_handlers/rest-api/index.ts +8 -0
- package/frontend/pages/studiocms_api/_handlers/rest-api/v1/_shared.ts +41 -0
- package/frontend/pages/studiocms_api/_handlers/rest-api/v1/index.ts +17 -0
- package/frontend/pages/studiocms_api/_handlers/rest-api/v1/public.ts +195 -0
- package/frontend/pages/studiocms_api/_handlers/rest-api/v1/secure.ts +1726 -0
- package/frontend/pages/studiocms_api/_handlers/sdk.ts +129 -0
- package/frontend/pages/studiocms_api/_middleware/astroLocals.ts +36 -0
- package/frontend/pages/studiocms_api/_middleware/restApi.ts +56 -0
- package/frontend/pages/studiocms_api/integrations/[...all].ts +8 -0
- package/frontend/scripts/formdata.ts +219 -0
- package/frontend/setup-pages/3-done.astro +4 -20
- package/frontend/setup-pages/studiocms_api/dashboard/step-2.ts +3 -6
- package/frontend/styles/dashboard-base.css +0 -1
- package/frontend/web-vitals/endpoint.ts +2 -1
- package/package.json +34 -29
- package/dist/global.d.ts +0 -9
- package/frontend/components/dashboard/LoginChecker.astro +0 -68
- package/frontend/components/dashboard/user-mgmt/RankCheck.astro +0 -57
- package/frontend/components/first-time-setup/snippets/opt1-astro.config.diff +0 -14
- package/frontend/components/first-time-setup/snippets/opt2-astro.config.diff +0 -9
- package/frontend/middleware/_authmap.ts +0 -63
- package/frontend/pages/studiocms_api/auth/[path].ts +0 -384
- package/frontend/pages/studiocms_api/auth/[provider]/[...id].ts +0 -64
- package/frontend/pages/studiocms_api/auth/[provider]/_effects/index.ts +0 -101
- package/frontend/pages/studiocms_api/auth/_shared.ts +0 -52
- package/frontend/pages/studiocms_api/dashboard/api-tokens.ts +0 -115
- package/frontend/pages/studiocms_api/dashboard/config.ts +0 -74
- package/frontend/pages/studiocms_api/dashboard/content/diff.ts +0 -73
- package/frontend/pages/studiocms_api/dashboard/content/folder.ts +0 -220
- package/frontend/pages/studiocms_api/dashboard/content/page.ts +0 -359
- package/frontend/pages/studiocms_api/dashboard/create-reset-link.ts +0 -77
- package/frontend/pages/studiocms_api/dashboard/create-user-invite.ts +0 -231
- package/frontend/pages/studiocms_api/dashboard/create-user.ts +0 -186
- package/frontend/pages/studiocms_api/dashboard/email-notification-settings-site.ts +0 -74
- package/frontend/pages/studiocms_api/dashboard/mailer/check-email.ts +0 -75
- package/frontend/pages/studiocms_api/dashboard/mailer/config.ts +0 -136
- package/frontend/pages/studiocms_api/dashboard/plugins/[plugin].ts +0 -80
- package/frontend/pages/studiocms_api/dashboard/profile.ts +0 -245
- package/frontend/pages/studiocms_api/dashboard/resend-verify-email.ts +0 -77
- package/frontend/pages/studiocms_api/dashboard/reset-password.ts +0 -124
- package/frontend/pages/studiocms_api/dashboard/search-list.ts +0 -59
- package/frontend/pages/studiocms_api/dashboard/taxonomy-search.ts +0 -47
- package/frontend/pages/studiocms_api/dashboard/taxonomy.ts +0 -230
- package/frontend/pages/studiocms_api/dashboard/templates.ts +0 -74
- package/frontend/pages/studiocms_api/dashboard/update-user-notifications.ts +0 -86
- package/frontend/pages/studiocms_api/dashboard/users.ts +0 -236
- package/frontend/pages/studiocms_api/dashboard/verify-email.ts +0 -83
- package/frontend/pages/studiocms_api/dashboard/verify-session.ts +0 -187
- package/frontend/pages/studiocms_api/integrations/[type]/[...id].ts +0 -15
- package/frontend/pages/studiocms_api/integrations/[type]/_routes/db-studio.ts +0 -173
- package/frontend/pages/studiocms_api/integrations/[type]/_routes/storage.ts +0 -88
- package/frontend/pages/studiocms_api/partials/editor.astro +0 -74
- package/frontend/pages/studiocms_api/partials/render.astro +0 -39
- package/frontend/pages/studiocms_api/partials/user-list-items.astro +0 -43
- package/frontend/pages/studiocms_api/rest/utils/auth-token.ts +0 -59
- package/frontend/pages/studiocms_api/rest/v1/[type]/[...id].ts +0 -23
- package/frontend/pages/studiocms_api/rest/v1/[type]/_routes/categories.ts +0 -267
- package/frontend/pages/studiocms_api/rest/v1/[type]/_routes/folders.ts +0 -283
- package/frontend/pages/studiocms_api/rest/v1/[type]/_routes/pages.ts +0 -505
- package/frontend/pages/studiocms_api/rest/v1/[type]/_routes/settings.ts +0 -100
- package/frontend/pages/studiocms_api/rest/v1/[type]/_routes/tags.ts +0 -229
- package/frontend/pages/studiocms_api/rest/v1/[type]/_routes/users.ts +0 -553
- package/frontend/pages/studiocms_api/rest/v1/public/[type]/[...id].ts +0 -19
- package/frontend/pages/studiocms_api/rest/v1/public/[type]/_routes/categories.ts +0 -74
- package/frontend/pages/studiocms_api/rest/v1/public/[type]/_routes/folders.ts +0 -85
- package/frontend/pages/studiocms_api/rest/v1/public/[type]/_routes/pages.ts +0 -103
- package/frontend/pages/studiocms_api/rest/v1/public/[type]/_routes/tags.ts +0 -67
- package/frontend/pages/studiocms_api/sdk/[...path].ts +0 -97
- package/frontend/pages/studiocms_api/sdk/utils/changelog.ts +0 -119
- package/frontend/scripts/auth/formListener.ts +0 -81
- package/frontend/scripts/formdata-utils.ts +0 -116
- package/frontend/utils/build-partial-schema.ts +0 -46
- package/frontend/utils/errors.ts +0 -6
- package/frontend/utils/param-extractor.ts +0 -83
- package/frontend/utils/rest-router.ts +0 -444
|
@@ -27,223 +27,284 @@ const userTokens = await runSDK(SDKCoreJs.REST_API.tokens.get(user.id));
|
|
|
27
27
|
const lang = Astro.locals.StudioCMS.defaultLang;
|
|
28
28
|
const t = useTranslations(lang, '@studiocms/dashboard:profile');
|
|
29
29
|
---
|
|
30
|
+
|
|
30
31
|
<Card fullWidth class="api-tokens">
|
|
31
32
|
<div slot="header">
|
|
32
33
|
<h2>
|
|
33
|
-
<t-profile-tokens key="api-tokens-header"
|
|
34
|
+
<t-profile-tokens key="api-tokens-header"
|
|
35
|
+
>{t("api-tokens-header")}</t-profile-tokens
|
|
36
|
+
>
|
|
34
37
|
</h2>
|
|
35
|
-
|
|
38
|
+
|
|
36
39
|
<div class="form-header">
|
|
37
|
-
<Button
|
|
38
|
-
type=
|
|
40
|
+
<Button
|
|
41
|
+
type="submit"
|
|
39
42
|
id="create-api-token"
|
|
40
|
-
variant=
|
|
41
|
-
color=
|
|
42
|
-
size=
|
|
43
|
-
|
|
44
|
-
<Icon
|
|
43
|
+
variant="solid"
|
|
44
|
+
color="primary"
|
|
45
|
+
size="sm"
|
|
46
|
+
>
|
|
47
|
+
<Icon
|
|
48
|
+
slot="start-content"
|
|
49
|
+
name="heroicons:plus"
|
|
50
|
+
width={24}
|
|
51
|
+
height={24}
|
|
52
|
+
/>
|
|
45
53
|
<t-profile-tokens key="api-tokens-create">
|
|
46
|
-
{t(
|
|
54
|
+
{t("api-tokens-create")}
|
|
47
55
|
</t-profile-tokens>
|
|
48
|
-
</Button>
|
|
56
|
+
</Button>
|
|
49
57
|
</div>
|
|
50
58
|
</div>
|
|
51
59
|
<div class="api-tokens-content">
|
|
52
60
|
<span class="description">
|
|
53
|
-
<t-profile-tokens key="api-tokens-description"
|
|
61
|
+
<t-profile-tokens key="api-tokens-description"
|
|
62
|
+
>{t("api-tokens-description")}</t-profile-tokens
|
|
63
|
+
>
|
|
54
64
|
</span>
|
|
55
65
|
|
|
56
|
-
{
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
<
|
|
60
|
-
<
|
|
61
|
-
<
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
66
|
+
{
|
|
67
|
+
userTokens.length > 0 ? (
|
|
68
|
+
userTokens.map((token) => (
|
|
69
|
+
<Card fullWidth class="token-list-item">
|
|
70
|
+
<div slot="header" class="token-list-item-header">
|
|
71
|
+
<div class="token-list-item-header-row">
|
|
72
|
+
<h4>
|
|
73
|
+
<Icon
|
|
74
|
+
name="heroicons:key"
|
|
75
|
+
width={24}
|
|
76
|
+
height={24}
|
|
77
|
+
/>
|
|
78
|
+
{token.description}
|
|
79
|
+
</h4>
|
|
80
|
+
<Button
|
|
81
|
+
type="submit"
|
|
82
|
+
variant="solid"
|
|
83
|
+
color="danger"
|
|
84
|
+
size="sm"
|
|
85
|
+
data-token={token.id}
|
|
86
|
+
data-user={user.id}
|
|
87
|
+
disabled
|
|
88
|
+
>
|
|
89
|
+
<Icon
|
|
90
|
+
slot="start-content"
|
|
91
|
+
name="heroicons:trash"
|
|
92
|
+
width={24}
|
|
93
|
+
height={24}
|
|
94
|
+
/>
|
|
95
|
+
<t-profile-tokens key="api-tokens-delete-button">
|
|
96
|
+
{t("api-tokens-delete-button")}
|
|
97
|
+
</t-profile-tokens>
|
|
98
|
+
</Button>
|
|
99
|
+
</div>
|
|
100
|
+
</div>
|
|
101
|
+
|
|
102
|
+
<div class="token-list-item-content">
|
|
103
|
+
<div class="token-list-item-content-row">
|
|
104
|
+
<span class="created-at">
|
|
105
|
+
<t-profile-tokens key="api-tokens-created">
|
|
106
|
+
{t("api-tokens-created")}
|
|
107
|
+
</t-profile-tokens>{" "}
|
|
108
|
+
-{" "}
|
|
109
|
+
<FormattedDate date={token.creationDate} />
|
|
110
|
+
</span>
|
|
111
|
+
</div>
|
|
112
|
+
</div>
|
|
113
|
+
</Card>
|
|
114
|
+
))
|
|
115
|
+
) : (
|
|
116
|
+
<Card fullWidth class="token-list-item">
|
|
117
|
+
<Center>
|
|
118
|
+
<p class="description">
|
|
119
|
+
<t-profile-tokens key="api-tokens-no-tokens">
|
|
120
|
+
{t("api-tokens-no-tokens")}
|
|
121
|
+
</t-profile-tokens>
|
|
122
|
+
</p>
|
|
123
|
+
</Center>
|
|
124
|
+
</Card>
|
|
125
|
+
)
|
|
126
|
+
}
|
|
86
127
|
</div>
|
|
87
|
-
|
|
88
128
|
</Card>
|
|
89
129
|
<Modal
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
130
|
+
id="create-api-token-modal"
|
|
131
|
+
cancelButton={{ label: "Cancel", color: "default" }}
|
|
132
|
+
actionButton={{ label: "Confirm", color: "primary" }}
|
|
133
|
+
isForm
|
|
94
134
|
>
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
<input type="hidden" name="user" value={user.id} />
|
|
101
|
-
</div>
|
|
102
|
-
</Modal>
|
|
103
|
-
|
|
104
|
-
<Modal id='create-token-response-modal'>
|
|
105
|
-
<h2 slot="header">
|
|
106
|
-
<t-profile-tokens key="api-tokens-modal-response-header">{t('api-tokens-modal-response-header')}</t-profile-tokens>
|
|
107
|
-
</h2>
|
|
108
|
-
<Center>
|
|
135
|
+
<h2 slot="header">
|
|
136
|
+
<t-profile-tokens key="api-tokens-modal-header"
|
|
137
|
+
>{t("api-tokens-modal-header")}</t-profile-tokens
|
|
138
|
+
>
|
|
139
|
+
</h2>
|
|
109
140
|
<div class="modal-body">
|
|
110
|
-
<
|
|
111
|
-
|
|
112
|
-
</span>
|
|
113
|
-
<code id="create-token-response-placeholder"></code>
|
|
141
|
+
<Input label="Description" name="description" type="text" isRequired />
|
|
142
|
+
<input type="hidden" name="user" value={user.id} />
|
|
114
143
|
</div>
|
|
115
|
-
</Center>
|
|
116
144
|
</Modal>
|
|
117
145
|
|
|
118
|
-
<
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
146
|
+
<Modal id="create-token-response-modal">
|
|
147
|
+
<h2 slot="header">
|
|
148
|
+
<t-profile-tokens key="api-tokens-modal-response-header"
|
|
149
|
+
>{t("api-tokens-modal-response-header")}</t-profile-tokens
|
|
150
|
+
>
|
|
151
|
+
</h2>
|
|
152
|
+
<Center>
|
|
153
|
+
<div class="modal-body">
|
|
154
|
+
<span>
|
|
155
|
+
<t-profile-tokens key="api-tokens-modal-response-description"
|
|
156
|
+
>{
|
|
157
|
+
t("api-tokens-modal-response-description")
|
|
158
|
+
}</t-profile-tokens
|
|
159
|
+
>
|
|
160
|
+
</span>
|
|
161
|
+
<code id="create-token-response-placeholder"></code>
|
|
162
|
+
</div>
|
|
163
|
+
</Center>
|
|
164
|
+
</Modal>
|
|
122
165
|
|
|
123
166
|
<script>
|
|
124
|
-
import {
|
|
167
|
+
import {
|
|
125
168
|
$i18n,
|
|
126
169
|
baseTranslation,
|
|
127
170
|
makeTranslation,
|
|
128
171
|
updateElmLabel,
|
|
129
|
-
} from
|
|
172
|
+
} from "studiocms:i18n/client";
|
|
130
173
|
|
|
131
|
-
const currentPage =
|
|
174
|
+
const currentPage = "@studiocms/dashboard:profile";
|
|
132
175
|
|
|
133
176
|
const i18n = $i18n(currentPage, baseTranslation[currentPage]);
|
|
134
|
-
|
|
135
|
-
i18n.subscribe(comp => {
|
|
136
|
-
updateElmLabel(
|
|
177
|
+
|
|
178
|
+
i18n.subscribe((comp) => {
|
|
179
|
+
updateElmLabel("description", comp["api-tokens-modal-description"]);
|
|
137
180
|
});
|
|
138
181
|
|
|
139
|
-
if (!customElements.get(
|
|
140
|
-
customElements.define(
|
|
182
|
+
if (!customElements.get("t-profile-tokens")) {
|
|
183
|
+
customElements.define(
|
|
184
|
+
"t-profile-tokens",
|
|
185
|
+
makeTranslation(currentPage, i18n),
|
|
186
|
+
);
|
|
141
187
|
}
|
|
142
188
|
</script>
|
|
143
189
|
|
|
144
190
|
<script>
|
|
145
|
-
import { ModalHelper } from
|
|
146
|
-
import { toast } from
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
const
|
|
191
|
+
import { ModalHelper } from "studiocms:ui/components/modal/client";
|
|
192
|
+
import { toast } from "studiocms:ui/components/toaster/client";
|
|
193
|
+
import { dashboardClient, dashboardSharedCatchTags } from "studiocms:client/apiClients";
|
|
194
|
+
import * as Effect from "effect/Effect";
|
|
195
|
+
|
|
196
|
+
const createAPITokenModal = new ModalHelper(
|
|
197
|
+
"create-api-token-modal",
|
|
198
|
+
"create-api-token",
|
|
199
|
+
);
|
|
200
|
+
const createTokenResponseModal = new ModalHelper(
|
|
201
|
+
"create-token-response-modal",
|
|
202
|
+
);
|
|
203
|
+
const deleteButtons = document.querySelectorAll(
|
|
204
|
+
"[data-token]",
|
|
205
|
+
) as NodeListOf<HTMLButtonElement>;
|
|
155
206
|
|
|
156
207
|
createAPITokenModal.registerConfirmCallback(async (formData) => {
|
|
157
|
-
const description = formData?.get(
|
|
158
|
-
const user = formData?.get(
|
|
208
|
+
const description = formData?.get("description")?.toString();
|
|
209
|
+
const user = formData?.get("user")?.toString();
|
|
159
210
|
|
|
160
211
|
if (!description) {
|
|
161
212
|
toast({
|
|
162
|
-
title:
|
|
163
|
-
description:
|
|
164
|
-
type:
|
|
165
|
-
duration: 5000
|
|
166
|
-
})
|
|
213
|
+
title: "Error",
|
|
214
|
+
description: "Description is required",
|
|
215
|
+
type: "danger",
|
|
216
|
+
duration: 5000,
|
|
217
|
+
});
|
|
167
218
|
return;
|
|
168
219
|
}
|
|
169
220
|
|
|
170
221
|
if (!user) {
|
|
171
222
|
toast({
|
|
172
|
-
title:
|
|
173
|
-
description:
|
|
174
|
-
type:
|
|
175
|
-
duration: 5000
|
|
176
|
-
})
|
|
223
|
+
title: "Error",
|
|
224
|
+
description: "User ID not found",
|
|
225
|
+
type: "danger",
|
|
226
|
+
duration: 5000,
|
|
227
|
+
});
|
|
177
228
|
return;
|
|
178
229
|
}
|
|
179
230
|
|
|
180
|
-
const response = await
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
if (!response.ok) {
|
|
231
|
+
const response = await dashboardClient.pipe(
|
|
232
|
+
Effect.flatMap((client) =>
|
|
233
|
+
client.apiTokens.createApiToken({
|
|
234
|
+
payload: {
|
|
235
|
+
description,
|
|
236
|
+
},
|
|
237
|
+
}),
|
|
238
|
+
),
|
|
239
|
+
Effect.catchTags(dashboardSharedCatchTags),
|
|
240
|
+
Effect.runPromise,
|
|
241
|
+
);
|
|
242
|
+
|
|
243
|
+
if ("error" in response) {
|
|
194
244
|
toast({
|
|
195
|
-
title:
|
|
196
|
-
description:
|
|
197
|
-
type:
|
|
198
|
-
duration: 5000
|
|
199
|
-
})
|
|
245
|
+
title: "Error",
|
|
246
|
+
description: response.error,
|
|
247
|
+
type: "danger",
|
|
248
|
+
duration: 5000,
|
|
249
|
+
});
|
|
250
|
+
return;
|
|
251
|
+
} else {
|
|
252
|
+
createTokenResponseModal.show();
|
|
253
|
+
document.getElementById(
|
|
254
|
+
"create-token-response-placeholder",
|
|
255
|
+
)!.innerText = response.token;
|
|
200
256
|
return;
|
|
201
257
|
}
|
|
202
|
-
|
|
203
|
-
createTokenResponseModal.show();
|
|
204
|
-
document.getElementById('create-token-response-placeholder')!.innerText = res.token;
|
|
205
|
-
|
|
206
|
-
})
|
|
258
|
+
});
|
|
207
259
|
|
|
208
260
|
deleteButtons.forEach((button) => {
|
|
209
|
-
button.addEventListener(
|
|
261
|
+
button.addEventListener("click", async (event) => {
|
|
210
262
|
event.preventDefault();
|
|
211
|
-
const tokenID = button.getAttribute(
|
|
212
|
-
const userID = button.getAttribute(
|
|
213
|
-
|
|
214
|
-
const response = await fetch(tokenAPI, {
|
|
215
|
-
method: 'DELETE',
|
|
216
|
-
headers: {
|
|
217
|
-
'Content-Type': 'application/json'
|
|
218
|
-
},
|
|
219
|
-
body: JSON.stringify({
|
|
220
|
-
tokenID,
|
|
221
|
-
userID
|
|
222
|
-
})
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
const res = await response.json();
|
|
263
|
+
const tokenID = button.getAttribute("data-token");
|
|
264
|
+
const userID = button.getAttribute("data-user");
|
|
226
265
|
|
|
227
|
-
if (!
|
|
266
|
+
if (!tokenID || !userID) {
|
|
228
267
|
toast({
|
|
229
|
-
title:
|
|
230
|
-
description:
|
|
231
|
-
type:
|
|
232
|
-
duration: 5000
|
|
233
|
-
})
|
|
268
|
+
title: "Error",
|
|
269
|
+
description: "Token ID or User ID not found",
|
|
270
|
+
type: "danger",
|
|
271
|
+
duration: 5000,
|
|
272
|
+
});
|
|
234
273
|
return;
|
|
235
274
|
}
|
|
236
275
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
276
|
+
const response = await dashboardClient.pipe(
|
|
277
|
+
Effect.flatMap((client) =>
|
|
278
|
+
client.apiTokens.revokeApiToken({
|
|
279
|
+
payload: {
|
|
280
|
+
tokenID
|
|
281
|
+
}
|
|
282
|
+
})
|
|
283
|
+
),
|
|
284
|
+
Effect.catchTags(dashboardSharedCatchTags),
|
|
285
|
+
Effect.runPromise,
|
|
286
|
+
);
|
|
287
|
+
|
|
288
|
+
if ("error" in response) {
|
|
289
|
+
toast({
|
|
290
|
+
title: "Error",
|
|
291
|
+
description: response.error,
|
|
292
|
+
type: "danger",
|
|
293
|
+
duration: 5000,
|
|
294
|
+
});
|
|
295
|
+
return;
|
|
296
|
+
} else {
|
|
297
|
+
toast({
|
|
298
|
+
title: "Success",
|
|
299
|
+
description: response.message || "API token revoked successfully",
|
|
300
|
+
type: "success",
|
|
301
|
+
duration: 5000,
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
setTimeout(() => {
|
|
305
|
+
window.location.reload();
|
|
306
|
+
}, 2000);
|
|
307
|
+
}
|
|
247
308
|
});
|
|
248
309
|
});
|
|
249
310
|
</script>
|
|
@@ -263,7 +324,7 @@ const t = useTranslations(lang, '@studiocms/dashboard:profile');
|
|
|
263
324
|
.api-tokens-content {
|
|
264
325
|
display: flex;
|
|
265
326
|
flex-direction: column;
|
|
266
|
-
gap: .5rem;
|
|
327
|
+
gap: 0.5rem;
|
|
267
328
|
|
|
268
329
|
.description {
|
|
269
330
|
color: var(--text-muted);
|
|
@@ -308,4 +369,4 @@ const t = useTranslations(lang, '@studiocms/dashboard:profile');
|
|
|
308
369
|
}
|
|
309
370
|
}
|
|
310
371
|
}
|
|
311
|
-
</style>
|
|
372
|
+
</style>
|