Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define the type/schema that allows the settings for an application to be described, this will be used to generate a form to manage settings. #1363

Open
Tracked by #1362
heswell opened this issue May 24, 2024 · 0 comments
Assignees

Comments

@heswell
Copy link
Contributor

heswell commented May 24, 2024

Application settings are a collection of properties. To keep things simple to start, lets assume simple types. so

  • string
  • boolean
  • number

We need to define a schema that allows devs to define the properties available to an application. Application developers will include a (JSON) document that describes the application settings properties. This will be used to build a custom form that presents the properties to the user and allows them to update the properties. Lets assume three simple properties:

  • themeMode: "light", "dark"
  • region: "us", "emea", "apac"
  • dateDisplayFormat: "dd/mm/yyyy", "mm/dd/yyyy", ""dd MMMM yyyy"

Example of what a simple structure to capture these details shown below. We might need more information than this to allow us to support a better UX for users (eg help text, grouping, sub sections ?) but this set is a good start

{
   "properties": [
   {
      "name": "themeMode",
      "label": "Mode",
      "values": ["light","dark"],
      "defaultValue": "light",
      "type": "string"
   },
   {
      "name": "dataFormatPattern",
      "label": "Date Formatting",
      "values": ["dd/mm/yyyy", "mm/dd/yyyy", "dd MMMM yyyy"],
      "defaultValue": "dd/mm/yyyy",
      "type": "string"
   },
   {
      "name": "region",
      "label": "Region",
      "values": [{value: "us", label:"US"},{value: "apac", label: "Asia Pacific"},{value: "emea", label: "Europe, Middle East & Africa"}],
      "defaultValue": "light",
      "type": "string"
   }
]
}

and our TypeScript type to describe this structure would be something like

type SettingsProperty<T extends string | number | boolean = string> = {
name: string;
label: string;
values?: T[];
defaultValue: T;
type: 'string' | 'boolean' | 'number';
}

interface SettingsSchema {
properties: SettingsProperty[];
}

`` 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants