diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml index 3701c2c34f..8226688fe9 100644 --- a/.github/workflows/cypress.yml +++ b/.github/workflows/cypress.yml @@ -21,7 +21,7 @@ jobs: if: "!contains(github.event.head_commit.message, '[skip ci]')" strategy: matrix: - containers: [1, 2, 3] + containers: [1, 2] #, 3] steps: - name: Checkout diff --git a/cypress/integration/save.cy.js b/cypress/integration/save.cy.js index 65b0a555a0..31aa417857 100644 --- a/cypress/integration/save.cy.js +++ b/cypress/integration/save.cy.js @@ -64,6 +64,11 @@ describe('saving an AO', () => { it('navigates to the start page', () => { goToStartPage() }) + it('checks that Save is disabled', () => { + clickMenuBarFileButton() + expectFileMenuButtonToBeDisabled(FILE_MENU_BUTTON_SAVE_EXISTING) + closeFileMenuWithClick() + }) it(`changes vis type to ${TEST_VIS_TYPE_NAME}`, () => { changeVisType(TEST_VIS_TYPE_NAME) }) @@ -90,6 +95,11 @@ describe('saving an AO', () => { expectAOTitleToBeUnsaved() expectRouteToBeEmpty() }) + it('checks that Save is enabled', () => { + clickMenuBarFileButton() + expectFileMenuButtonToBeEnabled(FILE_MENU_BUTTON_SAVE_EXISTING) + closeFileMenuWithClick() + }) it('checks that Save as is disabled', () => { clickMenuBarFileButton() expectFileMenuButtonToBeDisabled(FILE_MENU_BUTTON_SAVEAS) @@ -103,12 +113,11 @@ describe('saving an AO', () => { it('checks that the url was changed', () => { expectRouteToBeAOId() }) - it('all File menu buttons are enabled', () => { + it('all File menu buttons but Save are enabled', () => { clickMenuBarFileButton() const enabledButtons = [ FILE_MENU_BUTTON_NEW, FILE_MENU_BUTTON_OPEN, - FILE_MENU_BUTTON_SAVE_EXISTING, FILE_MENU_BUTTON_SAVEAS, FILE_MENU_BUTTON_RENAME, FILE_MENU_BUTTON_TRANSLATE, diff --git a/cypress/integration/start.cy.js b/cypress/integration/start.cy.js index f546d27c34..058ea1b97f 100644 --- a/cypress/integration/start.cy.js +++ b/cypress/integration/start.cy.js @@ -13,7 +13,6 @@ import { expectFileMenuButtonToBeDisabled, FILE_MENU_BUTTON_NEW, FILE_MENU_BUTTON_OPEN, - FILE_MENU_BUTTON_SAVE_NEW, FILE_MENU_BUTTON_SAVEAS, FILE_MENU_BUTTON_GETLINK, FILE_MENU_BUTTON_SHARE, @@ -75,11 +74,7 @@ describe('viewing the start screen', () => { }) it('primary File menu buttons are enabled and menu is closed with click', () => { clickMenuBarFileButton() - const enabledButtons = [ - FILE_MENU_BUTTON_NEW, - FILE_MENU_BUTTON_OPEN, - FILE_MENU_BUTTON_SAVE_NEW, - ] + const enabledButtons = [FILE_MENU_BUTTON_NEW, FILE_MENU_BUTTON_OPEN] enabledButtons.forEach((button) => expectFileMenuButtonToBeEnabled(button) ) diff --git a/packages/app/package.json b/packages/app/package.json index 74d3332e63..17eaa69c4a 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -13,7 +13,7 @@ "redux-mock-store": "^1.5.4" }, "dependencies": { - "@dhis2/analytics": "^21.9.1", + "@dhis2/analytics": "^21.10.0", "@dhis2/app-runtime": "^3.2.0", "@dhis2/app-runtime-adapter-d2": "^1.1.0", "@dhis2/d2-i18n": "^1.1.0", diff --git a/packages/app/src/components/MenuBar/MenuBar.js b/packages/app/src/components/MenuBar/MenuBar.js index bad90a8af2..a94855ac32 100644 --- a/packages/app/src/components/MenuBar/MenuBar.js +++ b/packages/app/src/components/MenuBar/MenuBar.js @@ -6,7 +6,13 @@ import { connect } from 'react-redux' import * as fromActions from '../../actions/index.js' import { getErrorVariantByStatusCode } from '../../modules/error.js' import history from '../../modules/history.js' +import { + getVisualizationState, + STATE_UNSAVED, + STATE_DIRTY, +} from '../../modules/visualization.js' import { sGetCurrent } from '../../reducers/current.js' +import { sGetVisualization } from '../../reducers/visualization.js' import { DownloadMenu } from '../DownloadMenu/DownloadMenu.js' import { InterpretationsButton } from '../Interpretations/InterpretationsButton.js' import UpdateButton from '../UpdateButton/UpdateButton.js' @@ -56,7 +62,13 @@ const UnconnectedMenuBar = ({ dataTest, ...props }, context) => ( onOpen={onOpen} onNew={onNew} onRename={getOnRename(props)} - onSave={getOnSave(props)} + onSave={ + [STATE_UNSAVED, STATE_DIRTY].includes( + getVisualizationState(props.visualization, props.current) + ) + ? getOnSave(props) + : undefined + } onSaveAs={getOnSaveAs(props)} onDelete={getOnDelete(props)} onError={getOnError(props)} @@ -72,6 +84,7 @@ UnconnectedMenuBar.propTypes = { apiObjectName: PropTypes.string, current: PropTypes.object, dataTest: PropTypes.string, + visualization: PropTypes.object, } UnconnectedMenuBar.contextTypes = { @@ -80,6 +93,7 @@ UnconnectedMenuBar.contextTypes = { const mapStateToProps = (state) => ({ current: sGetCurrent(state), + visualization: sGetVisualization(state), }) const mapDispatchToProps = (dispatch) => ({ diff --git a/packages/plugin/package.json b/packages/plugin/package.json index 36300f2012..69317e0e61 100644 --- a/packages/plugin/package.json +++ b/packages/plugin/package.json @@ -14,7 +14,7 @@ "access": "public" }, "dependencies": { - "@dhis2/analytics": "^21.9.1", + "@dhis2/analytics": "^21.10.0", "@dhis2/app-runtime": "^3.2.0", "@dhis2/d2-i18n": "^1.1.0", "@dhis2/ui": "^7.7.3", diff --git a/yarn.lock b/yarn.lock index 85e94a7080..f5a7ca707e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2174,10 +2174,10 @@ classnames "^2.3.1" prop-types "^15.7.2" -"@dhis2/analytics@^21.9.1": - version "21.9.1" - resolved "https://registry.yarnpkg.com/@dhis2/analytics/-/analytics-21.9.1.tgz#8ed76ac090cd3215885591813ccbbe8b18d1b402" - integrity sha512-klH32VRLefd2X9KdsbzQJxhKHeMidwv2MSVb24vHUySmiBZ6JBeS7ZsxTQhudQEa6abYLEtpgENljKAtcJ8lxA== +"@dhis2/analytics@^21.10.0": + version "21.10.0" + resolved "https://registry.yarnpkg.com/@dhis2/analytics/-/analytics-21.10.0.tgz#20d52de8424ba718331959e7b079ee146a65a07f" + integrity sha512-7KykxMxOsxI3c5pKqzDDRxsJxAZ+x44/MoOQnjGodKN9fItKPj/r35DuMyS9KH78IUc5MFNK7nzO001J8oylsQ== dependencies: "@dhis2/d2-ui-translation-dialog" "^7.3.1" "@dhis2/multi-calendar-dates" "1.0.0"