bunkerweb / bunker

Secure student environment
2 stars 4 forks source link

Expose user editable settings on the Settings page via the SDK #9

Open proudparrot2 opened 3 months ago

proudparrot2 commented 3 months ago

In the SDK, developers will be able to expose and bind config options as user-editable settings in the Settings page. They'll be able to choose the field name, description, and type of input (text, check, select). This will directly set the configuration value for the key they choose to the data the user inputs.

const plugin = {
  onReady(sdk) {
    sdk.exposeSetting({
      bind: "name",
      title: "Name",
      description: "Enter your name",
      type: "text",
    })
  },

  tile(sdk) {
    return <p>{sdk.config.get("name")}</p>
  }
}
interface ExposeSettingProps {
  key: string
  data: {
    title: string
    description?: string,
    type: "text" | "select" | "checkbox",
    options?: { // for type "select"
      title: string
      value: string
    }[]
  }
}

}