-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(iframe-plugin): wait to load plugins from cache to save network …
…[DHIS2-15097] (#2285) * feat(iframe-plugin): receive pwa installation status from plugins * chore: add todos * fix: wait to render until the first item of the type has gotten the plugin * fix: add property to the top-most item of each iframe plugin type * fix: dont use the <Layer> component * chore: cli-app-scripts upgrade * fix: remove unused var * refactor: combine loops --------- Co-authored-by: Jen Jones Arnesen <jennifer@dhis2.org>
- Loading branch information
1 parent
9ef65b4
commit a7368b1
Showing
13 changed files
with
261 additions
and
61 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { ADD_IFRAME_PLUGIN_STATUS } from '../reducers/iframePluginStatus.js' | ||
|
||
export const acAddIframePluginStatus = (value) => ({ | ||
type: ADD_IFRAME_PLUGIN_STATUS, | ||
value, | ||
}) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { getFirstOfTypes } from '../getFirstOfType.js' | ||
|
||
describe('getFirstOfTypes', () => { | ||
test('returns an empty array if no items are passed', () => { | ||
expect(getFirstOfTypes([])).toEqual([]) | ||
}) | ||
|
||
test('returns only ids for types in the array', () => { | ||
expect( | ||
getFirstOfTypes([ | ||
{ id: 'map2', type: 'MAP', x: 1, y: 1 }, | ||
{ id: 'map1', type: 'MAP', x: 2, y: 0 }, | ||
]) | ||
).toEqual(['map1']) | ||
}) | ||
|
||
test('returns first IDs for MAP, VISUALIZATION and EVENT_VISUALIZATION', () => { | ||
expect( | ||
getFirstOfTypes([ | ||
{ id: 'map2', type: 'MAP', x: 2, y: 2 }, | ||
{ id: 'map1', type: 'MAP', x: 1, y: 1 }, | ||
{ id: 'map0', type: 'MAP', x: 2, y: 0 }, | ||
{ id: 'vis1', type: 'CHART', x: 1, y: 1 }, | ||
{ id: 'vis0', type: 'REPORT_TABLE', x: 1, y: 0 }, | ||
{ id: 'vis2', type: 'VISUALIZATION', x: 2, y: 1 }, | ||
{ id: 'text1', type: 'TEXT', x: 0, y: 0 }, | ||
{ id: 'ev2', type: 'EVENT_VISUALIZATION', x: 0, y: 3 }, | ||
{ id: 'ev1', type: 'EVENT_VISUALIZATION', x: 1, y: 2 }, | ||
{ id: 'ev0', type: 'EVENT_VISUALIZATION', x: 0, y: 2 }, | ||
]) | ||
).toEqual(['map0', 'ev0', 'vis0']) | ||
}) | ||
}) |
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,31 @@ | ||
import sortBy from 'lodash/sortBy.js' | ||
import { | ||
MAP, | ||
VISUALIZATION, | ||
EVENT_VISUALIZATION, | ||
REPORT_TABLE, | ||
CHART, | ||
} from './itemTypes.js' | ||
|
||
export const getFirstOfTypes = (items) => { | ||
const firstOfTypes = {} | ||
|
||
firstOfTypes[MAP] = sortBy( | ||
items.filter((item) => item.type === MAP), | ||
['y', 'x'] | ||
)[0]?.id | ||
|
||
firstOfTypes[EVENT_VISUALIZATION] = sortBy( | ||
items.filter((item) => item.type === EVENT_VISUALIZATION), | ||
['y', 'x'] | ||
)[0]?.id | ||
|
||
firstOfTypes[VISUALIZATION] = sortBy( | ||
items.filter((item) => | ||
[VISUALIZATION, REPORT_TABLE, CHART].includes(item.type) | ||
), | ||
['y', 'x'] | ||
)[0]?.id | ||
|
||
return Object.values(firstOfTypes).filter((id) => id !== undefined) | ||
} |
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
Oops, something went wrong.