@solidxai/core-ui 0.1.7-beta.4 → 0.1.7-beta.5
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/components/auth/AuthLayout.d.ts.map +1 -1
- package/dist/components/auth/AuthLayout.js +1 -1
- package/dist/components/auth/AuthLayout.js.map +1 -1
- package/dist/components/auth/AuthLayout.tsx +5 -3
- package/dist/components/auth/SolidLogin.js +3 -3
- package/dist/components/auth/SolidLogin.js.map +1 -1
- package/dist/components/auth/SolidLogin.tsx +2 -2
- package/dist/components/common/DropzonePlaceholder.d.ts.map +1 -1
- package/dist/components/common/DropzonePlaceholder.js +1 -1
- package/dist/components/common/DropzonePlaceholder.js.map +1 -1
- package/dist/components/common/DropzonePlaceholder.tsx +8 -6
- package/dist/components/core/chatter/SolidChatter.d.ts +2 -1
- package/dist/components/core/chatter/SolidChatter.d.ts.map +1 -1
- package/dist/components/core/chatter/SolidChatter.js +2 -4
- package/dist/components/core/chatter/SolidChatter.js.map +1 -1
- package/dist/components/core/chatter/SolidChatter.tsx +3 -4
- package/dist/components/core/chatter/SolidChatterHeader.d.ts +1 -0
- package/dist/components/core/chatter/SolidChatterHeader.d.ts.map +1 -1
- package/dist/components/core/chatter/SolidChatterHeader.js +2 -2
- package/dist/components/core/chatter/SolidChatterHeader.js.map +1 -1
- package/dist/components/core/chatter/SolidChatterHeader.tsx +4 -3
- package/dist/components/core/chatter/chatter.module.css +42 -32
- package/dist/components/core/common/SolidGenericImport/SolidGenericImport.js +1 -1
- package/dist/components/core/common/SolidGenericImport/SolidGenericImport.js.map +1 -1
- package/dist/components/core/common/SolidGenericImport/SolidGenericImport.tsx +2 -2
- package/dist/components/core/common/SolidGenericImport/SolidImport.module.css +153 -30
- package/dist/components/core/common/SolidGenericImport/SolidImportInstructions.d.ts.map +1 -1
- package/dist/components/core/common/SolidGenericImport/SolidImportInstructions.js +7 -7
- package/dist/components/core/common/SolidGenericImport/SolidImportInstructions.js.map +1 -1
- package/dist/components/core/common/SolidGenericImport/SolidImportInstructions.tsx +9 -10
- package/dist/components/core/extension/solid-core/media/card/MediaCardWidget.d.ts.map +1 -1
- package/dist/components/core/extension/solid-core/media/card/MediaCardWidget.js +1 -1
- package/dist/components/core/extension/solid-core/media/card/MediaCardWidget.js.map +1 -1
- package/dist/components/core/extension/solid-core/media/card/MediaCardWidget.tsx +6 -4
- package/dist/components/core/extension/solid-core/mqMessage/kanban/MqMessageKanbanCardWidget.d.ts.map +1 -1
- package/dist/components/core/extension/solid-core/mqMessage/kanban/MqMessageKanbanCardWidget.js +1 -1
- package/dist/components/core/extension/solid-core/mqMessage/kanban/MqMessageKanbanCardWidget.js.map +1 -1
- package/dist/components/core/extension/solid-core/mqMessage/kanban/MqMessageKanbanCardWidget.tsx +3 -1
- package/dist/components/core/form/SolidFormActionHeader.d.ts.map +1 -1
- package/dist/components/core/form/SolidFormActionHeader.js +13 -13
- package/dist/components/core/form/SolidFormActionHeader.js.map +1 -1
- package/dist/components/core/form/SolidFormActionHeader.tsx +21 -24
- package/dist/components/core/form/SolidFormFooter.d.ts.map +1 -1
- package/dist/components/core/form/SolidFormFooter.js +1 -1
- package/dist/components/core/form/SolidFormFooter.js.map +1 -1
- package/dist/components/core/form/SolidFormFooter.tsx +0 -1
- package/dist/components/core/form/SolidFormUserViewLayout.js +1 -1
- package/dist/components/core/form/SolidFormUserViewLayout.js.map +1 -1
- package/dist/components/core/form/SolidFormUserViewLayout.tsx +1 -1
- package/dist/components/core/form/SolidFormView.d.ts.map +1 -1
- package/dist/components/core/form/SolidFormView.js +22 -33
- package/dist/components/core/form/SolidFormView.js.map +1 -1
- package/dist/components/core/form/SolidFormView.tsx +38 -59
- package/dist/components/core/form/SolidFormViewNormalHeaderButton.d.ts.map +1 -1
- package/dist/components/core/form/SolidFormViewNormalHeaderButton.js +12 -1
- package/dist/components/core/form/SolidFormViewNormalHeaderButton.js.map +1 -1
- package/dist/components/core/form/SolidFormViewNormalHeaderButton.tsx +1 -0
- package/dist/components/core/form/fields/SolidLongTextField.js +4 -4
- package/dist/components/core/form/fields/SolidLongTextField.js.map +1 -1
- package/dist/components/core/form/fields/SolidLongTextField.tsx +4 -4
- package/dist/components/core/form/fields/SolidMediaMultipleField.d.ts.map +1 -1
- package/dist/components/core/form/fields/SolidMediaMultipleField.js +14 -14
- package/dist/components/core/form/fields/SolidMediaMultipleField.js.map +1 -1
- package/dist/components/core/form/fields/SolidMediaMultipleField.tsx +35 -21
- package/dist/components/core/form/fields/SolidMediaSingleField.d.ts.map +1 -1
- package/dist/components/core/form/fields/SolidMediaSingleField.js +2 -2
- package/dist/components/core/form/fields/SolidMediaSingleField.js.map +1 -1
- package/dist/components/core/form/fields/SolidMediaSingleField.tsx +48 -34
- package/dist/components/core/form/fields/SolidPasswordField.d.ts.map +1 -1
- package/dist/components/core/form/fields/SolidPasswordField.js +2 -2
- package/dist/components/core/form/fields/SolidPasswordField.js.map +1 -1
- package/dist/components/core/form/fields/SolidPasswordField.tsx +46 -42
- package/dist/components/core/form/fields/relations/SolidRelationManyToManyField.d.ts.map +1 -1
- package/dist/components/core/form/fields/relations/SolidRelationManyToManyField.js +23 -27
- package/dist/components/core/form/fields/relations/SolidRelationManyToManyField.js.map +1 -1
- package/dist/components/core/form/fields/relations/SolidRelationManyToManyField.tsx +64 -66
- package/dist/components/core/form/fields/relations/SolidRelationManyToOneField.d.ts.map +1 -1
- package/dist/components/core/form/fields/relations/SolidRelationManyToOneField.js +2 -6
- package/dist/components/core/form/fields/relations/SolidRelationManyToOneField.js.map +1 -1
- package/dist/components/core/form/fields/relations/SolidRelationManyToOneField.tsx +4 -7
- package/dist/components/core/form/fields/relations/SolidRelationOneToManyField.d.ts.map +1 -1
- package/dist/components/core/form/fields/relations/SolidRelationOneToManyField.js +12 -15
- package/dist/components/core/form/fields/relations/SolidRelationOneToManyField.js.map +1 -1
- package/dist/components/core/form/fields/relations/SolidRelationOneToManyField.tsx +30 -16
- package/dist/components/core/form/fields/solidFields.module.css +86 -15
- package/dist/components/core/form/fields/widgets/SolidChatterMessageCoModelEntityIdFormViewWidget.d.ts +3 -0
- package/dist/components/core/form/fields/widgets/SolidChatterMessageCoModelEntityIdFormViewWidget.d.ts.map +1 -0
- package/dist/components/core/form/fields/widgets/SolidChatterMessageCoModelEntityIdFormViewWidget.js +92 -0
- package/dist/components/core/form/fields/widgets/SolidChatterMessageCoModelEntityIdFormViewWidget.js.map +1 -0
- package/dist/components/core/form/fields/widgets/SolidChatterMessageCoModelEntityIdFormViewWidget.tsx +68 -0
- package/dist/components/core/form/fields/widgets/SolidIconEditWidget.d.ts.map +1 -1
- package/dist/components/core/form/fields/widgets/SolidIconEditWidget.js +18 -28
- package/dist/components/core/form/fields/widgets/SolidIconEditWidget.js.map +1 -1
- package/dist/components/core/form/fields/widgets/SolidIconEditWidget.tsx +52 -48
- package/dist/components/core/form/fields/widgets/SolidLovTypeChangeFormEditWidget.d.ts +3 -0
- package/dist/components/core/form/fields/widgets/SolidLovTypeChangeFormEditWidget.d.ts.map +1 -0
- package/dist/components/core/form/fields/widgets/SolidLovTypeChangeFormEditWidget.js +111 -0
- package/dist/components/core/form/fields/widgets/SolidLovTypeChangeFormEditWidget.js.map +1 -0
- package/dist/components/core/form/fields/widgets/SolidLovTypeChangeFormEditWidget.tsx +122 -0
- package/dist/components/core/form/fields/widgets/SolidS3FileViewerWidget.d.ts.map +1 -1
- package/dist/components/core/form/fields/widgets/SolidS3FileViewerWidget.js +1 -1
- package/dist/components/core/form/fields/widgets/SolidS3FileViewerWidget.js.map +1 -1
- package/dist/components/core/form/fields/widgets/SolidS3FileViewerWidget.tsx +5 -4
- package/dist/components/core/kanban/KanbanBoard.d.ts.map +1 -1
- package/dist/components/core/kanban/KanbanBoard.js +11 -5
- package/dist/components/core/kanban/KanbanBoard.js.map +1 -1
- package/dist/components/core/kanban/KanbanBoard.tsx +8 -0
- package/dist/components/core/kanban/KanbanCard.d.ts +1 -0
- package/dist/components/core/kanban/KanbanCard.d.ts.map +1 -1
- package/dist/components/core/kanban/KanbanCard.js +4 -4
- package/dist/components/core/kanban/KanbanCard.js.map +1 -1
- package/dist/components/core/kanban/KanbanCard.tsx +5 -4
- package/dist/components/core/kanban/KanbanColumn.d.ts +2 -1
- package/dist/components/core/kanban/KanbanColumn.d.ts.map +1 -1
- package/dist/components/core/kanban/KanbanColumn.js +3 -3
- package/dist/components/core/kanban/KanbanColumn.js.map +1 -1
- package/dist/components/core/kanban/KanbanColumn.tsx +4 -3
- package/dist/components/core/list/SolidDataTable.d.ts +1 -0
- package/dist/components/core/list/SolidDataTable.d.ts.map +1 -1
- package/dist/components/core/list/SolidDataTable.js +19 -2
- package/dist/components/core/list/SolidDataTable.js.map +1 -1
- package/dist/components/core/list/SolidDataTable.tsx +30 -2
- package/dist/components/core/list/SolidListView.d.ts.map +1 -1
- package/dist/components/core/list/SolidListView.js +1 -1
- package/dist/components/core/list/SolidListView.js.map +1 -1
- package/dist/components/core/list/SolidListView.tsx +1 -0
- package/dist/components/core/list/SolidListViewConfigure.js.map +1 -1
- package/dist/components/core/list/SolidListViewConfigure.tsx +1 -1
- package/dist/components/core/list/widgets/SolidChatterMessageCoModelEntityIdListViewWidget.d.ts +3 -0
- package/dist/components/core/list/widgets/SolidChatterMessageCoModelEntityIdListViewWidget.d.ts.map +1 -0
- package/dist/components/core/list/widgets/SolidChatterMessageCoModelEntityIdListViewWidget.js +87 -0
- package/dist/components/core/list/widgets/SolidChatterMessageCoModelEntityIdListViewWidget.js.map +1 -0
- package/dist/components/core/list/widgets/SolidChatterMessageCoModelEntityIdListViewWidget.tsx +70 -0
- package/dist/components/core/list/widgets/SolidMqMessageStageListViewWidget.d.ts +3 -0
- package/dist/components/core/list/widgets/SolidMqMessageStageListViewWidget.d.ts.map +1 -0
- package/dist/components/core/list/widgets/SolidMqMessageStageListViewWidget.js +33 -0
- package/dist/components/core/list/widgets/SolidMqMessageStageListViewWidget.js.map +1 -0
- package/dist/components/core/list/widgets/SolidMqMessageStageListViewWidget.tsx +50 -0
- package/dist/components/core/list/widgets/SolidSummarizeListHeaderActionMqMessages.d.ts +3 -0
- package/dist/components/core/list/widgets/SolidSummarizeListHeaderActionMqMessages.d.ts.map +1 -0
- package/dist/components/core/list/widgets/SolidSummarizeListHeaderActionMqMessages.js +158 -0
- package/dist/components/core/list/widgets/SolidSummarizeListHeaderActionMqMessages.js.map +1 -0
- package/dist/components/core/list/widgets/SolidSummarizeListHeaderActionMqMessages.tsx +185 -0
- package/dist/components/core/locales/SolidChatterLocaleTabView.d.ts.map +1 -1
- package/dist/components/core/locales/SolidChatterLocaleTabView.js +7 -4
- package/dist/components/core/locales/SolidChatterLocaleTabView.js.map +1 -1
- package/dist/components/core/locales/SolidChatterLocaleTabView.tsx +28 -11
- package/dist/components/core/locales/SolidLocale.js +4 -4
- package/dist/components/core/locales/SolidLocale.js.map +1 -1
- package/dist/components/core/locales/SolidLocale.tsx +18 -18
- package/dist/components/core/locales/solid-locale.css +105 -7
- package/dist/components/core/model/CreateModel.js +2 -2
- package/dist/components/core/model/CreateModel.js.map +1 -1
- package/dist/components/core/model/CreateModel.tsx +2 -2
- package/dist/components/core/model/FieldMetaData.d.ts.map +1 -1
- package/dist/components/core/model/FieldMetaData.js +3 -3
- package/dist/components/core/model/FieldMetaData.js.map +1 -1
- package/dist/components/core/model/FieldMetaData.tsx +45 -22
- package/dist/components/core/users/ApiKeysTab/ApiKeysTab.d.ts +7 -0
- package/dist/components/core/users/ApiKeysTab/ApiKeysTab.d.ts.map +1 -0
- package/dist/components/core/users/ApiKeysTab/ApiKeysTab.js +138 -0
- package/dist/components/core/users/ApiKeysTab/ApiKeysTab.js.map +1 -0
- package/dist/components/core/users/ApiKeysTab/ApiKeysTab.tsx +246 -0
- package/dist/components/core/users/ApiKeysTab/GenerateApiKeyModal.d.ts +8 -0
- package/dist/components/core/users/ApiKeysTab/GenerateApiKeyModal.d.ts.map +1 -0
- package/dist/components/core/users/ApiKeysTab/GenerateApiKeyModal.js +156 -0
- package/dist/components/core/users/ApiKeysTab/GenerateApiKeyModal.js.map +1 -0
- package/dist/components/core/users/ApiKeysTab/GenerateApiKeyModal.tsx +184 -0
- package/dist/components/core/users/ApiKeysTab/RevealApiKeyModal.d.ts +9 -0
- package/dist/components/core/users/ApiKeysTab/RevealApiKeyModal.d.ts.map +1 -0
- package/dist/components/core/users/ApiKeysTab/RevealApiKeyModal.js +37 -0
- package/dist/components/core/users/ApiKeysTab/RevealApiKeyModal.js.map +1 -0
- package/dist/components/core/users/ApiKeysTab/RevealApiKeyModal.tsx +111 -0
- package/dist/components/core/users/ApiKeysTab/index.d.ts +4 -0
- package/dist/components/core/users/ApiKeysTab/index.d.ts.map +1 -0
- package/dist/components/core/users/ApiKeysTab/index.js +4 -0
- package/dist/components/core/users/ApiKeysTab/index.js.map +1 -0
- package/dist/components/core/users/ApiKeysTab/index.ts +3 -0
- package/dist/components/layout/AppSidebar.d.ts.map +1 -1
- package/dist/components/layout/AppSidebar.js +75 -7
- package/dist/components/layout/AppSidebar.js.map +1 -1
- package/dist/components/layout/AppSidebar.tsx +84 -7
- package/dist/components/shad-cn-ui/SolidCodeEditor.d.ts.map +1 -1
- package/dist/components/shad-cn-ui/SolidCodeEditor.js +13 -7
- package/dist/components/shad-cn-ui/SolidCodeEditor.js.map +1 -1
- package/dist/components/shad-cn-ui/SolidCodeEditor.tsx +22 -12
- package/dist/components/shad-cn-ui/SolidDialog.d.ts +2 -1
- package/dist/components/shad-cn-ui/SolidDialog.d.ts.map +1 -1
- package/dist/components/shad-cn-ui/SolidDialog.js +2 -2
- package/dist/components/shad-cn-ui/SolidDialog.js.map +1 -1
- package/dist/components/shad-cn-ui/SolidDialog.tsx +6 -3
- package/dist/components/shad-cn-ui/SolidSelect.d.ts +2 -1
- package/dist/components/shad-cn-ui/SolidSelect.d.ts.map +1 -1
- package/dist/components/shad-cn-ui/SolidSelect.js +2 -2
- package/dist/components/shad-cn-ui/SolidSelect.js.map +1 -1
- package/dist/components/shad-cn-ui/SolidSelect.tsx +3 -0
- package/dist/components/shad-cn-ui/SolidTextarea.d.ts +1 -1
- package/dist/components/shad-cn-ui/SolidTextarea.d.ts.map +1 -1
- package/dist/components/shad-cn-ui/SolidTextarea.js +3 -2
- package/dist/components/shad-cn-ui/SolidTextarea.js.map +1 -1
- package/dist/components/shad-cn-ui/SolidTextarea.tsx +17 -2
- package/dist/helpers/# no such endpoints exist, need to calle +3 -0
- package/dist/helpers/registry.d.ts.map +1 -1
- package/dist/helpers/registry.js +10 -0
- package/dist/helpers/registry.js.map +1 -1
- package/dist/helpers/registry.ts +16 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/index.ts +71 -2
- package/dist/redux/api/apiKeyApi.d.ts +40 -0
- package/dist/redux/api/apiKeyApi.d.ts.map +1 -0
- package/dist/redux/api/apiKeyApi.js +36 -0
- package/dist/redux/api/apiKeyApi.js.map +1 -0
- package/dist/redux/api/apiKeyApi.ts +60 -0
- package/dist/resources/globals.css +628 -67
- package/dist/resources/shadcn-base.css +333 -7
- package/dist/resources/solid-responsive.css +6 -6
- package/dist/resources/themes/solid-dark-purple/theme.css +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
49
|
+
import { useEffect, useState } from "react";
|
|
50
|
+
import { useDispatch } from "react-redux";
|
|
51
|
+
import { useFormik } from "formik";
|
|
52
|
+
import * as Yup from "yup";
|
|
53
|
+
import { SolidButton, SolidDatePicker, SolidDialog, SolidDialogBody, SolidDialogFooter, SolidDialogHeader, SolidDialogSeparator, SolidDialogTitle, SolidInput, SolidMessage, SolidSelect, } from "../../../shad-cn-ui";
|
|
54
|
+
import { showToast } from "../../../../redux/features/toastSlice";
|
|
55
|
+
import { useCreateApiKeyMutation } from "../../../../redux/api/apiKeyApi";
|
|
56
|
+
var EXPIRY_OPTIONS = [
|
|
57
|
+
{ label: "30 days", value: "30d" },
|
|
58
|
+
{ label: "60 days", value: "60d" },
|
|
59
|
+
{ label: "90 days", value: "90d" },
|
|
60
|
+
{ label: "Never", value: "never" },
|
|
61
|
+
{ label: "Custom date", value: "custom" },
|
|
62
|
+
];
|
|
63
|
+
function addDays(days) {
|
|
64
|
+
var d = new Date();
|
|
65
|
+
d.setDate(d.getDate() + days);
|
|
66
|
+
return d.toISOString();
|
|
67
|
+
}
|
|
68
|
+
function resolveExpiresAt(expiryOption, customDate) {
|
|
69
|
+
switch (expiryOption) {
|
|
70
|
+
case "30d":
|
|
71
|
+
return addDays(30);
|
|
72
|
+
case "60d":
|
|
73
|
+
return addDays(60);
|
|
74
|
+
case "90d":
|
|
75
|
+
return addDays(90);
|
|
76
|
+
case "never":
|
|
77
|
+
return undefined;
|
|
78
|
+
case "custom":
|
|
79
|
+
return customDate ? customDate.toISOString() : undefined;
|
|
80
|
+
default:
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
export function GenerateApiKeyModal(_a) {
|
|
85
|
+
var _this = this;
|
|
86
|
+
var open = _a.open, onClose = _a.onClose, onCreated = _a.onCreated;
|
|
87
|
+
var dispatch = useDispatch();
|
|
88
|
+
var _b = useCreateApiKeyMutation(), createApiKey = _b[0], isLoading = _b[1].isLoading;
|
|
89
|
+
var _c = useState(null), customDate = _c[0], setCustomDate = _c[1];
|
|
90
|
+
var formik = useFormik({
|
|
91
|
+
initialValues: {
|
|
92
|
+
name: "",
|
|
93
|
+
expiryOption: "30d",
|
|
94
|
+
},
|
|
95
|
+
validationSchema: Yup.object({
|
|
96
|
+
name: Yup.string()
|
|
97
|
+
.trim()
|
|
98
|
+
.min(2, "Name must be at least 2 characters")
|
|
99
|
+
.max(64, "Name must be 64 characters or fewer")
|
|
100
|
+
.required("Key name is required"),
|
|
101
|
+
expiryOption: Yup.string().required("Expiry is required"),
|
|
102
|
+
}),
|
|
103
|
+
onSubmit: function (values, helpers) { return __awaiter(_this, void 0, void 0, function () {
|
|
104
|
+
var expiresAt, response, err_1, detail;
|
|
105
|
+
var _a;
|
|
106
|
+
return __generator(this, function (_b) {
|
|
107
|
+
switch (_b.label) {
|
|
108
|
+
case 0:
|
|
109
|
+
if (values.expiryOption === "custom" && !customDate) {
|
|
110
|
+
helpers.setFieldError("expiryOption", "Please select a custom expiry date");
|
|
111
|
+
return [2 /*return*/];
|
|
112
|
+
}
|
|
113
|
+
expiresAt = resolveExpiresAt(values.expiryOption, customDate);
|
|
114
|
+
_b.label = 1;
|
|
115
|
+
case 1:
|
|
116
|
+
_b.trys.push([1, 3, , 4]);
|
|
117
|
+
return [4 /*yield*/, createApiKey(__assign({ name: values.name.trim() }, (expiresAt ? { expiresAt: expiresAt } : {}))).unwrap()];
|
|
118
|
+
case 2:
|
|
119
|
+
response = _b.sent();
|
|
120
|
+
onCreated(response.data.apiKey, values.name.trim());
|
|
121
|
+
handleClose();
|
|
122
|
+
return [3 /*break*/, 4];
|
|
123
|
+
case 3:
|
|
124
|
+
err_1 = _b.sent();
|
|
125
|
+
detail = ((_a = err_1 === null || err_1 === void 0 ? void 0 : err_1.data) === null || _a === void 0 ? void 0 : _a.message) || "Failed to generate API key. Please try again.";
|
|
126
|
+
dispatch(showToast({ severity: "error", summary: "Error", detail: detail }));
|
|
127
|
+
return [3 /*break*/, 4];
|
|
128
|
+
case 4: return [2 /*return*/];
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
}); },
|
|
132
|
+
});
|
|
133
|
+
var handleClose = function () {
|
|
134
|
+
formik.resetForm();
|
|
135
|
+
setCustomDate(null);
|
|
136
|
+
onClose();
|
|
137
|
+
};
|
|
138
|
+
// Reset form when modal opens
|
|
139
|
+
useEffect(function () {
|
|
140
|
+
if (open) {
|
|
141
|
+
formik.resetForm();
|
|
142
|
+
setCustomDate(null);
|
|
143
|
+
}
|
|
144
|
+
}, [open]);
|
|
145
|
+
var nameError = formik.touched.name && formik.errors.name ? String(formik.errors.name) : "";
|
|
146
|
+
var expiryError = formik.touched.expiryOption && formik.errors.expiryOption
|
|
147
|
+
? String(formik.errors.expiryOption)
|
|
148
|
+
: "";
|
|
149
|
+
return (_jsxs(SolidDialog, { open: open, onOpenChange: handleClose, style: { maxWidth: 480 }, children: [_jsx(SolidDialogHeader, { children: _jsx(SolidDialogTitle, { children: "Generate API Key" }) }), _jsx(SolidDialogSeparator, {}), _jsx(SolidDialogBody, { children: _jsx("form", { id: "generate-api-key-form", onSubmit: formik.handleSubmit, children: _jsxs("div", { className: "flex flex-column gap-3", children: [_jsxs("div", { className: "flex flex-column gap-2", children: [_jsxs("label", { htmlFor: "api-key-name", className: "form-field-label", children: ["Key Name ", _jsx("span", { style: { color: "var(--solid-danger-color, #ef4444)" }, children: "*" })] }), _jsx(SolidInput, { id: "api-key-name", name: "name", autoComplete: "off", placeholder: "e.g. CI/CD pipeline, Mobile app", value: formik.values.name, onChange: formik.handleChange, onBlur: formik.handleBlur }), nameError && _jsx(SolidMessage, { severity: "error", text: nameError })] }), _jsxs("div", { className: "flex flex-column gap-2", children: [_jsx("label", { htmlFor: "api-key-expiry", className: "form-field-label", children: "Expires" }), _jsx(SolidSelect, { value: formik.values.expiryOption, options: EXPIRY_OPTIONS, optionLabel: "label", optionValue: "value", onChange: function (_a) {
|
|
150
|
+
var value = _a.value;
|
|
151
|
+
formik.setFieldValue("expiryOption", value);
|
|
152
|
+
if (value !== "custom")
|
|
153
|
+
setCustomDate(null);
|
|
154
|
+
} }), formik.values.expiryOption === "custom" && (_jsx(SolidDatePicker, { selected: customDate, onChange: function (date) { return setCustomDate(date); }, minDate: new Date(), placeholderText: "Select expiry date", dateFormat: "dd/MM/yyyy" })), expiryError && _jsx(SolidMessage, { severity: "error", text: expiryError })] })] }) }) }), _jsx(SolidDialogSeparator, {}), _jsxs(SolidDialogFooter, { children: [_jsx(SolidButton, { variant: "outline", type: "button", onClick: handleClose, disabled: isLoading, children: "Cancel" }), _jsx(SolidButton, { type: "submit", form: "generate-api-key-form", loading: isLoading, children: "Generate Key" })] })] }));
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=GenerateApiKeyModal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GenerateApiKeyModal.js","sourceRoot":"","sources":["../../../../../src/components/core/users/ApiKeysTab/GenerateApiKeyModal.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC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AAQ,IAAI,CAC1C,KAAC,eAAe,IACd,QAAQ,EAAE,UAAU,EACpB,QAAQ,EAAE,UAAC,IAAiB,IAAK,OAAA,aAAa,CAAC,IAAI,CAAC,EAAnB,CAAmB,EACpD,OAAO,EAAE,IAAI,IAAI,EAAE,EACnB,eAAe,EAAC,oBAAoB,EACpC,UAAU,EAAC,YAAY,GACvB,CACH,EACA,WAAW,IAAI,KAAC,YAAY,IAAC,QAAQ,EAAC,OAAO,EAAC,IAAI,EAAE,WAAW,GAAI,IAChE,IACF,GACD,GACS,EAClB,KAAC,oBAAoB,KAAG,EACxB,MAAC,iBAAiB,eAChB,KAAC,WAAW,IAAC,OAAO,EAAC,SAAS,EAAC,IAAI,EAAC,QAAQ,EAAC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,uBAExE,EACd,KAAC,WAAW,IAAC,IAAI,EAAC,QAAQ,EAAC,IAAI,EAAC,uBAAuB,EAAC,OAAO,EAAE,SAAS,6BAE5D,IACI,IACR,CACf,CAAC;AACJ,CAAC","sourcesContent":["import { useEffect, useState } from \"react\";\nimport { useDispatch } from \"react-redux\";\nimport { useFormik } from \"formik\";\nimport * as Yup from \"yup\";\nimport {\n SolidButton,\n SolidDatePicker,\n SolidDialog,\n SolidDialogBody,\n SolidDialogFooter,\n SolidDialogHeader,\n SolidDialogSeparator,\n SolidDialogTitle,\n SolidInput,\n SolidMessage,\n SolidSelect,\n} from \"../../../shad-cn-ui\";\nimport { showToast } from \"../../../../redux/features/toastSlice\";\nimport { useCreateApiKeyMutation } from \"../../../../redux/api/apiKeyApi\";\n\nconst EXPIRY_OPTIONS = [\n { label: \"30 days\", value: \"30d\" },\n { label: \"60 days\", value: \"60d\" },\n { label: \"90 days\", value: \"90d\" },\n { label: \"Never\", value: \"never\" },\n { label: \"Custom date\", value: \"custom\" },\n];\n\nfunction addDays(days: number): string {\n const d = new Date();\n d.setDate(d.getDate() + days);\n return d.toISOString();\n}\n\nfunction resolveExpiresAt(expiryOption: string, customDate: Date | null): string | undefined {\n switch (expiryOption) {\n case \"30d\":\n return addDays(30);\n case \"60d\":\n return addDays(60);\n case \"90d\":\n return addDays(90);\n case \"never\":\n return undefined;\n case \"custom\":\n return customDate ? customDate.toISOString() : undefined;\n default:\n return undefined;\n }\n}\n\ninterface GenerateApiKeyModalProps {\n open: boolean;\n onClose: () => void;\n onCreated: (rawApiKey: string, keyName: string) => void;\n}\n\nexport function GenerateApiKeyModal({ open, onClose, onCreated }: GenerateApiKeyModalProps) {\n const dispatch = useDispatch();\n const [createApiKey, { isLoading }] = useCreateApiKeyMutation();\n const [customDate, setCustomDate] = useState<Date | null>(null);\n\n const formik = useFormik({\n initialValues: {\n name: \"\",\n expiryOption: \"30d\",\n },\n validationSchema: Yup.object({\n name: Yup.string()\n .trim()\n .min(2, \"Name must be at least 2 characters\")\n .max(64, \"Name must be 64 characters or fewer\")\n .required(\"Key name is required\"),\n expiryOption: Yup.string().required(\"Expiry is required\"),\n }),\n onSubmit: async (values, helpers) => {\n if (values.expiryOption === \"custom\" && !customDate) {\n helpers.setFieldError(\"expiryOption\", \"Please select a custom expiry date\");\n return;\n }\n\n const expiresAt = resolveExpiresAt(values.expiryOption, customDate);\n\n try {\n const response = await createApiKey({\n name: values.name.trim(),\n ...(expiresAt ? { expiresAt } : {}),\n }).unwrap();\n\n onCreated(response.data.apiKey, values.name.trim());\n handleClose();\n } catch (err: any) {\n const detail = err?.data?.message || \"Failed to generate API key. Please try again.\";\n dispatch(showToast({ severity: \"error\", summary: \"Error\", detail }));\n }\n },\n });\n\n const handleClose = () => {\n formik.resetForm();\n setCustomDate(null);\n onClose();\n };\n\n // Reset form when modal opens\n useEffect(() => {\n if (open) {\n formik.resetForm();\n setCustomDate(null);\n }\n }, [open]);\n\n const nameError =\n formik.touched.name && formik.errors.name ? String(formik.errors.name) : \"\";\n const expiryError =\n formik.touched.expiryOption && formik.errors.expiryOption\n ? String(formik.errors.expiryOption)\n : \"\";\n\n return (\n <SolidDialog open={open} onOpenChange={handleClose} style={{ maxWidth: 480 }}>\n <SolidDialogHeader>\n <SolidDialogTitle>Generate API Key</SolidDialogTitle>\n </SolidDialogHeader>\n <SolidDialogSeparator />\n <SolidDialogBody>\n <form id=\"generate-api-key-form\" onSubmit={formik.handleSubmit}>\n <div className=\"flex flex-column gap-3\">\n <div className=\"flex flex-column gap-2\">\n <label htmlFor=\"api-key-name\" className=\"form-field-label\">\n Key Name <span style={{ color: \"var(--solid-danger-color, #ef4444)\" }}>*</span>\n </label>\n <SolidInput\n id=\"api-key-name\"\n name=\"name\"\n autoComplete=\"off\"\n placeholder=\"e.g. CI/CD pipeline, Mobile app\"\n value={formik.values.name}\n onChange={formik.handleChange}\n onBlur={formik.handleBlur}\n />\n {nameError && <SolidMessage severity=\"error\" text={nameError} />}\n </div>\n\n <div className=\"flex flex-column gap-2\">\n <label htmlFor=\"api-key-expiry\" className=\"form-field-label\">\n Expires\n </label>\n <SolidSelect\n value={formik.values.expiryOption}\n options={EXPIRY_OPTIONS}\n optionLabel=\"label\"\n optionValue=\"value\"\n onChange={({ value }) => {\n formik.setFieldValue(\"expiryOption\", value);\n if (value !== \"custom\") setCustomDate(null);\n }}\n />\n {formik.values.expiryOption === \"custom\" && (\n <SolidDatePicker\n selected={customDate}\n onChange={(date: Date | null) => setCustomDate(date)}\n minDate={new Date()}\n placeholderText=\"Select expiry date\"\n dateFormat=\"dd/MM/yyyy\"\n />\n )}\n {expiryError && <SolidMessage severity=\"error\" text={expiryError} />}\n </div>\n </div>\n </form>\n </SolidDialogBody>\n <SolidDialogSeparator />\n <SolidDialogFooter>\n <SolidButton variant=\"outline\" type=\"button\" onClick={handleClose} disabled={isLoading}>\n Cancel\n </SolidButton>\n <SolidButton type=\"submit\" form=\"generate-api-key-form\" loading={isLoading}>\n Generate Key\n </SolidButton>\n </SolidDialogFooter>\n </SolidDialog>\n );\n}\n"]}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { useDispatch } from "react-redux";
|
|
3
|
+
import { useFormik } from "formik";
|
|
4
|
+
import * as Yup from "yup";
|
|
5
|
+
import {
|
|
6
|
+
SolidButton,
|
|
7
|
+
SolidDatePicker,
|
|
8
|
+
SolidDialog,
|
|
9
|
+
SolidDialogBody,
|
|
10
|
+
SolidDialogFooter,
|
|
11
|
+
SolidDialogHeader,
|
|
12
|
+
SolidDialogSeparator,
|
|
13
|
+
SolidDialogTitle,
|
|
14
|
+
SolidInput,
|
|
15
|
+
SolidMessage,
|
|
16
|
+
SolidSelect,
|
|
17
|
+
} from "../../../shad-cn-ui";
|
|
18
|
+
import { showToast } from "../../../../redux/features/toastSlice";
|
|
19
|
+
import { useCreateApiKeyMutation } from "../../../../redux/api/apiKeyApi";
|
|
20
|
+
|
|
21
|
+
const EXPIRY_OPTIONS = [
|
|
22
|
+
{ label: "30 days", value: "30d" },
|
|
23
|
+
{ label: "60 days", value: "60d" },
|
|
24
|
+
{ label: "90 days", value: "90d" },
|
|
25
|
+
{ label: "Never", value: "never" },
|
|
26
|
+
{ label: "Custom date", value: "custom" },
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
function addDays(days: number): string {
|
|
30
|
+
const d = new Date();
|
|
31
|
+
d.setDate(d.getDate() + days);
|
|
32
|
+
return d.toISOString();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function resolveExpiresAt(expiryOption: string, customDate: Date | null): string | undefined {
|
|
36
|
+
switch (expiryOption) {
|
|
37
|
+
case "30d":
|
|
38
|
+
return addDays(30);
|
|
39
|
+
case "60d":
|
|
40
|
+
return addDays(60);
|
|
41
|
+
case "90d":
|
|
42
|
+
return addDays(90);
|
|
43
|
+
case "never":
|
|
44
|
+
return undefined;
|
|
45
|
+
case "custom":
|
|
46
|
+
return customDate ? customDate.toISOString() : undefined;
|
|
47
|
+
default:
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
interface GenerateApiKeyModalProps {
|
|
53
|
+
open: boolean;
|
|
54
|
+
onClose: () => void;
|
|
55
|
+
onCreated: (rawApiKey: string, keyName: string) => void;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function GenerateApiKeyModal({ open, onClose, onCreated }: GenerateApiKeyModalProps) {
|
|
59
|
+
const dispatch = useDispatch();
|
|
60
|
+
const [createApiKey, { isLoading }] = useCreateApiKeyMutation();
|
|
61
|
+
const [customDate, setCustomDate] = useState<Date | null>(null);
|
|
62
|
+
|
|
63
|
+
const formik = useFormik({
|
|
64
|
+
initialValues: {
|
|
65
|
+
name: "",
|
|
66
|
+
expiryOption: "30d",
|
|
67
|
+
},
|
|
68
|
+
validationSchema: Yup.object({
|
|
69
|
+
name: Yup.string()
|
|
70
|
+
.trim()
|
|
71
|
+
.min(2, "Name must be at least 2 characters")
|
|
72
|
+
.max(64, "Name must be 64 characters or fewer")
|
|
73
|
+
.required("Key name is required"),
|
|
74
|
+
expiryOption: Yup.string().required("Expiry is required"),
|
|
75
|
+
}),
|
|
76
|
+
onSubmit: async (values, helpers) => {
|
|
77
|
+
if (values.expiryOption === "custom" && !customDate) {
|
|
78
|
+
helpers.setFieldError("expiryOption", "Please select a custom expiry date");
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const expiresAt = resolveExpiresAt(values.expiryOption, customDate);
|
|
83
|
+
|
|
84
|
+
try {
|
|
85
|
+
const response = await createApiKey({
|
|
86
|
+
name: values.name.trim(),
|
|
87
|
+
...(expiresAt ? { expiresAt } : {}),
|
|
88
|
+
}).unwrap();
|
|
89
|
+
|
|
90
|
+
onCreated(response.data.apiKey, values.name.trim());
|
|
91
|
+
handleClose();
|
|
92
|
+
} catch (err: any) {
|
|
93
|
+
const detail = err?.data?.message || "Failed to generate API key. Please try again.";
|
|
94
|
+
dispatch(showToast({ severity: "error", summary: "Error", detail }));
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
const handleClose = () => {
|
|
100
|
+
formik.resetForm();
|
|
101
|
+
setCustomDate(null);
|
|
102
|
+
onClose();
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
// Reset form when modal opens
|
|
106
|
+
useEffect(() => {
|
|
107
|
+
if (open) {
|
|
108
|
+
formik.resetForm();
|
|
109
|
+
setCustomDate(null);
|
|
110
|
+
}
|
|
111
|
+
}, [open]);
|
|
112
|
+
|
|
113
|
+
const nameError =
|
|
114
|
+
formik.touched.name && formik.errors.name ? String(formik.errors.name) : "";
|
|
115
|
+
const expiryError =
|
|
116
|
+
formik.touched.expiryOption && formik.errors.expiryOption
|
|
117
|
+
? String(formik.errors.expiryOption)
|
|
118
|
+
: "";
|
|
119
|
+
|
|
120
|
+
return (
|
|
121
|
+
<SolidDialog open={open} onOpenChange={handleClose} style={{ maxWidth: 480 }}>
|
|
122
|
+
<SolidDialogHeader>
|
|
123
|
+
<SolidDialogTitle>Generate API Key</SolidDialogTitle>
|
|
124
|
+
</SolidDialogHeader>
|
|
125
|
+
<SolidDialogSeparator />
|
|
126
|
+
<SolidDialogBody>
|
|
127
|
+
<form id="generate-api-key-form" onSubmit={formik.handleSubmit}>
|
|
128
|
+
<div className="flex flex-column gap-3">
|
|
129
|
+
<div className="flex flex-column gap-2">
|
|
130
|
+
<label htmlFor="api-key-name" className="form-field-label">
|
|
131
|
+
Key Name <span style={{ color: "var(--solid-danger-color, #ef4444)" }}>*</span>
|
|
132
|
+
</label>
|
|
133
|
+
<SolidInput
|
|
134
|
+
id="api-key-name"
|
|
135
|
+
name="name"
|
|
136
|
+
autoComplete="off"
|
|
137
|
+
placeholder="e.g. CI/CD pipeline, Mobile app"
|
|
138
|
+
value={formik.values.name}
|
|
139
|
+
onChange={formik.handleChange}
|
|
140
|
+
onBlur={formik.handleBlur}
|
|
141
|
+
/>
|
|
142
|
+
{nameError && <SolidMessage severity="error" text={nameError} />}
|
|
143
|
+
</div>
|
|
144
|
+
|
|
145
|
+
<div className="flex flex-column gap-2">
|
|
146
|
+
<label htmlFor="api-key-expiry" className="form-field-label">
|
|
147
|
+
Expires
|
|
148
|
+
</label>
|
|
149
|
+
<SolidSelect
|
|
150
|
+
value={formik.values.expiryOption}
|
|
151
|
+
options={EXPIRY_OPTIONS}
|
|
152
|
+
optionLabel="label"
|
|
153
|
+
optionValue="value"
|
|
154
|
+
onChange={({ value }) => {
|
|
155
|
+
formik.setFieldValue("expiryOption", value);
|
|
156
|
+
if (value !== "custom") setCustomDate(null);
|
|
157
|
+
}}
|
|
158
|
+
/>
|
|
159
|
+
{formik.values.expiryOption === "custom" && (
|
|
160
|
+
<SolidDatePicker
|
|
161
|
+
selected={customDate}
|
|
162
|
+
onChange={(date: Date | null) => setCustomDate(date)}
|
|
163
|
+
minDate={new Date()}
|
|
164
|
+
placeholderText="Select expiry date"
|
|
165
|
+
dateFormat="dd/MM/yyyy"
|
|
166
|
+
/>
|
|
167
|
+
)}
|
|
168
|
+
{expiryError && <SolidMessage severity="error" text={expiryError} />}
|
|
169
|
+
</div>
|
|
170
|
+
</div>
|
|
171
|
+
</form>
|
|
172
|
+
</SolidDialogBody>
|
|
173
|
+
<SolidDialogSeparator />
|
|
174
|
+
<SolidDialogFooter>
|
|
175
|
+
<SolidButton variant="outline" type="button" onClick={handleClose} disabled={isLoading}>
|
|
176
|
+
Cancel
|
|
177
|
+
</SolidButton>
|
|
178
|
+
<SolidButton type="submit" form="generate-api-key-form" loading={isLoading}>
|
|
179
|
+
Generate Key
|
|
180
|
+
</SolidButton>
|
|
181
|
+
</SolidDialogFooter>
|
|
182
|
+
</SolidDialog>
|
|
183
|
+
);
|
|
184
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface RevealApiKeyModalProps {
|
|
2
|
+
open: boolean;
|
|
3
|
+
apiKey: string;
|
|
4
|
+
keyName: string;
|
|
5
|
+
onClose: () => void;
|
|
6
|
+
}
|
|
7
|
+
export declare function RevealApiKeyModal({ open, apiKey, keyName, onClose }: RevealApiKeyModalProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=RevealApiKeyModal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RevealApiKeyModal.d.ts","sourceRoot":"","sources":["../../../../../src/components/core/users/ApiKeysTab/RevealApiKeyModal.tsx"],"names":[],"mappings":"AAYA,UAAU,sBAAsB;IAC9B,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,wBAAgB,iBAAiB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,sBAAsB,2CA2F3F"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { AlertTriangle, CheckCircle, Copy } from "lucide-react";
|
|
4
|
+
import { SolidButton, SolidDialog, SolidDialogBody, SolidDialogFooter, SolidDialogHeader, SolidDialogSeparator, SolidDialogTitle, } from "../../../shad-cn-ui";
|
|
5
|
+
export function RevealApiKeyModal(_a) {
|
|
6
|
+
var open = _a.open, apiKey = _a.apiKey, keyName = _a.keyName, onClose = _a.onClose;
|
|
7
|
+
var _b = useState(false), copied = _b[0], setCopied = _b[1];
|
|
8
|
+
var handleCopy = function () {
|
|
9
|
+
navigator.clipboard.writeText(apiKey).then(function () {
|
|
10
|
+
setCopied(true);
|
|
11
|
+
setTimeout(function () { return setCopied(false); }, 3000);
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
var handleClose = function () {
|
|
15
|
+
setCopied(false);
|
|
16
|
+
onClose();
|
|
17
|
+
};
|
|
18
|
+
return (_jsxs(SolidDialog, { open: open, onOpenChange: handleClose, dismissible: false, style: { maxWidth: 520 }, children: [_jsx(SolidDialogHeader, { children: _jsx(SolidDialogTitle, { children: "API Key Created" }) }), _jsx(SolidDialogSeparator, {}), _jsxs(SolidDialogBody, { children: [_jsxs("div", { className: "solid-api-key-reveal-warning flex align-items-start gap-2 mb-4", children: [_jsx(AlertTriangle, { size: 16, className: "flex-shrink-0 mt-1" }), _jsxs("p", { className: "m-0", style: { fontSize: 13 }, children: [_jsx("strong", { children: "Copy this key now." }), " It will not be shown again once you close this dialog. Store it somewhere secure."] })] }), _jsx("p", { className: "form-field-label mb-2", children: keyName }), _jsxs("div", { className: "solid-api-key-reveal-box flex align-items-center gap-2 p-3", style: {
|
|
19
|
+
background: "var(--solid-surface-secondary, #f5f5f5)",
|
|
20
|
+
borderRadius: 6,
|
|
21
|
+
border: "1px solid var(--solid-border-color, #e0e0e0)",
|
|
22
|
+
}, children: [_jsx("code", { className: "flex-1", style: {
|
|
23
|
+
fontFamily: "monospace",
|
|
24
|
+
fontSize: 13,
|
|
25
|
+
wordBreak: "break-all",
|
|
26
|
+
userSelect: "all",
|
|
27
|
+
}, children: apiKey }), _jsx("button", { type: "button", title: copied ? "Copied!" : "Copy to clipboard", onClick: handleCopy, style: {
|
|
28
|
+
background: "none",
|
|
29
|
+
border: "none",
|
|
30
|
+
cursor: "pointer",
|
|
31
|
+
padding: "4px",
|
|
32
|
+
display: "flex",
|
|
33
|
+
alignItems: "center",
|
|
34
|
+
flexShrink: 0,
|
|
35
|
+
}, children: copied ? (_jsx(CheckCircle, { size: 16, style: { color: "var(--solid-success-color, #22c55e)" } })) : (_jsx(Copy, { size: 16 })) })] }), copied && (_jsx("p", { className: "m-0 mt-2", style: { fontSize: 12, color: "var(--solid-success-color, #22c55e)" }, children: "Copied to clipboard!" }))] }), _jsx(SolidDialogSeparator, {}), _jsxs(SolidDialogFooter, { children: [_jsx(SolidButton, { variant: "outline", onClick: handleClose, children: "Close" }), _jsx(SolidButton, { onClick: handleClose, children: "I've Saved This Key" })] })] }));
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=RevealApiKeyModal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RevealApiKeyModal.js","sourceRoot":"","sources":["../../../../../src/components/core/users/ApiKeysTab/RevealApiKeyModal.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EACL,WAAW,EACX,WAAW,EACX,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAS7B,MAAM,UAAU,iBAAiB,CAAC,EAA0D;QAAxD,IAAI,UAAA,EAAE,MAAM,YAAA,EAAE,OAAO,aAAA,EAAE,OAAO,aAAA;IAC1D,IAAA,KAAsB,QAAQ,CAAC,KAAK,CAAC,EAApC,MAAM,QAAA,EAAE,SAAS,QAAmB,CAAC;IAE5C,IAAM,UAAU,GAAG;QACjB,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC;YACzC,SAAS,CAAC,IAAI,CAAC,CAAC;YAChB,UAAU,CAAC,cAAM,OAAA,SAAS,CAAC,KAAK,CAAC,EAAhB,CAAgB,EAAE,IAAI,CAAC,CAAC;QAC3C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,IAAM,WAAW,GAAG;QAClB,SAAS,CAAC,KAAK,CAAC,CAAC;QACjB,OAAO,EAAE,CAAC;IACZ,CAAC,CAAC;IAEF,OAAO,CACL,MAAC,WAAW,IAAC,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,aAC9F,KAAC,iBAAiB,cAChB,KAAC,gBAAgB,kCAAmC,GAClC,EACpB,KAAC,oBAAoB,KAAG,EACxB,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qCAAqC,EAAE,qCAEzF,CACL,IACe,EAClB,KAAC,oBAAoB,KAAG,EACxB,MAAC,iBAAiB,eAChB,KAAC,WAAW,IAAC,OAAO,EAAC,SAAS,EAAC,OAAO,EAAE,WAAW,sBAErC,EACd,KAAC,WAAW,IAAC,OAAO,EAAE,WAAW,oCAEnB,IACI,IACR,CACf,CAAC;AACJ,CAAC","sourcesContent":["import { useState } from \"react\";\nimport { AlertTriangle, CheckCircle, Copy } from \"lucide-react\";\nimport {\n SolidButton,\n SolidDialog,\n SolidDialogBody,\n SolidDialogFooter,\n SolidDialogHeader,\n SolidDialogSeparator,\n SolidDialogTitle,\n} from \"../../../shad-cn-ui\";\n\ninterface RevealApiKeyModalProps {\n open: boolean;\n apiKey: string;\n keyName: string;\n onClose: () => void;\n}\n\nexport function RevealApiKeyModal({ open, apiKey, keyName, onClose }: RevealApiKeyModalProps) {\n const [copied, setCopied] = useState(false);\n\n const handleCopy = () => {\n navigator.clipboard.writeText(apiKey).then(() => {\n setCopied(true);\n setTimeout(() => setCopied(false), 3000);\n });\n };\n\n const handleClose = () => {\n setCopied(false);\n onClose();\n };\n\n return (\n <SolidDialog open={open} onOpenChange={handleClose} dismissible={false} style={{ maxWidth: 520 }}>\n <SolidDialogHeader>\n <SolidDialogTitle>API Key Created</SolidDialogTitle>\n </SolidDialogHeader>\n <SolidDialogSeparator />\n <SolidDialogBody>\n <div className=\"solid-api-key-reveal-warning flex align-items-start gap-2 mb-4\">\n <AlertTriangle size={16} className=\"flex-shrink-0 mt-1\" />\n <p className=\"m-0\" style={{ fontSize: 13 }}>\n <strong>Copy this key now.</strong> It will not be shown again once you close this dialog. Store it somewhere secure.\n </p>\n </div>\n\n <p className=\"form-field-label mb-2\">\n {keyName}\n </p>\n\n <div\n className=\"solid-api-key-reveal-box flex align-items-center gap-2 p-3\"\n style={{\n background: \"var(--solid-surface-secondary, #f5f5f5)\",\n borderRadius: 6,\n border: \"1px solid var(--solid-border-color, #e0e0e0)\",\n }}\n >\n <code\n className=\"flex-1\"\n style={{\n fontFamily: \"monospace\",\n fontSize: 13,\n wordBreak: \"break-all\",\n userSelect: \"all\",\n }}\n >\n {apiKey}\n </code>\n <button\n type=\"button\"\n title={copied ? \"Copied!\" : \"Copy to clipboard\"}\n onClick={handleCopy}\n style={{\n background: \"none\",\n border: \"none\",\n cursor: \"pointer\",\n padding: \"4px\",\n display: \"flex\",\n alignItems: \"center\",\n flexShrink: 0,\n }}\n >\n {copied ? (\n <CheckCircle size={16} style={{ color: \"var(--solid-success-color, #22c55e)\" }} />\n ) : (\n <Copy size={16} />\n )}\n </button>\n </div>\n\n {copied && (\n <p className=\"m-0 mt-2\" style={{ fontSize: 12, color: \"var(--solid-success-color, #22c55e)\" }}>\n Copied to clipboard!\n </p>\n )}\n </SolidDialogBody>\n <SolidDialogSeparator />\n <SolidDialogFooter>\n <SolidButton variant=\"outline\" onClick={handleClose}>\n Close\n </SolidButton>\n <SolidButton onClick={handleClose}>\n I've Saved This Key\n </SolidButton>\n </SolidDialogFooter>\n </SolidDialog>\n );\n}\n"]}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import { AlertTriangle, CheckCircle, Copy } from "lucide-react";
|
|
3
|
+
import {
|
|
4
|
+
SolidButton,
|
|
5
|
+
SolidDialog,
|
|
6
|
+
SolidDialogBody,
|
|
7
|
+
SolidDialogFooter,
|
|
8
|
+
SolidDialogHeader,
|
|
9
|
+
SolidDialogSeparator,
|
|
10
|
+
SolidDialogTitle,
|
|
11
|
+
} from "../../../shad-cn-ui";
|
|
12
|
+
|
|
13
|
+
interface RevealApiKeyModalProps {
|
|
14
|
+
open: boolean;
|
|
15
|
+
apiKey: string;
|
|
16
|
+
keyName: string;
|
|
17
|
+
onClose: () => void;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function RevealApiKeyModal({ open, apiKey, keyName, onClose }: RevealApiKeyModalProps) {
|
|
21
|
+
const [copied, setCopied] = useState(false);
|
|
22
|
+
|
|
23
|
+
const handleCopy = () => {
|
|
24
|
+
navigator.clipboard.writeText(apiKey).then(() => {
|
|
25
|
+
setCopied(true);
|
|
26
|
+
setTimeout(() => setCopied(false), 3000);
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const handleClose = () => {
|
|
31
|
+
setCopied(false);
|
|
32
|
+
onClose();
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<SolidDialog open={open} onOpenChange={handleClose} dismissible={false} style={{ maxWidth: 520 }}>
|
|
37
|
+
<SolidDialogHeader>
|
|
38
|
+
<SolidDialogTitle>API Key Created</SolidDialogTitle>
|
|
39
|
+
</SolidDialogHeader>
|
|
40
|
+
<SolidDialogSeparator />
|
|
41
|
+
<SolidDialogBody>
|
|
42
|
+
<div className="solid-api-key-reveal-warning flex align-items-start gap-2 mb-4">
|
|
43
|
+
<AlertTriangle size={16} className="flex-shrink-0 mt-1" />
|
|
44
|
+
<p className="m-0" style={{ fontSize: 13 }}>
|
|
45
|
+
<strong>Copy this key now.</strong> It will not be shown again once you close this dialog. Store it somewhere secure.
|
|
46
|
+
</p>
|
|
47
|
+
</div>
|
|
48
|
+
|
|
49
|
+
<p className="form-field-label mb-2">
|
|
50
|
+
{keyName}
|
|
51
|
+
</p>
|
|
52
|
+
|
|
53
|
+
<div
|
|
54
|
+
className="solid-api-key-reveal-box flex align-items-center gap-2 p-3"
|
|
55
|
+
style={{
|
|
56
|
+
background: "var(--solid-surface-secondary, #f5f5f5)",
|
|
57
|
+
borderRadius: 6,
|
|
58
|
+
border: "1px solid var(--solid-border-color, #e0e0e0)",
|
|
59
|
+
}}
|
|
60
|
+
>
|
|
61
|
+
<code
|
|
62
|
+
className="flex-1"
|
|
63
|
+
style={{
|
|
64
|
+
fontFamily: "monospace",
|
|
65
|
+
fontSize: 13,
|
|
66
|
+
wordBreak: "break-all",
|
|
67
|
+
userSelect: "all",
|
|
68
|
+
}}
|
|
69
|
+
>
|
|
70
|
+
{apiKey}
|
|
71
|
+
</code>
|
|
72
|
+
<button
|
|
73
|
+
type="button"
|
|
74
|
+
title={copied ? "Copied!" : "Copy to clipboard"}
|
|
75
|
+
onClick={handleCopy}
|
|
76
|
+
style={{
|
|
77
|
+
background: "none",
|
|
78
|
+
border: "none",
|
|
79
|
+
cursor: "pointer",
|
|
80
|
+
padding: "4px",
|
|
81
|
+
display: "flex",
|
|
82
|
+
alignItems: "center",
|
|
83
|
+
flexShrink: 0,
|
|
84
|
+
}}
|
|
85
|
+
>
|
|
86
|
+
{copied ? (
|
|
87
|
+
<CheckCircle size={16} style={{ color: "var(--solid-success-color, #22c55e)" }} />
|
|
88
|
+
) : (
|
|
89
|
+
<Copy size={16} />
|
|
90
|
+
)}
|
|
91
|
+
</button>
|
|
92
|
+
</div>
|
|
93
|
+
|
|
94
|
+
{copied && (
|
|
95
|
+
<p className="m-0 mt-2" style={{ fontSize: 12, color: "var(--solid-success-color, #22c55e)" }}>
|
|
96
|
+
Copied to clipboard!
|
|
97
|
+
</p>
|
|
98
|
+
)}
|
|
99
|
+
</SolidDialogBody>
|
|
100
|
+
<SolidDialogSeparator />
|
|
101
|
+
<SolidDialogFooter>
|
|
102
|
+
<SolidButton variant="outline" onClick={handleClose}>
|
|
103
|
+
Close
|
|
104
|
+
</SolidButton>
|
|
105
|
+
<SolidButton onClick={handleClose}>
|
|
106
|
+
I've Saved This Key
|
|
107
|
+
</SolidButton>
|
|
108
|
+
</SolidDialogFooter>
|
|
109
|
+
</SolidDialog>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/core/users/ApiKeysTab/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/components/core/users/ApiKeysTab/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC","sourcesContent":["export { ApiKeysTab } from \"./ApiKeysTab\";\nexport { GenerateApiKeyModal } from \"./GenerateApiKeyModal\";\nexport { RevealApiKeyModal } from \"./RevealApiKeyModal\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppSidebar.d.ts","sourceRoot":"","sources":["../../../src/components/layout/AppSidebar.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AppSidebar.d.ts","sourceRoot":"","sources":["../../../src/components/layout/AppSidebar.tsx"],"names":[],"mappings":"AA+LA,QAAA,MAAM,UAAU,+CAsNf,CAAC;AAEF,eAAe,UAAU,CAAC"}
|