show deprecation message as toast
This commit is contained in:
parent
79b547bfe4
commit
b28d78ccc7
6 changed files with 58 additions and 18 deletions
|
|
@ -394,25 +394,48 @@ async function configYamlToContinueConfig(options: {
|
|||
({ description: { title } }) => title,
|
||||
);
|
||||
|
||||
continueConfig.contextProviders = (config.context
|
||||
?.map((context) => {
|
||||
const cls = contextProviderClassFromName(context.provider) as any;
|
||||
if (!cls) {
|
||||
if (!DEFAULT_CONTEXT_PROVIDERS_TITLES.includes(context.provider)) {
|
||||
localErrors.push({
|
||||
fatal: false,
|
||||
message: `Unknown context provider ${context.provider}`,
|
||||
});
|
||||
const globalContext = new GlobalContext();
|
||||
|
||||
continueConfig.contextProviders =
|
||||
config.context
|
||||
?.map((context) => {
|
||||
const cls = contextProviderClassFromName(context.provider) as any;
|
||||
if (!cls) {
|
||||
if (!DEFAULT_CONTEXT_PROVIDERS_TITLES.includes(context.provider)) {
|
||||
localErrors.push({
|
||||
fatal: false,
|
||||
message: `Unknown context provider ${context.provider}`,
|
||||
});
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
const instance: IContextProvider = new cls({
|
||||
name: context.name,
|
||||
...context.params,
|
||||
});
|
||||
return instance;
|
||||
})
|
||||
.filter((p) => !!p) ?? []) as IContextProvider[];
|
||||
const instance: IContextProvider = new cls({
|
||||
name: context.name,
|
||||
...context.params,
|
||||
});
|
||||
return instance;
|
||||
})
|
||||
.filter((p) => !!p)
|
||||
.filter((p) => {
|
||||
if (p.isDeprecated()) {
|
||||
const providerTitle = p.description.title;
|
||||
const shownWarnings =
|
||||
globalContext.get("shownDeprecatedProviderWarnings") ?? {};
|
||||
if (!shownWarnings[providerTitle]) {
|
||||
ide.showToast(
|
||||
"warning",
|
||||
`Context provider ${providerTitle} is deprecated and will be removed in a future version.`,
|
||||
);
|
||||
globalContext.update("shownDeprecatedProviderWarnings", {
|
||||
...shownWarnings,
|
||||
[providerTitle]: true,
|
||||
});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}) ?? [];
|
||||
|
||||
continueConfig.contextProviders.push(...DEFAULT_CONTEXT_PROVIDERS);
|
||||
|
||||
if (
|
||||
|
|
|
|||
|
|
@ -31,4 +31,8 @@ export abstract class BaseContextProvider implements IContextProvider {
|
|||
): Promise<ContextSubmenuItem[]> {
|
||||
return [];
|
||||
}
|
||||
|
||||
isDeprecated(): boolean {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,10 @@ class CustomContextProviderClass implements IContextProvider {
|
|||
async loadSubmenuItems(args: LoadSubmenuItemsArgs) {
|
||||
return this.custom.loadSubmenuItems?.(args) ?? [];
|
||||
}
|
||||
|
||||
isDeprecated() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export default CustomContextProviderClass;
|
||||
|
|
|
|||
|
|
@ -132,6 +132,10 @@ LIMIT ${sampleRows}`);
|
|||
throw new Error(`Failed to query PostgreSQL database: ${error}`);
|
||||
}
|
||||
}
|
||||
|
||||
isDeprecated() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
export default PostgresContextProvider;
|
||||
|
|
|
|||
2
core/index.d.ts
vendored
2
core/index.d.ts
vendored
|
|
@ -256,6 +256,8 @@ export interface IContextProvider {
|
|||
): Promise<ContextItem[]>;
|
||||
|
||||
loadSubmenuItems(args: LoadSubmenuItemsArgs): Promise<ContextSubmenuItem[]>;
|
||||
|
||||
isDeprecated(): boolean;
|
||||
}
|
||||
|
||||
export interface Session {
|
||||
|
|
|
|||
|
|
@ -39,6 +39,9 @@ export type GlobalContextType = {
|
|||
isSupportedLanceDbCpuTargetForLinux: boolean;
|
||||
sharedConfig: SharedConfigSchema;
|
||||
failedDocs: SiteIndexingConfig[];
|
||||
shownDeprecatedProviderWarnings: {
|
||||
[providerTitle: string]: boolean;
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue