Skip to content

Commit 6b73045

Browse files
committed
Removed unused state currentMode and updated mode to saveMethod in FeedSourceForm props and templates
1 parent 47b6e66 commit 6b73045

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

src/components/feed-sources/feed-source-manager.jsx

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,13 @@ function FeedSourceManager({
3333
isLoading = false,
3434
loadingError = null,
3535
initialState = null,
36-
mode = null,
3736
}) {
3837
// Hooks
3938
const { t } = useTranslation("common", {
4039
keyPrefix: "feed-source-manager",
4140
});
4241
const navigate = useNavigate();
4342

44-
const [currentMode, setCurrentMode] = useState();
4543
// State
4644
const [headerText] = useState(
4745
saveMethod === "PUT" ? t("edit-feed-source") : t("create-new-feed-source")
@@ -70,19 +68,19 @@ function FeedSourceManager({
7068
value: "App\\Feed\\EventDatabaseApiFeedType",
7169
title: t("dynamic-fields.EventDatabaseApiFeedType.title"),
7270
key: "1",
73-
template: <EventDatabaseApiFeedTypeTemplate mode={currentMode} />,
71+
template: <EventDatabaseApiFeedTypeTemplate mode={saveMethod} />,
7472
},
7573
{
7674
value: "App\\Feed\\NotifiedFeedType",
7775
title: t("dynamic-fields.NotifiedFeedType.title"),
7876
key: "2",
79-
template: <NotifiedFeedTypeTemplate mode={currentMode} />,
77+
template: <NotifiedFeedTypeTemplate mode={saveMethod} />,
8078
},
8179
{
8280
value: "App\\Feed\\CalendarApiFeedType",
8381
title: t("dynamic-fields.CalendarApiFeedType.title"),
8482
key: "3",
85-
template: <CalendarFeedTypeTemplate mode={currentMode} />,
83+
template: <CalendarFeedTypeTemplate mode={saveMethod} />,
8684
},
8785
{
8886
value: "App\\Feed\\RssFeedType",
@@ -97,28 +95,29 @@ function FeedSourceManager({
9795
setFormStateObject({ ...initialState });
9896
}, [initialState]);
9997

100-
useEffect(() => {
101-
setCurrentMode(mode);
102-
}, [mode]);
10398

10499
useEffect(() => {
105-
let newSecrets = {};
106100
if (formStateObject && formStateObject.feedType) {
101+
let newSecrets = {};
102+
107103
switch (formStateObject.feedType) {
108104
case "App\\Feed\\EventDatabaseApiFeedType":
109-
newSecrets = {
110-
host: formStateObject.host,
111-
};
105+
newSecrets =
106+
formStateObject.host === "" ? [] : { host: formStateObject.host };
112107
break;
113108
case "App\\Feed\\NotifiedFeedType":
114-
newSecrets = {
115-
token: formStateObject.token,
116-
};
109+
newSecrets =
110+
formStateObject.token === ""
111+
? []
112+
: { token: formStateObject.token };
117113
break;
118114
case "App\\Feed\\CalendarApiFeedType":
119-
newSecrets = {
120-
resources: formStateObject.resources,
121-
};
115+
newSecrets =
116+
formStateObject.resources === ""
117+
? []
118+
: { resources: formStateObject.resources };
119+
break;
120+
default:
122121
break;
123122
}
124123
formStateObject.secrets = newSecrets;
@@ -217,7 +216,7 @@ function FeedSourceManager({
217216
loadingMessage={loadingMessage}
218217
feedSourceTypeOptions={feedSourceTypeOptions}
219218
dynamicFormElement={dynamicFormElement}
220-
mode={currentMode}
219+
mode={saveMethod}
221220
/>
222221
)}
223222
</>

0 commit comments

Comments
 (0)