@cagatayfdn/flora-components 0.0.4 → 0.0.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/index.d.ts CHANGED
@@ -1,15 +1,42 @@
1
1
  /// <reference types="react" />
2
2
 
3
+ import { AxiosError } from 'axios';
3
4
  import { CustomLocale } from 'flatpickr/dist/types/locale';
5
+ import { Dispatch as Dispatch_2 } from 'react';
4
6
  import { FC } from 'react';
5
7
  import i18n from 'i18next';
8
+ import { JSX as JSX_2 } from 'react/jsx-runtime';
6
9
  import { LinkProps } from 'react-router-dom';
7
10
  import { MouseEvent as MouseEvent_2 } from 'react';
8
11
  import NiceModal from '@ebay/nice-modal-react';
9
12
  import { NiceModalHocProps } from '@ebay/nice-modal-react';
13
+ import { default as React_2 } from 'react';
10
14
  import { ReactNode } from 'react';
15
+ import { SetStateAction } from 'react';
11
16
  import { TFunction } from 'i18next';
12
17
 
18
+ declare type Actiontype = {
19
+ type: 'login_pending';
20
+ } | {
21
+ type: 'active_user_success';
22
+ payload: UserEntity;
23
+ } | {
24
+ type: 'login_failure';
25
+ payload: any;
26
+ } | {
27
+ type: 'active_user_failure';
28
+ payload: any;
29
+ } | {
30
+ type: 'register_pending';
31
+ } | {
32
+ type: 'register_failure';
33
+ payload: any;
34
+ } | {
35
+ type: 'no_active_user';
36
+ } | {
37
+ type: 'signout';
38
+ };
39
+
13
40
  export declare enum AppAndServicesStatusApperenceType {
14
41
  ADDONS_INITIALIZING = "addons_initializing",
15
42
  ADDONS_ADDONS_INITILIZATION_FAILED = "addons_initialization_failed",
@@ -77,6 +104,14 @@ export declare enum AppTypeEnum {
77
104
  APPLICATION = "application"
78
105
  }
79
106
 
107
+ declare type AuthContextType = [state: State & {
108
+ token?: string;
109
+ }, dispatch: Dispatch];
110
+
111
+ export declare const AuthProvider: (props: {
112
+ children: React_2.ReactNode;
113
+ }) => JSX_2.Element;
114
+
80
115
  export declare const Button: ({ children, size, isLoading, isDisabled, isBlock, noBorder, isSolid, type, className, prefixIcon, appearance, onClick, }: ButtonProps) => JSX.Element;
81
116
 
82
117
  declare type ButtonProps = {
@@ -129,6 +164,8 @@ export declare enum CopyTextStatusEnum {
129
164
  ERROR = "error"
130
165
  }
131
166
 
167
+ declare type Dispatch = React_2.Dispatch<Actiontype>;
168
+
132
169
  export declare enum DividerAppearance {
133
170
  LIGHT = "light",
134
171
  GREY = "grey"
@@ -159,6 +196,10 @@ export declare function getCurrentLanguage(): string;
159
196
 
160
197
  export declare function getDatepickerLocale(): "en" | CustomLocale;
161
198
 
199
+ declare type HashMap<K extends string | number, V> = {
200
+ [key in K]: V
201
+ }
202
+
162
203
  export { i18n }
163
204
 
164
205
  export declare const Icon: (props: IconProps) => JSX.Element;
@@ -246,6 +287,8 @@ declare type LoadingProps = {
246
287
  layer?: boolean;
247
288
  };
248
289
 
290
+ declare type MappedObjectPermission = HashMap<PermissionsType, number[]>
291
+
249
292
  export declare const Modal: (props: ModalProps) => JSX.Element;
250
293
 
251
294
  export declare enum ModalAppearanceType {
@@ -279,6 +322,78 @@ export declare enum NotificationAppearanceType {
279
322
  LOADING = "loading"
280
323
  }
281
324
 
325
+ declare interface Permissions_2 {
326
+ default: boolean
327
+ depends_on: PermissionsType[] | null
328
+ description: string
329
+ name: string
330
+ slug: PermItem
331
+ }
332
+
333
+ declare enum PermissionsSlug {
334
+ Read = 'read',
335
+ Write = 'write',
336
+ Edit = 'edit',
337
+ Delete = 'delete',
338
+ Build = 'build',
339
+ Deploy = 'deploy',
340
+ EditPermissions = 'edit_permissions',
341
+ ViewAddonInfo = 'view_addon_info',
342
+ SetStableVersion = 'set_stable_version',
343
+ AttachCertificate = 'attach_certificate',
344
+ ManageEnvironments = 'manage_environments',
345
+ ManageSecretEnvironments = 'manage_secret_environments',
346
+ Monitor = 'monitor',
347
+ Resend = 'resend',
348
+ ExportZonefile = 'export_zonefile',
349
+ }
350
+
351
+ declare type PermissionsType = `${PermItem}::${PermissionsSlug}`
352
+
353
+ declare interface PermissionTree {
354
+ users: PermissionTreeItem
355
+ roles: PermissionTreeItem
356
+ public_key: PermissionTreeItem
357
+ apps: PermissionTreeItem
358
+ app_versions: PermissionTreeItem
359
+ quality_assurance_report: PermissionTreeItem
360
+ addon_types: PermissionTreeItem
361
+ related_app: PermissionTreeItem
362
+ public_apps: PermissionTreeItem
363
+ public_services: PermissionTreeItem
364
+ projects: PermissionTreeItem
365
+ project_apps: PermissionTreeItem
366
+ export_project_app_log: PermissionTreeItem
367
+ project_app_deployments: PermissionTreeItem
368
+ related_project_app: PermissionTreeItem
369
+ project_app_email: PermissionTreeItem
370
+ addons: PermissionTreeItem
371
+ accounts: PermissionTreeItem
372
+ domain: PermissionTreeItem
373
+ certificate: PermissionTreeItem
374
+ email: PermissionTreeItem
375
+ mail_identity_domain: PermissionTreeItem
376
+ remote_group: PermissionTreeItem
377
+ remote_group_user: PermissionTreeItem
378
+ remote_group_application: PermissionTreeItem
379
+ app_bundle: PermissionTreeItem
380
+ app_bundle_app: PermissionTreeItem
381
+ app_bundle_base_app: PermissionTreeItem
382
+ monitoring: PermissionTreeItem
383
+ kubernetes: PermissionTreeItem
384
+ app_user: PermissionTreeItem
385
+ }
386
+
387
+ declare interface PermissionTreeItem {
388
+ depends_on: PermissionsType[] | null
389
+ description: string
390
+ name: string
391
+ permissions: Permissions_2[]
392
+ slug: PermItem
393
+ }
394
+
395
+ declare type PermItem = keyof PermissionTree
396
+
282
397
  export declare enum PodStatusEnum {
283
398
  TERMINATED = "Terminated",
284
399
  TERMINATING = "Terminating",
@@ -296,6 +411,15 @@ export declare enum ReportStatus {
296
411
  SUCCESS = "completed"
297
412
  }
298
413
 
414
+ declare interface Role {
415
+ pk: number
416
+ name: string
417
+ account: number
418
+ description: string | null
419
+ permission_tree: PermissionTree
420
+ permissions: PermissionsType[]
421
+ }
422
+
299
423
  export declare const Row: ({ children, className }: RowProps) => JSX.Element;
300
424
 
301
425
  declare type RowProps = {
@@ -311,6 +435,14 @@ export declare enum Size {
311
435
  XL = "xlarge"
312
436
  }
313
437
 
438
+ declare interface State {
439
+ user: UserEntity | null;
440
+ status: Status;
441
+ error: AxiosError | null;
442
+ }
443
+
444
+ declare type Status = 'idle' | 'pending' | 'success' | 'rejected';
445
+
314
446
  export declare enum StatusEnum {
315
447
  addons_initializing = "initializing",
316
448
  addons_initialization_failed = "failed",
@@ -360,4 +492,34 @@ export declare enum ThemeAppearance {
360
492
  DARK_BLUE = "dark_blue"
361
493
  }
362
494
 
495
+ export declare const useAuth: () => AuthContextType;
496
+
497
+ export declare function useDisclosure(isOpenInit?: boolean): {
498
+ isOpen: boolean;
499
+ setIsOpen: Dispatch_2<SetStateAction<boolean>>;
500
+ onOpen: () => void;
501
+ onClose: () => void;
502
+ onToggle: () => void;
503
+ };
504
+
505
+ declare type UseNiceModal = [() => void, () => void, string];
506
+
507
+ export declare function useNiceModal(modalId?: string): UseNiceModal;
508
+
509
+ declare interface UserEntity {
510
+ pk: number
511
+ email?: string
512
+ first_name?: string
513
+ last_name?: string
514
+ language?: string
515
+ account?: number
516
+ last_login?: string | null
517
+ permission_tree?: PermissionTree
518
+ is_active?: boolean
519
+ avatar?: string
520
+ role?: Role
521
+ object_permissions: MappedObjectPermission
522
+ permissions: PermissionsType[]
523
+ }
524
+
363
525
  export { }