-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhancement move transform and other registration to separate files
- Loading branch information
Christopher Joe
committed
Aug 8, 2017
1 parent
6fa1585
commit fbf2ace
Showing
8 changed files
with
76 additions
and
46 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import i18n from 'i18n'; | ||
import Injector from 'lib/Injector'; | ||
|
||
const insertTransform = form => { | ||
const schema = form.getState(); | ||
// todo remove this schemaName check when injector considers schemaName for selector | ||
const schemaName = schema.schema.name; | ||
if (schemaName !== 'fileInsertForm') { | ||
return schema; | ||
} | ||
const overrides = schema.stateOverride && schema.stateOverride.fields; | ||
const customTitle = (overrides && overrides.length > 0) | ||
? i18n._t('AssetAdmin.UPDATE_FILE', 'Update file') | ||
: i18n._t('AssetAdmin.INSERT_FILE', 'Insert file'); | ||
|
||
form.mutateField('action_insert', (field) => ({ | ||
...field, | ||
title: customTitle || field.title, | ||
})); | ||
|
||
return form.getState(); | ||
}; | ||
|
||
const applyTransform = () => { | ||
Injector.transform( | ||
'insert-media-modal', | ||
(updater) => { | ||
updater.form.alterSchema('AssetAdmin.EditForm', insertTransform); | ||
} | ||
); | ||
}; | ||
|
||
export default applyTransform; |
Oops, something went wrong.