-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(dashboard): toggle between view and edit mode (#609)
- Loading branch information
1 parent
da05cfc
commit 22a404a
Showing
12 changed files
with
229 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
packages/dashboard/src/store/actions/toggleReadOnly/index.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { toggleReadOnly } from '.'; | ||
import { DashboardState, initialState } from '../../state'; | ||
|
||
import { MOCK_KPI_WIDGET, MOCK_LINE_CHART_WIDGET } from '../../../../testing/mocks'; | ||
import { Widget } from '~/types'; | ||
|
||
const setupDashboardState = (widgets: Widget[] = [], pasteCounter = 0): DashboardState => ({ | ||
...initialState, | ||
dashboardConfiguration: { | ||
...initialState.dashboardConfiguration, | ||
widgets, | ||
}, | ||
pasteCounter, | ||
readOnly: false, | ||
}); | ||
|
||
it('can toggle the state if no widgets are present', () => { | ||
expect(toggleReadOnly(setupDashboardState([])).readOnly).toEqual(true); | ||
}); | ||
|
||
it('can toggle the state if widgets are present', () => { | ||
expect(toggleReadOnly(setupDashboardState([MOCK_KPI_WIDGET, MOCK_LINE_CHART_WIDGET])).readOnly).toEqual(true); | ||
}); | ||
|
||
it('can toggle the state back and forth', () => { | ||
expect( | ||
toggleReadOnly(toggleReadOnly(setupDashboardState([MOCK_KPI_WIDGET, MOCK_LINE_CHART_WIDGET]))).readOnly | ||
).toEqual(false); | ||
}); |
Oops, something went wrong.