Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 8 additions & 13 deletions src/actions/event-type-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {
authErrorHandler,
escapeFilterValue
} from "openstack-uicore-foundation/lib/utils/actions";
import history from "../history";
import { getAccessTokenSafely } from "../utils/methods";
import { DEFAULT_PER_PAGE, DEFAULT_CURRENT_PAGE } from "../utils/constants";

Expand Down Expand Up @@ -124,7 +123,7 @@ export const saveEventType = (entity) => async (dispatch, getState) => {
const params = { access_token: accessToken };

if (entity.id) {
putRequest(
return putRequest(
createAction(UPDATE_EVENT_TYPE),
createAction(EVENT_TYPE_UPDATED),
`${window.API_BASE_URL}/api/v1/summits/${currentSummit.id}/event-types/${entity.id}`,
Expand All @@ -135,31 +134,27 @@ export const saveEventType = (entity) => async (dispatch, getState) => {
dispatch(
showSuccessMessage(T.translate("edit_event_type.event_type_saved"))
);
return dispatch(getEventTypes());
});
} else {
}
const success_message = {
title: T.translate("general.done"),
html: T.translate("edit_event_type.event_type_created"),
type: "success"
};

postRequest(
return postRequest(
createAction(UPDATE_EVENT_TYPE),
createAction(EVENT_TYPE_ADDED),
`${window.API_BASE_URL}/api/v1/summits/${currentSummit.id}/event-types`,
normalizedEntity,
authErrorHandler,
entity
)(params)(dispatch).then((payload) => {
dispatch(
showMessage(success_message, () => {
history.push(
`/app/summits/${currentSummit.id}/event-types/${payload.response.id}`
);
})
);
)(params)(dispatch).then(() => {
dispatch(showMessage(success_message, () => {}));
return dispatch(getEventTypes());
});
}

};

export const deleteEventType = (eventTypeId) => async (dispatch, getState) => {
Expand Down
3 changes: 2 additions & 1 deletion src/components/forms/event-type-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class EventTypeForm extends React.Component {

render() {
const { entity, errors, showSection } = this.state;
const { getMediaUploads, currentSummit } = this.props;
const { getMediaUploads, currentSummit, isSaving } = this.props;
const event_types_ddl = [
{ label: "Presentation", value: "PRESENTATION_TYPE" },
{ label: "Event", value: "EVENT_TYPE" }
Expand Down Expand Up @@ -618,6 +618,7 @@ class EventTypeForm extends React.Component {
onClick={this.handleSubmit}
className="btn btn-primary pull-right"
value={T.translate("general.save")}
disabled={isSaving}
/>
</div>
</div>
Expand Down
53 changes: 20 additions & 33 deletions src/layouts/event-type-layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,49 +9,36 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
* */

import React from "react";
import PropTypes from "prop-types";
import { Switch, Route, withRouter } from "react-router-dom";
import T from "i18n-react/dist/i18n-react";
import { Breadcrumb } from "react-breadcrumbs";
import Restrict from "../routes/restrict";

import EditEventTypePage from "../pages/events/edit-event-type-page";
import EventTypeListPage from "../pages/events/event-type-list-page";
import NoMatchPage from "../pages/no-match-page";

class EventTypeLayout extends React.Component {
render() {
const { match } = this.props;
return (
<div>
<Breadcrumb
data={{
title: T.translate("event_type_list.event_types"),
pathname: match.url
}}
/>
const EventTypeLayout = ({ match }) => (
<div>
<Breadcrumb
data={{
title: T.translate("event_type_list.event_types"),
pathname: match.url
}}
/>

<Switch>
<Route exact strict path={match.url} component={EventTypeListPage} />
<Route
strict
exact
path={`${match.url}/new`}
component={EditEventTypePage}
/>
<Route
strict
exact
path={`${match.url}/:event_type_id(\\d+)`}
component={EditEventTypePage}
/>
<Route component={NoMatchPage} />
</Switch>
</div>
);
}
}
<Switch>
<Route exact strict path={match.url} component={EventTypeListPage} />
<Route component={NoMatchPage} />
</Switch>
</div>
);

EventTypeLayout.propTypes = {
match: PropTypes.shape({ url: PropTypes.string }).isRequired
};

export default Restrict(withRouter(EventTypeLayout), "events");
135 changes: 135 additions & 0 deletions src/pages/events/components/event-type-dialog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
/**
* Copyright 2026 OpenStack Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* */

import React from "react";
import { connect } from "react-redux";
import PropTypes from "prop-types";
import T from "i18n-react/dist/i18n-react";
import Dialog from "@mui/material/Dialog";
import DialogContent from "@mui/material/DialogContent";
import DialogTitle from "@mui/material/DialogTitle";
import Divider from "@mui/material/Divider";
import IconButton from "@mui/material/IconButton";
import CloseIcon from "@mui/icons-material/Close";
import EventTypeForm from "../../../components/forms/event-type-form";
import { saveEventType as saveEventTypeAction } from "../../../actions/event-type-actions";
import {
linkToPresentationType as linkToPresentationTypeAction,
unlinkFromPresentationType as unlinkFromPresentationTypeAction,
queryMediaUploads
} from "../../../actions/media-upload-actions";

const EventTypeDialog = ({
currentSummit,
entity,
errors,
loading,
onClose,
saveEventType,
linkToPresentationType,
unlinkFromPresentationType
}) => {
const isSaving = Boolean(loading);

const handleClose = () => {
if (isSaving) return;
onClose();
};

const handleOnSave = (eventTypeEntity) => {
if (isSaving) return;
saveEventType(eventTypeEntity)
.then(() => onClose())
.catch(() => {
// keep dialog open on save error to preserve user input
});
};

const getMediaUploads = (input, callback) => {
if (!input) return Promise.resolve({ options: [] });
return queryMediaUploads(currentSummit.id, input, callback);
};

const isEdit = Boolean(entity.id);
const title = `${T.translate(
isEdit ? "general.edit" : "general.add"
)} ${T.translate("edit_event_type.event_type")}`;

return (
<Dialog
open
onClose={handleClose}
maxWidth="md"
fullWidth
disableEscapeKeyDown={isSaving}
>
<DialogTitle sx={{ display: "flex", justifyContent: "space-between" }}>
{title}
<IconButton
size="small"
onClick={handleClose}
sx={{ mr: 1 }}
disabled={isSaving}
aria-label="close"
>
<CloseIcon fontSize="small" />
</IconButton>
</DialogTitle>
<Divider />
<DialogContent>
<EventTypeForm
currentSummit={currentSummit}
entity={entity}
errors={errors}
onSubmit={handleOnSave}
getMediaUploads={getMediaUploads}
onMediaUploadLink={linkToPresentationType}
onMediaUploadUnLink={unlinkFromPresentationType}
isSaving={isSaving}
/>
</DialogContent>
</Dialog>
);
};

EventTypeDialog.propTypes = {
currentSummit: PropTypes.shape({ id: PropTypes.number }).isRequired,
entity: PropTypes.shape({ id: PropTypes.number }).isRequired,
errors: PropTypes.shape({}),
loading: PropTypes.number,
onClose: PropTypes.func.isRequired,
saveEventType: PropTypes.func.isRequired,
linkToPresentationType: PropTypes.func.isRequired,
unlinkFromPresentationType: PropTypes.func.isRequired
};

EventTypeDialog.defaultProps = {
errors: {},
loading: 0
};

const mapStateToProps = ({
baseState,
currentSummitState,
currentEventTypeState
}) => ({
currentSummit: currentSummitState.currentSummit,
loading: baseState.loading,
...currentEventTypeState
});

export default connect(mapStateToProps, {
saveEventType: saveEventTypeAction,
linkToPresentationType: linkToPresentationTypeAction,
unlinkFromPresentationType: unlinkFromPresentationTypeAction
})(EventTypeDialog);
113 changes: 0 additions & 113 deletions src/pages/events/edit-event-type-page.js

This file was deleted.

Loading
Loading