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

feat: dynamically register extension settings #2494

Merged
merged 18 commits into from
Mar 29, 2024
Merged

Conversation

namchuai
Copy link
Contributor

@namchuai namchuai commented Mar 25, 2024

Describe Your Changes

  • Extension can register its own settings.

Screenshots

Screenshot 2024-03-29 at 00 41 58

Self Checklist

  • Added relevant comments, esp in complex areas
  • Updated docs (for bug fixes / features)
  • Created issues for follow-up changes or refactoring needed

@namchuai namchuai force-pushed the feat/extension-setting branch from 8f4554d to 6e3d9a1 Compare March 27, 2024 02:36
@namchuai namchuai marked this pull request as ready for review March 27, 2024 02:37
@namchuai namchuai changed the title Feat/extension setting feat: dynamically register extension settings Mar 27, 2024
@namchuai namchuai force-pushed the feat/extension-setting branch 2 times, most recently from 36fd41a to e912297 Compare March 27, 2024 08:08
@louis-jan
Copy link
Contributor

louis-jan commented Mar 27, 2024

@namchuai. I've updated the Settings API as discussed

override async onLoad(): Promise<void> {
  super.onLoad()

  // Register Settings
  this.registerSettings(SETTINGS)

  // Retrieve API Key Setting
  this.apiKey = await this.getSetting<string>(this.settingName, 'default_value_here')
}

// Update extension logic once setting is updated
onSettingUpdate<T>(key: string, value: T): void {
  if (key === this.settingName) this.apiKey = value as string
}

@namchuai namchuai force-pushed the feat/extension-setting branch from 94dd684 to b002045 Compare March 28, 2024 07:04
James and others added 16 commits March 29, 2024 00:44
Signed-off-by: James <[email protected]>
Signed-off-by: James <[email protected]>
Signed-off-by: James <[email protected]>
Signed-off-by: James <[email protected]>
Signed-off-by: James <[email protected]>
Signed-off-by: James <[email protected]>
Signed-off-by: James <[email protected]>
Signed-off-by: James <[email protected]>
Signed-off-by: James <[email protected]>
Signed-off-by: James <[email protected]>
@namchuai namchuai force-pushed the feat/extension-setting branch from 08da8ff to 410749b Compare March 28, 2024 17:44
@louis-jan
Copy link
Contributor

Screenshot 2024-03-29 at 13 51 53 Screenshot 2024-03-29 at 13 52 04

@namchuai namchuai merged commit fa35aa6 into dev Mar 29, 2024
4 checks passed
@namchuai namchuai deleted the feat/extension-setting branch March 29, 2024 08:44
@github-actions github-actions bot added this to the v0.4.11 milestone Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants