diff options
Diffstat (limited to 'src/components/settings/services/EditServiceForm.js')
-rw-r--r-- | src/components/settings/services/EditServiceForm.js | 67 |
1 files changed, 44 insertions, 23 deletions
diff --git a/src/components/settings/services/EditServiceForm.js b/src/components/settings/services/EditServiceForm.js index fa34ac60b..98051d78f 100644 --- a/src/components/settings/services/EditServiceForm.js +++ b/src/components/settings/services/EditServiceForm.js | |||
@@ -33,6 +33,18 @@ const messages = defineMessages({ | |||
33 | id: 'settings.service.form.openDarkmodeCss', | 33 | id: 'settings.service.form.openDarkmodeCss', |
34 | defaultMessage: '!!!Open darkmode.css', | 34 | defaultMessage: '!!!Open darkmode.css', |
35 | }, | 35 | }, |
36 | openUserCss: { | ||
37 | id: 'settings.service.form.openUserCss', | ||
38 | defaultMessage: '!!!Open user.css', | ||
39 | }, | ||
40 | openUserJs: { | ||
41 | id: 'settings.service.form.openUserJs', | ||
42 | defaultMessage: '!!!Open user.js', | ||
43 | }, | ||
44 | recipeFileInfo: { | ||
45 | id: 'settings.service.form.recipeFileInfo', | ||
46 | defaultMessage: '!!!Your user files will be inserted into the webpage so you can customize services in any way you like. User files are only stored locally and are not transferred to other computers using the same account.', | ||
47 | }, | ||
36 | availableServices: { | 48 | availableServices: { |
37 | id: 'settings.service.form.availableServices', | 49 | id: 'settings.service.form.availableServices', |
38 | defaultMessage: '!!!Available services', | 50 | defaultMessage: '!!!Available services', |
@@ -131,8 +143,7 @@ export default @observer class EditServiceForm extends Component { | |||
131 | form: PropTypes.instanceOf(Form).isRequired, | 143 | form: PropTypes.instanceOf(Form).isRequired, |
132 | onSubmit: PropTypes.func.isRequired, | 144 | onSubmit: PropTypes.func.isRequired, |
133 | onDelete: PropTypes.func.isRequired, | 145 | onDelete: PropTypes.func.isRequired, |
134 | openDarkmodeCss: PropTypes.func.isRequired, | 146 | openRecipeFile: PropTypes.func.isRequired, |
135 | isOpeningDarkModeCss: PropTypes.bool.isRequired, | ||
136 | isSaving: PropTypes.bool.isRequired, | 147 | isSaving: PropTypes.bool.isRequired, |
137 | isDeleting: PropTypes.bool.isRequired, | 148 | isDeleting: PropTypes.bool.isRequired, |
138 | isProxyFeatureEnabled: PropTypes.bool.isRequired, | 149 | isProxyFeatureEnabled: PropTypes.bool.isRequired, |
@@ -169,7 +180,7 @@ export default @observer class EditServiceForm extends Component { | |||
169 | if (recipe.validateUrl && values.customUrl) { | 180 | if (recipe.validateUrl && values.customUrl) { |
170 | this.setState({ isValidatingCustomUrl: true }); | 181 | this.setState({ isValidatingCustomUrl: true }); |
171 | try { | 182 | try { |
172 | values.customUrl = normalizeUrl(values.customUrl, { stripWWW: false }); | 183 | values.customUrl = normalizeUrl(values.customUrl, { stripWWW: false, removeTrailingSlash: false }); |
173 | isValid = await recipe.validateUrl(values.customUrl); | 184 | isValid = await recipe.validateUrl(values.customUrl); |
174 | } catch (err) { | 185 | } catch (err) { |
175 | console.warn('ValidateURL', err); | 186 | console.warn('ValidateURL', err); |
@@ -199,8 +210,7 @@ export default @observer class EditServiceForm extends Component { | |||
199 | isSaving, | 210 | isSaving, |
200 | isDeleting, | 211 | isDeleting, |
201 | onDelete, | 212 | onDelete, |
202 | openDarkmodeCss, | 213 | openRecipeFile, |
203 | isOpeningDarkModeCss, | ||
204 | isProxyFeatureEnabled, | 214 | isProxyFeatureEnabled, |
205 | isServiceProxyIncludedInCurrentPlan, | 215 | isServiceProxyIncludedInCurrentPlan, |
206 | isSpellcheckerIncludedInCurrentPlan, | 216 | isSpellcheckerIncludedInCurrentPlan, |
@@ -226,23 +236,6 @@ export default @observer class EditServiceForm extends Component { | |||
226 | /> | 236 | /> |
227 | ); | 237 | ); |
228 | 238 | ||
229 | const openDarkmodeCssButton = isOpeningDarkModeCss ? ( | ||
230 | <Button | ||
231 | label={intl.formatMessage(messages.openDarkmodeCss)} | ||
232 | loaded={false} | ||
233 | buttonType="secondary" | ||
234 | className="settings__open-dark-mode-button" | ||
235 | disabled | ||
236 | /> | ||
237 | ) : ( | ||
238 | <Button | ||
239 | buttonType="secondary" | ||
240 | label={intl.formatMessage(messages.openDarkmodeCss)} | ||
241 | className="settings__open-dark-mode-button" | ||
242 | onClick={openDarkmodeCss} | ||
243 | /> | ||
244 | ); | ||
245 | |||
246 | let activeTabIndex = 0; | 239 | let activeTabIndex = 0; |
247 | if (recipe.hasHostedOption && service.team) { | 240 | if (recipe.hasHostedOption && service.team) { |
248 | activeTabIndex = 1; | 241 | activeTabIndex = 1; |
@@ -430,11 +423,39 @@ export default @observer class EditServiceForm extends Component { | |||
430 | </PremiumFeatureContainer> | 423 | </PremiumFeatureContainer> |
431 | )} | 424 | )} |
432 | </form> | 425 | </form> |
426 | |||
427 | {action === 'edit' && ( | ||
428 | <> | ||
429 | <div className="settings__open-recipe-file-container"> | ||
430 | <Button | ||
431 | buttonType="secondary" | ||
432 | label={intl.formatMessage(messages.openDarkmodeCss)} | ||
433 | className="settings__open-recipe-file-button" | ||
434 | onClick={() => openRecipeFile('darkmode.css')} | ||
435 | /> | ||
436 | <Button | ||
437 | buttonType="secondary" | ||
438 | label={intl.formatMessage(messages.openUserCss)} | ||
439 | className="settings__open-recipe-file-button" | ||
440 | onClick={() => openRecipeFile('user.css')} | ||
441 | /> | ||
442 | <Button | ||
443 | buttonType="secondary" | ||
444 | label={intl.formatMessage(messages.openUserJs)} | ||
445 | className="settings__open-recipe-file-button" | ||
446 | onClick={() => openRecipeFile('user.js')} | ||
447 | /> | ||
448 | </div> | ||
449 | <p style={{ marginTop: 10 }}> | ||
450 | <span className="mdi mdi-information" /> | ||
451 | {intl.formatMessage(messages.recipeFileInfo)} | ||
452 | </p> | ||
453 | </> | ||
454 | )} | ||
433 | </div> | 455 | </div> |
434 | <div className="settings__controls"> | 456 | <div className="settings__controls"> |
435 | {/* Delete Button */} | 457 | {/* Delete Button */} |
436 | {action === 'edit' && deleteButton} | 458 | {action === 'edit' && deleteButton} |
437 | {action === 'edit' && openDarkmodeCssButton} | ||
438 | 459 | ||
439 | {/* Save Button */} | 460 | {/* Save Button */} |
440 | {isSaving || isValidatingCustomUrl ? ( | 461 | {isSaving || isValidatingCustomUrl ? ( |