@hed-hog/core 0.0.374 → 0.0.376

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.
@@ -92,6 +92,8 @@ function getLocalizedIntegrationName(
92
92
 
93
93
  const MAIL_INTEGRATION_PROFILE_SETTING_SLUG = 'mail-integration-profile-id';
94
94
  const SCALING_INFRA_PROFILE_SETTING_SLUG = 'scaling.video.integration_profile_id';
95
+ const HEDHOG_K8S_INFRA_PROFILE_SETTING_SLUG =
96
+ 'hedhog.k8s_integration_profile_id';
95
97
  const COMMERCE_PAYMENT_PROFILE_SETTING_SLUG =
96
98
  'commerce-default-payment-profile-id';
97
99
  const DAILY_REPORT_EMAIL_INTEGRATION_SETTING_SLUG =
@@ -117,6 +119,7 @@ const OAUTH_PROFILE_SLUG_TO_PROVIDER: Record<string, string> = {
117
119
  const ALL_INTEGRATION_PROFILE_SETTING_SLUGS = [
118
120
  MAIL_INTEGRATION_PROFILE_SETTING_SLUG,
119
121
  SCALING_INFRA_PROFILE_SETTING_SLUG,
122
+ HEDHOG_K8S_INFRA_PROFILE_SETTING_SLUG,
120
123
  COMMERCE_PAYMENT_PROFILE_SETTING_SLUG,
121
124
  DAILY_REPORT_EMAIL_INTEGRATION_SETTING_SLUG,
122
125
  DAILY_REPORT_WHATSAPP_INTEGRATION_SETTING_SLUG,
@@ -1266,6 +1269,105 @@ export const SettingField = ({ setting, className }: SettingFieldProps) => {
1266
1269
  );
1267
1270
  }
1268
1271
 
1272
+ if (setting.slug === HEDHOG_K8S_INFRA_PROFILE_SETTING_SLUG) {
1273
+ return (
1274
+ <>
1275
+ <div className="flex w-full min-w-0 items-center gap-2 md:max-w-72">
1276
+ <EntityPicker<IntegrationProfileOption & Record<string, unknown>>
1277
+ placeholder={t('selectK8sInfraProfile')}
1278
+ emptyStateDescription={t('k8sInfraProfileEmptyState')}
1279
+ value={parsedValue || null}
1280
+ onChange={(slug, option) => {
1281
+ setStorageProfileSelectedLabel(option?.name ?? '');
1282
+ setResolvedProfileId(
1283
+ option ? Number((option as { id?: number }).id) || null : null
1284
+ );
1285
+ handleChangeValue(slug != null ? String(slug) : '', true);
1286
+ }}
1287
+ valueType="string"
1288
+ initialSelectedLabel={storageProfileSelectedLabel}
1289
+ showCreateButton={false}
1290
+ clearable
1291
+ loadOptions={async ({ page, pageSize, search }) => {
1292
+ const qs = new URLSearchParams({
1293
+ page: String(page),
1294
+ pageSize: String(pageSize),
1295
+ typeSlug: 'infrastructure',
1296
+ providerSlug: 'kubernetes',
1297
+ });
1298
+ if (search) qs.set('search', search);
1299
+ const response = await request<
1300
+ ApiPaginated<
1301
+ IntegrationProfileOption & Record<string, unknown>
1302
+ >
1303
+ >({
1304
+ url: `/integration-profile?${qs}`,
1305
+ method: 'GET',
1306
+ });
1307
+ const paged = response.data;
1308
+ return {
1309
+ items: paged?.data ?? [],
1310
+ hasMore: (paged?.page ?? 0) < (paged?.lastPage ?? 0),
1311
+ };
1312
+ }}
1313
+ getOptionValue={(opt) => opt.slug}
1314
+ getOptionLabel={(opt) => String(opt.name ?? '')}
1315
+ getOptionDescription={(opt) => opt.slug}
1316
+ className={cn('flex-1 min-w-0', className)}
1317
+ />
1318
+
1319
+ <Button
1320
+ type="button"
1321
+ variant="outline"
1322
+ size="icon"
1323
+ className="h-10 w-10 shrink-0"
1324
+ onClick={() => {
1325
+ setStorageProfileEditingId(resolvedProfileId);
1326
+ setIsStorageProfileSheetOpen(true);
1327
+ }}
1328
+ disabled={!resolvedProfileId}
1329
+ aria-label="Editar perfil Kubernetes"
1330
+ title="Editar perfil Kubernetes"
1331
+ >
1332
+ <Pencil className="h-4 w-4" />
1333
+ </Button>
1334
+
1335
+ <Button
1336
+ type="button"
1337
+ variant="outline"
1338
+ size="icon"
1339
+ className="h-10 w-10 shrink-0"
1340
+ onClick={() => {
1341
+ setStorageProfileEditingId(null);
1342
+ setIsStorageProfileSheetOpen(true);
1343
+ }}
1344
+ aria-label="Criar perfil Kubernetes"
1345
+ title="Criar perfil Kubernetes"
1346
+ >
1347
+ <Plus className="h-4 w-4" />
1348
+ </Button>
1349
+ </div>
1350
+
1351
+ <IntegrationProfileSheet
1352
+ open={isStorageProfileSheetOpen}
1353
+ onOpenChange={(nextOpen) => {
1354
+ setIsStorageProfileSheetOpen(nextOpen);
1355
+ if (!nextOpen) setStorageProfileEditingId(null);
1356
+ }}
1357
+ profileId={storageProfileEditingId}
1358
+ initialTypeSlug="infrastructure"
1359
+ lockedTypeSlug="infrastructure"
1360
+ lockedProviderSlug="kubernetes"
1361
+ onSaved={(profile: IntegrationProfileSheetSavedProfile) => {
1362
+ setStorageProfileSelectedLabel(profile.name ?? '');
1363
+ setResolvedProfileId(profile.id ?? null);
1364
+ handleChangeValue(String(profile.slug ?? ''), true);
1365
+ }}
1366
+ />
1367
+ </>
1368
+ );
1369
+ }
1370
+
1269
1371
  if (setting.slug === MAIL_INTEGRATION_PROFILE_SETTING_SLUG) {
1270
1372
  return (
1271
1373
  <>