-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathload-actions.ts
79 lines (67 loc) · 2.27 KB
/
load-actions.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// SPDX-FileCopyrightText: Meta Platforms, Inc. and its affiliates
// SPDX-FileCopyrightText: TNG Technology Consulting GmbH <https://www.tngtech.com>
//
// SPDX-License-Identifier: Apache-2.0
import { ParsedFileContent } from '../../../../shared/shared-types';
import { AppThunkAction } from '../../types';
import {
setAttributionBreakpoints,
setBaseUrlsForSources,
setConfig,
setExternalAttributionSources,
setExternalData,
setFilesWithChildren,
setFrequentLicenses,
setIsPreferenceFeatureEnabled,
setManualData,
setProjectMetadata,
setResources,
} from './all-views-simple-actions';
import { setResolvedExternalAttributions } from './audit-view-simple-actions';
export function loadFromFile(
parsedFileContent: ParsedFileContent,
): AppThunkAction {
return (dispatch) => {
dispatch(setResources(parsedFileContent.resources));
dispatch(setConfig(parsedFileContent.config));
dispatch(
setManualData(
parsedFileContent.manualAttributions.attributions,
parsedFileContent.manualAttributions.resourcesToAttributions,
parsedFileContent.manualAttributions.attributionsToResources,
),
);
dispatch(
setExternalData(
parsedFileContent.externalAttributions.attributions,
parsedFileContent.externalAttributions.resourcesToAttributions,
parsedFileContent.externalAttributions.attributionsToResources,
parsedFileContent.resolvedExternalAttributions,
),
);
dispatch(
setResolvedExternalAttributions(
parsedFileContent.resolvedExternalAttributions,
),
);
dispatch(setFrequentLicenses(parsedFileContent.frequentLicenses));
dispatch(
setAttributionBreakpoints(parsedFileContent.attributionBreakpoints),
);
dispatch(setFilesWithChildren(parsedFileContent.filesWithChildren));
dispatch(setProjectMetadata(parsedFileContent.metadata));
dispatch(setBaseUrlsForSources(parsedFileContent.baseUrlsForSources));
dispatch(
setExternalAttributionSources(
parsedFileContent.externalAttributionSources,
),
);
dispatch(
setIsPreferenceFeatureEnabled(
Object.values(parsedFileContent.externalAttributionSources).some(
(source) => source.isRelevantForPreferred,
),
),
);
};
}