Skip to content

Commit

Permalink
✨ feat(input): explcit placeholders
Browse files Browse the repository at this point in the history
  • Loading branch information
thrownullexception committed Dec 12, 2023
1 parent 9e48cc0 commit d51b382
Show file tree
Hide file tree
Showing 15 changed files with 32 additions and 26 deletions.
3 changes: 3 additions & 0 deletions src/__tests__/api/_test-utils/_all.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ConfigDomain } from "backend/lib/config-persistence/types";
import { KeyValueDomain } from "backend/lib/key-value/types";
import { createCacheService } from "backend/lib/cache";
import { setupAppConfigTestData } from "./_app-config";
import { setupIntegrationsConstantsTestData } from "./_integrations-constants";
import { setupCredentialsTestData } from "./_credentials";
Expand Down Expand Up @@ -33,6 +34,8 @@ export const setupAllTestData = async (domains: DomainTypes[]) => {
...portalTestData,
];

createCacheService().purge();

await Promise.all(
allTestData
.filter(([domain]) => {
Expand Down
4 changes: 3 additions & 1 deletion src/backend/lib/cache/RedisCacheAdaptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ export class RedisCacheAdaptor extends AbstractCacheService {
}

async persistData(key: string, data: unknown): Promise<void> {
await (await this.getRedisInstance()).set(key, JSON.stringify(data));
await (
await this.getRedisInstance()
).set(key, JSON.stringify(data), { EX: 60 * 60 }); // I hour
}

async clearItem(key: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export abstract class AbstractConfigDataPersistenceService<T> {
}

public async resetState(keyField: keyof T, data: T[]) {
await cacheService.purge();
await this.resetToEmpty();
await this.saveAllItems(keyField, data);
}
Expand Down
5 changes: 3 additions & 2 deletions src/frontend/_layouts/utils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { DataStateKeys } from "frontend/lib/data/types";
import { ColorSchemes, IThemeSettings } from "shared/types/ui";
import { AppConfigurationValueType } from "shared/configurations/constants";
import { ColorSchemes } from "shared/types/ui";

export const getThemePrimaryColor = (
theme: ColorSchemes,
themeColor: DataStateKeys<IThemeSettings>
themeColor: DataStateKeys<AppConfigurationValueType<"theme_color">>
) =>
theme === "dark" ? themeColor.data?.primaryDark : themeColor.data?.primary;
2 changes: 1 addition & 1 deletion src/frontend/components/SchemaForm/_RenderFormInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function RenderFormInput({
label,
required,
disabled,
placeholder,
placeholder: placeholder || label,
description,
...renderProps,
};
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/design-system/components/Form/FormInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ interface IFormInput extends ISharedFormInput {
}

export const FormInput: React.FC<IFormInput> = (formInput) => {
const { input, type, label, disabled, meta, ...rest } = formInput;
const { input, type, disabled, meta, placeholder, ...rest } = formInput;

return wrapLabelAndError(
<Input
Expand All @@ -17,7 +17,7 @@ export const FormInput: React.FC<IFormInput> = (formInput) => {
{...generateFormArias(meta)}
type={type}
id={formInput.input.name}
placeholder={label}
placeholder={placeholder}
disabled={disabled}
/>,
formInput
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const getNumberValue = (value: string | number | null, required: boolean) => {
};

export const FormNumberInput: React.FC<IFormNumberInput> = (formInput) => {
const { input, label, disabled, meta, allowNegative, required, sm } =
const { input, placeholder, disabled, meta, allowNegative, required, sm } =
formInput;
if (typeof input.value === "string") {
input.onChange(getNumberValue(input.value, !!required));
Expand All @@ -35,7 +35,7 @@ export const FormNumberInput: React.FC<IFormNumberInput> = (formInput) => {
onChange={(e) => {
input.onChange(getNumberValue(e.target.value, !!required));
}}
placeholder={label}
placeholder={placeholder}
type="number"
disabled={disabled}
/>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,6 @@ const Root = styled.div`
}
`;

interface IFormRichText extends ISharedFormInput {
nothingForNow?: string;
}

const modules = {
toolbar: [
[{ size: [] }, { font: [] }],
Expand All @@ -105,11 +101,12 @@ const modules = {
},
};

export const FormRichTextArea: React.FC<IFormRichText> = (formInput) => {
export const FormRichTextArea: React.FC<ISharedFormInput> = (formInput) => {
const {
input: { onFocus, onBlur, ...inputProps },
disabled,
meta,
placeholder,
} = formInput;
noop(onBlur, onFocus);
return wrapLabelAndError(
Expand All @@ -120,7 +117,7 @@ export const FormRichTextArea: React.FC<IFormRichText> = (formInput) => {
readOnly={disabled}
modules={modules}
id={formInput.input.name}
placeholder="Write something..."
placeholder={placeholder}
theme="snow"
/>
</Root>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export function AsyncFormSelect(props: IProps) {
label: formLabel,
disabledOptions = [],
nullable,
placeholder,
defaultLabel,
} = props;

Expand Down Expand Up @@ -108,6 +109,7 @@ export function AsyncFormSelect(props: IProps) {
classNamePrefix={SharedSelectProps.classNamePrefix}
isDisabled={disabled}
isLoading={isLoading}
placeholder={placeholder}
className={generateClassNames(meta)}
value={{ value: input.value, label: valueLabelToUse.value }}
loadOptions={(inputValue) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export const FormSelect: React.FC<IFormSelect> = (props) => {
disabledOptions,
nullable,
defaultLabel,
placeholder,
} = props;
const selectDataWithDefault = [
{
Expand All @@ -78,6 +79,7 @@ export const FormSelect: React.FC<IFormSelect> = (props) => {
label: "",
}
}
placeholder={placeholder}
inputId={input.name}
onChange={({ value }: any) => {
input.onChange(nullable && !value ? null : value);
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/design-system/components/Form/FormTextArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ interface IFormTextArea extends ISharedFormInput {
}

export const FormTextArea: React.FC<IFormTextArea> = (formInput) => {
const { input, rows = 3, label, disabled, meta } = formInput;
const { input, rows = 3, placeholder, disabled, meta } = formInput;
return wrapLabelAndError(
<TextArea
{...generateFormArias(meta)}
Expand All @@ -27,7 +27,7 @@ export const FormTextArea: React.FC<IFormTextArea> = (formInput) => {
onFocus={input.onFocus}
onBlur={input.onBlur}
rows={rows}
placeholder={label}
placeholder={placeholder}
disabled={disabled}
>
{input.value}
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/design-system/components/Tooltip/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function Tooltip({ children, text, place = "right", offset }: IProps) {
return (
<>
<span id={id}> {children} </span>
<BaseTooltip anchorId={id} content={text} place={place} offset={offset} />
<BaseTooltip anchorId={id} html={text} place={place} offset={offset} />
</>
);
}
7 changes: 5 additions & 2 deletions src/frontend/views/settings/Theme/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ import { IFormProps } from "frontend/lib/form/types";
import { SchemaForm } from "frontend/components/SchemaForm";
import { MAKE_APP_CONFIGURATION_CRUD_CONFIG } from "frontend/hooks/configuration/configuration.constant";
import { UPDATE_USER_PREFERENCES_FORM_SCHEMA } from "frontend/views/account/Preferences/constants";
import { ColorSchemes, IThemeSettings } from "shared/types/ui";
import { ColorSchemes } from "shared/types/ui";
import { AppConfigurationValueType } from "shared/configurations/constants";

type Settings = IThemeSettings & { theme: ColorSchemes };
type Settings = AppConfigurationValueType<"theme_color"> & {
theme: ColorSchemes;
};

const CRUD_CONFIG = MAKE_APP_CONFIGURATION_CRUD_CONFIG("theme_color");

Expand Down
4 changes: 2 additions & 2 deletions src/shared/configurations/constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IFileUploadSettings } from "shared/types/file";
import { IFieldValidationItem } from "shared/validations/types";
import { IColorableSelection, IThemeSettings } from "shared/types/ui";
import { IColorableSelection } from "shared/types/ui";
import { FIELD_TYPES_CONFIG_MAP } from "shared/validations";
import { ITableTab } from "shared/types/data";
import { BaseAppConfigurationKeys } from "./base-types";
Expand Down Expand Up @@ -156,7 +156,7 @@ export const APP_CONFIGURATION_CONFIG = {
defaultValue: {
primary: "#4b38b3",
primaryDark: "#8c68cd",
} as IThemeSettings,
},
},
site_settings: {
label: "Site Settings",
Expand Down
5 changes: 0 additions & 5 deletions src/shared/types/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ export const FOR_CODE_COV = 1;

export type ColorSchemes = "light" | "dark";

export type IThemeSettings = {
primary: string;
primaryDark: string;
};

export type GridSpanSizes = "1" | "2" | "3" | "4";

export type GridHeightSizes = "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8";

0 comments on commit d51b382

Please sign in to comment.