generated from flotiq/flotiq-ui-plugin-templates-plain-js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f52c37d
commit 7a2778b
Showing
9 changed files
with
62 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export const parsePluginSettings = (settings) => { | ||
const parsedSettings = JSON.parse(settings || '{}'); | ||
|
||
return (parsedSettings?.surferSeoAnalyzer || []).reduce( | ||
(settings, element) => { | ||
settings[element.content_type] = element; | ||
return settings; | ||
}, | ||
{}, | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,41 @@ | ||
import { getCachedElement } from '../../common/plugin-element-cache.js'; | ||
import { getValidFields, validFieldsCacheKey } from '../common/valid-fields'; | ||
import { | ||
addObjectToCache, | ||
getCachedElement, | ||
} from '../../common/plugin-element-cache.js'; | ||
import { | ||
getValidFields, | ||
validFieldsCacheKey, | ||
} from '../../common/valid-fields.js'; | ||
import pluginInfo from '../../plugin-manifest.json'; | ||
import { addObjectToCache, removeRoot } from '../common/plugin-helpers.js'; | ||
import { getSchema, getValidator } from './settings-schema.js'; | ||
|
||
export const handleManagePlugin = ({ contentTypes, modalInstance }) => { | ||
const formSchemaCacheKey = `${pluginInfo.id}-form-schema`; | ||
let formSchema = getCachedElement(formSchemaCacheKey); | ||
let configCache = null; | ||
|
||
if (!formSchema) { | ||
const validFields = getValidFields(contentTypes); | ||
addObjectToCache(validFieldsCacheKey, validFields); | ||
export const handleManagePlugin = ({ plugin, contentTypes, modalInstance }) => { | ||
if (plugin?.id !== pluginInfo.id) return null; | ||
|
||
const ctds = contentTypes | ||
?.filter(({ internal }) => !internal) | ||
?.map(({ name, label }) => ({ value: name, label })); | ||
if (configCache) return configCache; | ||
|
||
const { sourceFieldsKeys } = validFields; | ||
const validFields = getValidFields(contentTypes); | ||
addObjectToCache(validFieldsCacheKey, validFields); | ||
|
||
formSchema = { | ||
options: { | ||
disbaledBuildInValidation: true, | ||
onValidate: getValidator(sourceFieldsKeys), | ||
}, | ||
schema: getSchema(ctds), | ||
}; | ||
} | ||
const ctds = contentTypes | ||
?.filter(({ internal }) => !internal) | ||
?.map(({ name, label }) => ({ value: name, label })); | ||
|
||
modalInstance.promise.then(() => removeRoot(formSchemaCacheKey)); | ||
const { sourceFieldsKeys } = validFields; | ||
|
||
return formSchema; | ||
configCache = {}; | ||
|
||
configCache = { | ||
options: { | ||
disbaledBuildInValidation: true, | ||
onValidate: getValidator(sourceFieldsKeys), | ||
}, | ||
schema: getSchema(ctds), | ||
}; | ||
|
||
modalInstance.promise.then(() => (configCache = null)); | ||
|
||
return configCache; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters