Fix parsing and wrapping tuple values in Args setting inside Pleroma.Upload.Filter.Mogrify

This commit is contained in:
Angelina Filippova 2020-08-03 22:31:53 +03:00
parent 659adbe6d7
commit 8e1825ae1a
2 changed files with 6 additions and 16 deletions

View file

@ -50,12 +50,7 @@ export const parseNonTuples = (key, value) => {
return updated return updated
} }
if (key === ':args') { if (key === ':args') {
if (typeof value === 'string') { return typeof value === 'string' ? [value] : value
return [value]
}
const index = value.findIndex(el => typeof el === 'object' && el.tuple.includes('implode'))
const updated = value.map((el, i) => i === index ? 'implode' : el)
return updated
} }
return value return value
} }
@ -259,13 +254,6 @@ const wrapValues = (settings, currentState) => {
} else if (setting === ':ip') { } else if (setting === ':ip') {
const ip = value.split('.').map(s => parseInt(s, 10)) const ip = value.split('.').map(s => parseInt(s, 10))
return { 'tuple': [setting, { 'tuple': ip }] } return { 'tuple': [setting, { 'tuple': ip }] }
} else if (setting === ':args') {
const index = value.findIndex(el => el === 'implode')
const updatedArray = value.slice()
if (index !== -1) {
updatedArray[index] = { 'tuple': ['implode', '1'] }
}
return { 'tuple': [setting, updatedArray] }
} else { } else {
return { 'tuple': [setting, value] } return { 'tuple': [setting, value] }
} }

View file

@ -20,9 +20,11 @@
allow-create allow-create
class="input" class="input"
@change="updateSetting($event, settingGroup.group, settingGroup.key, setting.key, setting.type)"> @change="updateSetting($event, settingGroup.group, settingGroup.key, setting.key, setting.type)">
<el-option value="strip" label="strip"/> <el-option value="strip"/>
<el-option value="auto-orient" label="auto-orient"/> <el-option value="auto-orient"/>
<el-option value="implode" label="implode"/> <!-- eslint-disable -->
<el-option value='{"implode", "1"}'/>
<!-- eslint-enable -->
</el-select> </el-select>
</div> </div>
</template> </template>