Skip to content

Commit

Permalink
Allows enable save button for new snippets
Browse files Browse the repository at this point in the history
... and when the parser changes
  • Loading branch information
fkling committed Jan 30, 2017
1 parent 11f91f9 commit b7d75f9
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions website/src/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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)
)
)

}
);

Expand Down

0 comments on commit b7d75f9

Please sign in to comment.