@axinom/mosaic-fe-samples-host 0.14.0-rc.7 → 0.15.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Profiles/Profiles.d.ts.map +1 -1
- package/dist/index.es.js +67 -2
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +67 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/Profiles/Profiles.tsx +106 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Profiles.d.ts","sourceRoot":"","sources":["../../src/Profiles/Profiles.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AACnD,OAAO,EAGL,mBAAmB,EAGpB,MAAM,kBAAkB,CAAC;AAqB1B,UAAU,WAAW;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,YAAa,SAAQ,mBAAmB,CAAC,WAAW,CAAC;CAAG;AAElE,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,
|
|
1
|
+
{"version":3,"file":"Profiles.d.ts","sourceRoot":"","sources":["../../src/Profiles/Profiles.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AACnD,OAAO,EAGL,mBAAmB,EAGpB,MAAM,kBAAkB,CAAC;AAqB1B,UAAU,WAAW;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,YAAa,SAAQ,mBAAmB,CAAC,WAAW,CAAC;CAAG;AAElE,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAwb3C,CAAC"}
|
package/dist/index.es.js
CHANGED
|
@@ -586,6 +586,68 @@ const Profiles = ({ match }) => {
|
|
|
586
586
|
history.replace(`/profiles`);
|
|
587
587
|
}
|
|
588
588
|
};
|
|
589
|
+
const handleExportProfileClick = () => {
|
|
590
|
+
const activeProfileIndex = profiles.findIndex((env) => env.id === (selectedProfile === null || selectedProfile === void 0 ? void 0 : selectedProfile.id));
|
|
591
|
+
if (activeProfileIndex !== -1 && selectedProfile !== undefined) {
|
|
592
|
+
const fileDownloadLink = document.createElement('a');
|
|
593
|
+
fileDownloadLink.href = URL.createObjectURL(new Blob([JSON.stringify(selectedProfile, null, 2)], {
|
|
594
|
+
type: 'application/json',
|
|
595
|
+
}));
|
|
596
|
+
fileDownloadLink.setAttribute('download', `fe-samples-${selectedProfile.name}.json`);
|
|
597
|
+
document.body.appendChild(fileDownloadLink);
|
|
598
|
+
fileDownloadLink.click();
|
|
599
|
+
document.body.removeChild(fileDownloadLink);
|
|
600
|
+
}
|
|
601
|
+
};
|
|
602
|
+
const handleImportProfileClick = () => {
|
|
603
|
+
var _a, _b;
|
|
604
|
+
(_a = document.getElementById('fileInput')) === null || _a === void 0 ? void 0 : _a.click();
|
|
605
|
+
// Event listener for file input change
|
|
606
|
+
(_b = document
|
|
607
|
+
.getElementById('fileInput')) === null || _b === void 0 ? void 0 : _b.addEventListener('change', function (event) {
|
|
608
|
+
var _a;
|
|
609
|
+
if (event && event.target) {
|
|
610
|
+
const inputElement = event.target;
|
|
611
|
+
// Handle the selected file
|
|
612
|
+
if (inputElement) {
|
|
613
|
+
const file = (_a = inputElement.files) === null || _a === void 0 ? void 0 : _a[0];
|
|
614
|
+
if (file) {
|
|
615
|
+
const reader = new FileReader();
|
|
616
|
+
reader.onload = function (e) {
|
|
617
|
+
var _a;
|
|
618
|
+
const fileContent = (_a = e.target) === null || _a === void 0 ? void 0 : _a.result;
|
|
619
|
+
// Save file content to local storage
|
|
620
|
+
saveToLocalStorage(fileContent);
|
|
621
|
+
// Reset the file input value to clear it
|
|
622
|
+
inputElement.value = '';
|
|
623
|
+
};
|
|
624
|
+
reader.readAsText(file);
|
|
625
|
+
}
|
|
626
|
+
else {
|
|
627
|
+
console.error(`[importProfile]: Please select a file.`);
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
});
|
|
632
|
+
};
|
|
633
|
+
const saveToLocalStorage = (fileContent) => {
|
|
634
|
+
const importedProfile = JSON.parse(fileContent);
|
|
635
|
+
const profileAlreadyExists = profiles.find((profile) => profile.id === (importedProfile === null || importedProfile === void 0 ? void 0 : importedProfile.id));
|
|
636
|
+
if (profileAlreadyExists === undefined) {
|
|
637
|
+
// Add new data to the profiles array
|
|
638
|
+
profiles.push(importedProfile);
|
|
639
|
+
setProfiles([...profiles]);
|
|
640
|
+
saveAllProfiles(profiles);
|
|
641
|
+
}
|
|
642
|
+
else {
|
|
643
|
+
const existProfileIndex = profiles.findIndex((profile) => profile.id === (importedProfile === null || importedProfile === void 0 ? void 0 : importedProfile.id));
|
|
644
|
+
if (existProfileIndex !== -1) {
|
|
645
|
+
profiles[existProfileIndex] = importedProfile;
|
|
646
|
+
setProfiles([...profiles]);
|
|
647
|
+
saveAllProfiles(profiles);
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
};
|
|
589
651
|
/**
|
|
590
652
|
* A common input changed handler used for all top-level profile fields (i.e. URLs)
|
|
591
653
|
*/
|
|
@@ -658,7 +720,9 @@ const Profiles = ({ match }) => {
|
|
|
658
720
|
React__default.createElement(Dropdown, { "data-test-id": "new-profile-dropdown", text: "New Profile", icon: "dropdown", labeled: true, button: true, floating: true, className: "icon blue", pointing: "top" },
|
|
659
721
|
React__default.createElement(Dropdown.Menu, null,
|
|
660
722
|
React__default.createElement(Dropdown.Item, { "data-test-id": "new-profile:local", onClick: handleNewProfileClick('local') }, "Local Profile"),
|
|
661
|
-
React__default.createElement(Dropdown.Item, { "data-test-id": "new-profile:production", onClick: handleNewProfileClick('production') }, "Production Profile")
|
|
723
|
+
React__default.createElement(Dropdown.Item, { "data-test-id": "new-profile:production", onClick: handleNewProfileClick('production') }, "Production Profile"),
|
|
724
|
+
React__default.createElement(Dropdown.Item, { "data-test-id": "import-from-file", onClick: handleImportProfileClick }, "Import Profile From File"))),
|
|
725
|
+
React__default.createElement("input", { id: "fileInput", type: "file", accept: ".json", hidden: true }),
|
|
662
726
|
React__default.createElement(Button, { basic: true, "data-test-id": "scenarios-button", floated: "right", color: "blue", as: Link, to: `/` }, "Scenarios"),
|
|
663
727
|
React__default.createElement(Divider, null),
|
|
664
728
|
React__default.createElement(List, { link: true }, profiles.map((profile) => {
|
|
@@ -672,7 +736,8 @@ const Profiles = ({ match }) => {
|
|
|
672
736
|
React__default.createElement(Header, null, selectedProfile === null || selectedProfile === void 0 ? void 0 :
|
|
673
737
|
selectedProfile.name,
|
|
674
738
|
React__default.createElement(Button, { "data-test-id": "save-profile-button", color: "blue", floated: "right", content: "Save", onClick: handleSaveProfileClick }),
|
|
675
|
-
React__default.createElement(Button, { basic: true, color: "blue", floated: "right", content: "Delete", onClick: handleDeleteProfileClick })
|
|
739
|
+
React__default.createElement(Button, { basic: true, color: "blue", floated: "right", content: "Delete", onClick: handleDeleteProfileClick }),
|
|
740
|
+
React__default.createElement(Button, { basic: true, color: "blue", floated: "right", content: "Export", onClick: handleExportProfileClick })),
|
|
676
741
|
React__default.createElement(Form, null,
|
|
677
742
|
React__default.createElement(Form.Input, { width: 4, label: "Profile Name", name: "name", value: selectedProfile === null || selectedProfile === void 0 ? void 0 : selectedProfile.name, onChange: handleInputChange })),
|
|
678
743
|
React__default.createElement(Divider, null),
|