Mobile: Support description banners on plugin-registered settings screens (#10286)

pull/10317/head
Henry Heino 2024-04-15 10:18:22 -07:00 committed by GitHub
parent ff86c253d3
commit b638056150
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 42 additions and 4 deletions

View File

@ -575,6 +575,7 @@ packages/app-mobile/components/screens/ConfigScreen/NoteExportSection/utils/expo
packages/app-mobile/components/screens/ConfigScreen/NoteExportSection/utils/exportDebugReport.js
packages/app-mobile/components/screens/ConfigScreen/NoteExportSection/utils/exportProfile.js
packages/app-mobile/components/screens/ConfigScreen/NoteExportSection/utils/makeImportExportCacheDirectory.js
packages/app-mobile/components/screens/ConfigScreen/SectionDescription.js
packages/app-mobile/components/screens/ConfigScreen/SectionHeader.js
packages/app-mobile/components/screens/ConfigScreen/SectionSelector.js
packages/app-mobile/components/screens/ConfigScreen/SettingComponent.js

1
.gitignore vendored
View File

@ -555,6 +555,7 @@ packages/app-mobile/components/screens/ConfigScreen/NoteExportSection/utils/expo
packages/app-mobile/components/screens/ConfigScreen/NoteExportSection/utils/exportDebugReport.js
packages/app-mobile/components/screens/ConfigScreen/NoteExportSection/utils/exportProfile.js
packages/app-mobile/components/screens/ConfigScreen/NoteExportSection/utils/makeImportExportCacheDirectory.js
packages/app-mobile/components/screens/ConfigScreen/SectionDescription.js
packages/app-mobile/components/screens/ConfigScreen/SectionHeader.js
packages/app-mobile/components/screens/ConfigScreen/SectionSelector.js
packages/app-mobile/components/screens/ConfigScreen/SettingComponent.js

View File

@ -149,7 +149,7 @@ class ConfigScreenComponent extends React.Component<any, any> {
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
public renderSectionDescription(section: any) {
const description = Setting.sectionDescription(section.name);
const description = Setting.sectionDescription(section.name, AppType.Desktop);
if (!description) return null;
const theme = themeStyle(this.props.themeId);

View File

@ -32,6 +32,7 @@ import PluginService, { PluginSettings } from '@joplin/lib/services/plugins/Plug
import PluginStates, { getSearchText as getPluginStatesSearchText } from './plugins/PluginStates';
import PluginUploadButton, { canInstallPluginsFromFile, buttonLabel as pluginUploadButtonSearchText } from './plugins/PluginUploadButton';
import NoteImportButton, { importButtonDefaultTitle, importButtonDescription } from './NoteExportSection/NoteImportButton';
import SectionDescription from './SectionDescription';
interface ConfigScreenState {
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
@ -354,6 +355,15 @@ class ConfigScreenComponent extends BaseScreenComponent<ConfigScreenProps, Confi
const advancedSettingComps: ReactElement[] = [];
const headerTitle = Setting.sectionNameToLabel(section.name);
const sectionDescription = Setting.sectionDescription(key, AppType.Mobile);
if (sectionDescription && !this.state.searching) {
settingComps.push(
<SectionDescription
key='section-description'
content={sectionDescription}
/>,
);
}
const matchesSearchQuery = (relatedText: string|string[]) => {
let searchThrough;

View File

@ -0,0 +1,22 @@
import * as React from 'react';
import { ViewStyle } from 'react-native';
import { Banner } from 'react-native-paper';
interface Props {
content: string;
}
const style: ViewStyle = { marginBottom: 10 };
const SectionDescription: React.FC<Props> = props => {
return (
<Banner
visible={true}
icon='information'
style={style}
>
{props.content}
</Banner>
);
};
export default SectionDescription;

View File

@ -2784,9 +2784,13 @@ class Setting extends BaseModel {
return name;
}
public static sectionDescription(name: string) {
if (name === 'markdownPlugins') return _('These plugins enhance the Markdown renderer with additional features. Please note that, while these features might be useful, they are not standard Markdown and thus most of them will only work in Joplin. Additionally, some of them are *incompatible* with the WYSIWYG editor. If you open a note that uses one of these plugins in that editor, you will lose the plugin formatting. It is indicated below which plugins are compatible or not with the WYSIWYG editor.');
if (name === 'general') return _('Notes and settings are stored in: %s', toSystemSlashes(this.value('profileDir'), process.platform));
public static sectionDescription(name: string, appType: AppType) {
if (name === 'markdownPlugins' && appType === AppType.Desktop) {
return _('These plugins enhance the Markdown renderer with additional features. Please note that, while these features might be useful, they are not standard Markdown and thus most of them will only work in Joplin. Additionally, some of them are *incompatible* with the WYSIWYG editor. If you open a note that uses one of these plugins in that editor, you will lose the plugin formatting. It is indicated below which plugins are compatible or not with the WYSIWYG editor.');
}
if (name === 'general' && appType === AppType.Desktop) {
return _('Notes and settings are stored in: %s', toSystemSlashes(this.value('profileDir'), process.platform));
}
if (this.customSections_[name] && this.customSections_[name].description) return this.customSections_[name].description;