From b7d75f9c70007d105ca5475f639e61f8e45ebe0d Mon Sep 17 00:00:00 2001 From: Felix Kling Date: Sun, 29 Jan 2017 20:27:43 -0800 Subject: [PATCH] Allows enable save button for new snippets ... and when the parser changes --- website/src/store/selectors.js | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/website/src/store/selectors.js b/website/src/store/selectors.js index e00e8b23..54c90cfa 100644 --- a/website/src/store/selectors.js +++ b/website/src/store/selectors.js @@ -93,8 +93,11 @@ export const canFork = createSelector( ); const canSaveCode = createSelector( - [isCodeDirty], - dirty => dirty + [getRevision, isCodeDirty], + (revision, dirty) => ( + !revision || // can always save if there is no revision + dirty + ) ); export const canSaveTransform = createSelector( @@ -103,12 +106,17 @@ export const canSaveTransform = createSelector( ); const didParserSettingsChange = createSelector( - [getParserSettings, getRevision], - (parserSettings, revision) => { + [getParserSettings, getRevision, getParser], + (parserSettings, revision, parser) => { const savedParserSettings = revision && revision.getParserSettings(); - return !!revision && - !!savedParserSettings && - !isEqual(parserSettings, savedParserSettings); + return ( + !!revision && + ( + parser.id !== revision.getParserID() || + !!savedParserSettings && !isEqual(parserSettings, savedParserSettings) + ) + ) + } );