Skip to content

Commit

Permalink
Merge pull request #109 from dev-family/ADM-62
Browse files Browse the repository at this point in the history
ADM 62 + ADM-103
  • Loading branch information
aMurashkoWebSecret authored Dec 21, 2023
2 parents 31a0d07 + e4c1bba commit 0c0c170
Show file tree
Hide file tree
Showing 18 changed files with 180 additions and 57 deletions.
2 changes: 1 addition & 1 deletion admiral/crud/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ function makeUpdatePage<RecordType>(config: CRUDConfig<RecordType>) {
) : (
<Page title={title(id)}>
<Form
redirect={path}
redirect={true}
submitData={submitData}
fetchInitialData={fetchInitialData}
locale={locale.form}
Expand Down
2 changes: 1 addition & 1 deletion admiral/crud/locale/LocaleContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { enUs as enUsTableLocale } from '../../ui/Table/locales'
import { enUs as enUsPopconfirmLocale } from '../../dataTable/locale/enUS'
import { enUs as enEsLayoutLocale } from '../../ui/Layout/locale/enUs'

const defaultLocale: CRUDLocale = {
export const defaultLocale: CRUDLocale = {
actions: enUsActionsLocale,
pagination: enUsPaginationLocale,
filters: enUsFiltersLocale,
Expand Down
1 change: 0 additions & 1 deletion admiral/dataTable/actions/EditAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export const EditAction: React.FC<EditActionProps> = ({
if (behavior === 'backgroundRoute' && !mainRoutePath) {
console.error('Please provide "mainRoutePath" for "backgroundRoute" behavior')
}

return (
<Link
to={{
Expand Down
7 changes: 6 additions & 1 deletion admiral/dataTable/locale/enUS.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { enUs as enUsPopconfirmLocale } from '../../ui/Popconfirm/locale/enUS'
import { PopconfirmLocaleType } from '../../ui/Popconfirm/interfaces'

export const enUs = {
export type DataTableType = {
title: string
} & PopconfirmLocaleType

export const enUs: DataTableType = {
title: 'Are you sure you want to delete?',
...enUsPopconfirmLocale,
}
7 changes: 4 additions & 3 deletions admiral/form/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { RouterLocationState } from '../router/interfaces'
export type FormProps = {
locale?: Locale
className?: string
redirect?: string
redirect?: string | boolean
fetchInitialData?: () => Promise<GetFormDataResult>
submitData?: (values: any) => Promise<any>
children: React.ReactNode
Expand Down Expand Up @@ -93,8 +93,9 @@ const InternalForm = forwardRef<FormRef, FormProps>(
message: locale.successMessage,
type: 'success',
})

if (redirect) {
if (redirect === true) {
history.goBack()
} else if (redirect) {
history.push({
pathname: redirect,
// update table when drawer saved and closed
Expand Down
3 changes: 3 additions & 0 deletions admiral/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,6 @@ export { createRoutesFrom } from './router'

export { useTheme, useThemeVars } from './theme'
export type { ThemeName, ThemePreset } from './theme/interfaces'

export { admiralLocales } from './locales'
export type { AdmiralLocales } from './locales'
57 changes: 57 additions & 0 deletions admiral/locales.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { CRUDLocale } from './crud/interfaces'
import { defaultLocale as CRUDEn } from './crud/locale/LocaleContext'
import { enUs as tableEn, DataTableType } from './dataTable/locale'
import { FiltersLocale } from './filters/interfaces'
import { enUS as filtersLocaleEn } from './filters/locale/enUS'
import { Locale as FormLocale } from './form/interfaces'
import { enUS as formLocaleEn } from './form/locale/enUS'
import datePickerLocaleEn from './ui/DatePicker/locale/en_US'
import { PickerLocale } from './ui/DatePicker/generatePicker/interfaces'
import { enUs as LayoutLocaleEn } from './ui/Layout/locale/enUs'
import { LayoutLocale } from './ui/Layout/interfaces'
import { enUs as paginationLocaleEn } from './ui/Pagination/locales/enUS'
import { PaginationLocale } from './ui/Pagination/interfaces'
import { enUs as PopconfirmLocaleEn } from './ui/Popconfirm/locale'
import { PopconfirmLocaleType } from './ui/Popconfirm/interfaces'
import { enUs as selectLocaleEn } from './ui/Select/locales/enUS'
import { SelectLocale } from './ui/Select/interfaces'
import { enUS as uploadLocaleEn } from './ui/Upload/locales/enUS'
import { UploadLocale } from './ui/Upload/interfaces'

type AdmiralLocale = {
CRUD: CRUDLocale
table: DataTableType
filters: FiltersLocale
form: FormLocale
ui: {
datePicker: PickerLocale
layout: LayoutLocale
pagination: PaginationLocale
popconfirm: PopconfirmLocaleType
select: SelectLocale
upload: UploadLocale
}
}

export type AdmiralLocales = {
en: AdmiralLocale
ru: {}
}

export const admiralLocales: AdmiralLocales = {
en: {
CRUD: CRUDEn,
table: tableEn,
filters: filtersLocaleEn,
form: formLocaleEn,
ui: {
datePicker: datePickerLocaleEn,
layout: LayoutLocaleEn,
pagination: paginationLocaleEn,
popconfirm: PopconfirmLocaleEn,
select: selectLocaleEn,
upload: uploadLocaleEn,
},
},
ru: {},
}
2 changes: 2 additions & 0 deletions admiral/ui/Popconfirm/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { TooltipProps } from '../Tooltip/interfaces'

export type PopconfirmLocaleType = { cancelTitle: string; confirmTitle: string }

export interface PopconfirmProps extends Pick<TooltipProps, 'placement'> {
title: React.ReactNode
initialOpen?: boolean
Expand Down
4 changes: 3 additions & 1 deletion admiral/ui/Popconfirm/locale/enUS.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export const enUs = {
import { PopconfirmLocaleType } from '../interfaces'

export const enUs: PopconfirmLocaleType = {
cancelTitle: 'Cancel',
confirmTitle: 'Confirm',
}
25 changes: 22 additions & 3 deletions lib/admiral.es.js
Original file line number Diff line number Diff line change
Expand Up @@ -94274,7 +94274,9 @@ const InternalForm = forwardRef$3(({ locale: locale2 = enUS$2, className, fetchI
message: locale2.successMessage,
type: "success"
});
if (redirect) {
if (redirect === true) {
history.goBack();
} else if (redirect) {
history.push({
pathname: redirect,
state: { update: { dataTable: true } }
Expand Down Expand Up @@ -96761,7 +96763,7 @@ function makeUpdatePage(config2) {
}) : /* @__PURE__ */ React__default.createElement(Page, {
title: title2(id)
}, /* @__PURE__ */ React__default.createElement(Form, {
redirect: path,
redirect: true,
submitData,
fetchInitialData,
locale: locale2.form
Expand Down Expand Up @@ -96864,4 +96866,21 @@ function createCRUD(config2) {
UpdatePage: makeUpdatePage(config2)
};
}
export { Admin, AjaxSelectInput, ArrayInput, BackButton, Badge, BooleanInput, Button$1 as Button, Card$1 as Card, Checkbox$1 as Checkbox, ColorPicker$1 as ColorPicker, ColorPickerInput, CreateButton, DatePicker, DatePickerInput, DeleteAction, DraggerInput, Drawer, EditAction, Editor, EditorInput, FileField, FilePictureInput, FilterButton, Form, FormProvider, Input$2 as Input, Layout, Menu$1 as Menu, MenuItemLink, MonthPicker, MultilineTextInput, Notification, NotificationContent, OAuthProvidersEnum, Page, Pagination, Password$1 as Password, PasswordInput, Popconfirm, QuarterPicker, Radio$1 as Radio, RadioGroup$1 as RadioGroup, RadioInput, Select, SelectInput, SlugInput, Spin, SubMenu$1 as SubMenu, Switch, Table, Tabs, TextInput, Textarea$1 as Textarea, ThemeSwitch, TimePicker, TimePickerInput, Tooltip, TopToolbar, TranslatableInput, Typography, Upload, WeekPicker, YearPicker, createCRUD, createRoutesFrom, index as filtersLocale, index$1 as formLocale, parseValue, useDataProvider, useForceUpdate, useForm, useGetIdentity, useMedia, useControlledState as useMergedState, useNav, useSafeSetState, useTheme, _useThemeVars as useThemeVars, useUrlState };
const admiralLocales = {
en: {
CRUD: defaultLocale,
table: enUs$1,
filters: enUS$1,
form: enUS$2,
ui: {
datePicker: locale,
layout: enUs,
pagination: enUs$5,
popconfirm: enUs$3,
select: enUs$4,
upload: enUS$3
}
},
ru: {}
};
export { Admin, AjaxSelectInput, ArrayInput, BackButton, Badge, BooleanInput, Button$1 as Button, Card$1 as Card, Checkbox$1 as Checkbox, ColorPicker$1 as ColorPicker, ColorPickerInput, CreateButton, DatePicker, DatePickerInput, DeleteAction, DraggerInput, Drawer, EditAction, Editor, EditorInput, FileField, FilePictureInput, FilterButton, Form, FormProvider, Input$2 as Input, Layout, Menu$1 as Menu, MenuItemLink, MonthPicker, MultilineTextInput, Notification, NotificationContent, OAuthProvidersEnum, Page, Pagination, Password$1 as Password, PasswordInput, Popconfirm, QuarterPicker, Radio$1 as Radio, RadioGroup$1 as RadioGroup, RadioInput, Select, SelectInput, SlugInput, Spin, SubMenu$1 as SubMenu, Switch, Table, Tabs, TextInput, Textarea$1 as Textarea, ThemeSwitch, TimePicker, TimePickerInput, Tooltip, TopToolbar, TranslatableInput, Typography, Upload, WeekPicker, YearPicker, admiralLocales, createCRUD, createRoutesFrom, index as filtersLocale, index$1 as formLocale, parseValue, useDataProvider, useForceUpdate, useForm, useGetIdentity, useMedia, useControlledState as useMergedState, useNav, useSafeSetState, useTheme, _useThemeVars as useThemeVars, useUrlState };
74 changes: 37 additions & 37 deletions lib/admiral.umd.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions lib/admiral/crud/locale/LocaleContext.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { CRUDLocale } from '../interfaces';
export declare const defaultLocale: CRUDLocale;
export declare const LocaleContext: React.Context<CRUDLocale>;
export declare const LocaleContextProvider: React.FC<{
value?: Partial<CRUDLocale>;
Expand Down
8 changes: 4 additions & 4 deletions lib/admiral/dataTable/locale/enUS.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export declare const enUs: {
cancelTitle: string;
confirmTitle: string;
import { PopconfirmLocaleType } from '../../ui/Popconfirm/interfaces';
export declare type DataTableType = {
title: string;
};
} & PopconfirmLocaleType;
export declare const enUs: DataTableType;
2 changes: 1 addition & 1 deletion lib/admiral/form/Form.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Locale } from './interfaces';
export declare type FormProps = {
locale?: Locale;
className?: string;
redirect?: string;
redirect?: string | boolean;
fetchInitialData?: () => Promise<GetFormDataResult>;
submitData?: (values: any) => Promise<any>;
children: React.ReactNode;
Expand Down
2 changes: 2 additions & 0 deletions lib/admiral/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ export { TopToolbar } from './layout';
export { createRoutesFrom } from './router';
export { useTheme, useThemeVars } from './theme';
export type { ThemeName, ThemePreset } from './theme/interfaces';
export { admiralLocales } from './locales';
export type { AdmiralLocales } from './locales';
30 changes: 30 additions & 0 deletions lib/admiral/locales.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { CRUDLocale } from './crud/interfaces';
import { DataTableType } from './dataTable/locale';
import { FiltersLocale } from './filters/interfaces';
import { Locale as FormLocale } from './form/interfaces';
import { PickerLocale } from './ui/DatePicker/generatePicker/interfaces';
import { LayoutLocale } from './ui/Layout/interfaces';
import { PaginationLocale } from './ui/Pagination/interfaces';
import { PopconfirmLocaleType } from './ui/Popconfirm/interfaces';
import { SelectLocale } from './ui/Select/interfaces';
import { UploadLocale } from './ui/Upload/interfaces';
declare type AdmiralLocale = {
CRUD: CRUDLocale;
table: DataTableType;
filters: FiltersLocale;
form: FormLocale;
ui: {
datePicker: PickerLocale;
layout: LayoutLocale;
pagination: PaginationLocale;
popconfirm: PopconfirmLocaleType;
select: SelectLocale;
upload: UploadLocale;
};
};
export declare type AdmiralLocales = {
en: AdmiralLocale;
ru: {};
};
export declare const admiralLocales: AdmiralLocales;
export {};
4 changes: 4 additions & 0 deletions lib/admiral/ui/Popconfirm/interfaces.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/// <reference types="react" />
import { TooltipProps } from '../Tooltip/interfaces';
export declare type PopconfirmLocaleType = {
cancelTitle: string;
confirmTitle: string;
};
export interface PopconfirmProps extends Pick<TooltipProps, 'placement'> {
title: React.ReactNode;
initialOpen?: boolean;
Expand Down
6 changes: 2 additions & 4 deletions lib/admiral/ui/Popconfirm/locale/enUS.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
export declare const enUs: {
cancelTitle: string;
confirmTitle: string;
};
import { PopconfirmLocaleType } from '../interfaces';
export declare const enUs: PopconfirmLocaleType;

0 comments on commit 0c0c170

Please sign in to comment.