Skip to content

Commit 4aada82

Browse files
feat: move show directory to mui (#896)
* feat: move show directory to mui * fix: figma adjustments on show directory grid * fix: feedback from PR
1 parent 3b5d4d2 commit 4aada82

5 files changed

Lines changed: 342 additions & 180 deletions

File tree

src/actions/summit-actions.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ import {
2121
stopLoading,
2222
startLoading,
2323
showSuccessMessage,
24-
authErrorHandler
24+
authErrorHandler,
25+
escapeFilterValue
2526
} from "openstack-uicore-foundation/lib/utils/actions";
2627
import moment from "moment-timezone";
2728
import {
@@ -130,7 +131,12 @@ export const clearCurrentSummit = () => (dispatch) => {
130131
};
131132

132133
export const loadSummits =
133-
(page = DEFAULT_CURRENT_PAGE, perPage = DEFAULT_PER_PAGE) =>
134+
(
135+
page = DEFAULT_CURRENT_PAGE,
136+
perPage = DEFAULT_PER_PAGE,
137+
term = "",
138+
hidePastEvents = false
139+
) =>
134140
async (dispatch, getState) => {
135141
const accessToken = await getAccessTokenSafely();
136142

@@ -146,6 +152,22 @@ export const loadSummits =
146152
order: "-start_date"
147153
};
148154

155+
const filters = [];
156+
157+
if (term) {
158+
const escapedTerm = escapeFilterValue(term);
159+
filters.push(`name=@${escapedTerm}`);
160+
}
161+
162+
if (hidePastEvents) {
163+
const now = moment().tz("UTC").unix();
164+
filters.push(`end_date>=${now}`);
165+
}
166+
167+
if (filters.length > 0) {
168+
params["filter[]"] = filters;
169+
}
170+
149171
getRequest(
150172
createAction(REQUEST_SUMMITS),
151173
createAction(RECEIVE_SUMMITS),

src/i18n/en.json

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,10 +299,23 @@
299299
},
300300
"directory": {
301301
"select": "Select",
302-
"summits": "Events",
303-
"add_summit": "Add Event",
302+
"summits": "Shows",
303+
"shows": "shows",
304+
"add_summit": "Add Show",
304305
"remove_warning": "Are you sure you want to delete event",
305-
"invitation_only": "Invitation Only"
306+
"error_loading": "Error loading directory.",
307+
"invitation_only": "Invitation Only",
308+
"id": "ID",
309+
"summit_name": "Event Name",
310+
"sponsors": "Sponsors",
311+
"forms": "Forms",
312+
"attachments": "Attachments",
313+
"hide_past_events": "Hide past events",
314+
"start_date": "Start Date",
315+
"end_date": "End Date",
316+
"placeholders": {
317+
"search": "Search..."
318+
}
306319
},
307320
"dashboard": {
308321
"dashboard": "Dashboard",

src/pages/summits/summit-dashboard-page.js

Lines changed: 74 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@
99
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1010
* See the License for the specific language governing permissions and
1111
* limitations under the License.
12-
**/
12+
* */
1313
import React from "react";
14+
import PropTypes from "prop-types";
1415
import { connect } from "react-redux";
1516
import moment from "moment-timezone";
16-
import { getSummitById } from "../../actions/summit-actions";
1717
import T from "i18n-react/dist/i18n-react";
1818
import { Breadcrumb } from "react-breadcrumbs";
19+
import { getSummitById } from "../../actions/summit-actions";
1920
import Member from "../../models/member";
2021
import "../../styles/summit-dashboard-page.less";
2122

@@ -37,18 +38,21 @@ class SummitDashboardPage extends React.Component {
3738
}
3839

3940
onCollapseChange(section) {
40-
let newCollapseState = { ...this.state.collapseState };
41+
const newCollapseState = { ...this.state.collapseState };
4142
newCollapseState[section] = !newCollapseState[section];
4243
this.setState({ ...this.state, collapseState: newCollapseState });
4344
}
4445

4546
componentDidMount() {
4647
const { currentSummit } = this.props;
47-
this.interval = setInterval(this.localTimer.bind(this), 1000);
48+
this.interval = setInterval(
49+
this.localTimer.bind(this),
50+
moment.duration(1, "second").asMilliseconds()
51+
);
4852

49-
if (currentSummit) {
50-
let localtime = moment().tz(currentSummit.time_zone.name);
51-
this.setState({ ...this.state, localtime: localtime });
53+
if (currentSummit?.time_zone?.name) {
54+
const localtime = moment().tz(currentSummit.time_zone.name);
55+
this.setState({ ...this.state, localtime });
5256
}
5357
}
5458

@@ -63,8 +67,8 @@ class SummitDashboardPage extends React.Component {
6367
}
6468

6569
getFormattedTime(atime) {
66-
atime = atime * 1000;
67-
return moment(atime)
70+
return moment
71+
.unix(atime)
6872
.tz(this.props.currentSummit.time_zone.name)
6973
.format("MMMM Do YYYY, h:mm:ss a");
7074
}
@@ -77,10 +81,10 @@ class SummitDashboardPage extends React.Component {
7781

7882
render() {
7983
const { currentSummit, match, member } = this.props;
80-
let memberObj = new Member(member);
81-
let canEditSummit = memberObj.canEditSummit();
84+
const memberObj = new Member(member);
85+
const canEditSummit = memberObj.canEditSummit();
8286

83-
if (!currentSummit.id) return <div />;
87+
if (!currentSummit.id || !currentSummit.time_zone?.name) return <div />;
8488

8589
return (
8690
<div>
@@ -100,16 +104,16 @@ class SummitDashboardPage extends React.Component {
100104
<div className="col-md-6"> {currentSummit.time_zone.name} </div>
101105
<div className="col-md-6">
102106
{" "}
103-
{this.getFormattedTime(this.state.localtime / 1000)}{" "}
107+
{this.getFormattedTime(this.state.localtime.unix())}{" "}
104108
</div>
105109
</div>
106110
<div
107111
className={
108-
"row " +
112+
`row ${
109113
this.getTimeClass(
110114
currentSummit.start_date,
111115
currentSummit.end_date
112-
)
116+
)}`
113117
}
114118
>
115119
<div className="col-md-2">
@@ -131,11 +135,11 @@ class SummitDashboardPage extends React.Component {
131135
</div>
132136
<div
133137
className={
134-
"row " +
138+
`row ${
135139
this.getTimeClass(
136140
currentSummit.start_date,
137141
currentSummit.end_date
138-
)
142+
)}`
139143
}
140144
>
141145
<div className="col-md-2">
@@ -160,16 +164,16 @@ class SummitDashboardPage extends React.Component {
160164
</div>
161165
{canEditSummit &&
162166
currentSummit.selection_plans.map((sp) => (
163-
<div key={"seleplan_" + sp.id} className="selection-plan row">
167+
<div key={`seleplan_${ sp.id}`} className="selection-plan row">
164168
<div className="col-md-12">{sp.name}</div>
165169
<div className="col-md-12">
166170
<div
167171
className={
168-
"row " +
172+
`row ${
169173
this.getTimeClass(
170174
currentSummit.start_date,
171175
currentSummit.end_date
172-
)
176+
)}`
173177
}
174178
>
175179
<div className="col-md-2">
@@ -192,11 +196,11 @@ class SummitDashboardPage extends React.Component {
192196
</div>
193197
<div
194198
className={
195-
"row " +
199+
`row ${
196200
this.getTimeClass(
197201
currentSummit.start_date,
198202
currentSummit.end_date
199-
)
203+
)}`
200204
}
201205
>
202206
<div className="col-md-2">
@@ -219,11 +223,11 @@ class SummitDashboardPage extends React.Component {
219223
</div>
220224
<div
221225
className={
222-
"row " +
226+
`row ${
223227
this.getTimeClass(
224228
currentSummit.start_date,
225229
currentSummit.end_date
226-
)
230+
)}`
227231
}
228232
>
229233
<div className="col-md-2">
@@ -253,24 +257,24 @@ class SummitDashboardPage extends React.Component {
253257
<hr />
254258
<h4>
255259
{T.translate("dashboard.events")}&nbsp;
256-
{this.state.collapseState["events"] && (
260+
{this.state.collapseState.events && (
257261
<i
258262
title={T.translate("dashboard.expand")}
259263
onClick={() => this.onCollapseChange("events")}
260264
className="fa fa-plus-square clickable"
261265
aria-hidden="true"
262-
></i>
266+
/>
263267
)}
264-
{!this.state.collapseState["events"] && (
268+
{!this.state.collapseState.events && (
265269
<i
266270
title={T.translate("dashboard.collapse")}
267271
onClick={() => this.onCollapseChange("events")}
268272
className="fa fa-minus-square clickable"
269273
aria-hidden="true"
270-
></i>
274+
/>
271275
)}
272276
</h4>
273-
{!this.state.collapseState["events"] && (
277+
{!this.state.collapseState.events && (
274278
<div>
275279
<div className="row">
276280
<div className="col-md-4">
@@ -309,24 +313,24 @@ class SummitDashboardPage extends React.Component {
309313
<hr />
310314
<h4>
311315
{T.translate("dashboard.voting")}&nbsp;
312-
{this.state.collapseState["voting"] && (
316+
{this.state.collapseState.voting && (
313317
<i
314318
title={T.translate("dashboard.expand")}
315319
onClick={() => this.onCollapseChange("voting")}
316320
className="fa fa-plus-square clickable"
317321
aria-hidden="true"
318-
></i>
322+
/>
319323
)}
320-
{!this.state.collapseState["voting"] && (
324+
{!this.state.collapseState.voting && (
321325
<i
322326
title={T.translate("dashboard.collapse")}
323327
onClick={() => this.onCollapseChange("voting")}
324328
className="fa fa-minus-square clickable"
325329
aria-hidden="true"
326-
></i>
330+
/>
327331
)}
328332
</h4>
329-
{!this.state.collapseState["voting"] && (
333+
{!this.state.collapseState.voting && (
330334
<div>
331335
<div className="row">
332336
<div className="col-md-6">
@@ -345,24 +349,24 @@ class SummitDashboardPage extends React.Component {
345349
<hr />
346350
<h4>
347351
{T.translate("dashboard.emails")}&nbsp;
348-
{this.state.collapseState["emails"] && (
352+
{this.state.collapseState.emails && (
349353
<i
350354
title={T.translate("dashboard.expand")}
351355
onClick={() => this.onCollapseChange("emails")}
352356
className="fa fa-plus-square clickable"
353357
aria-hidden="true"
354-
></i>
358+
/>
355359
)}
356-
{!this.state.collapseState["emails"] && (
360+
{!this.state.collapseState.emails && (
357361
<i
358362
title={T.translate("dashboard.collapse")}
359363
onClick={() => this.onCollapseChange("emails")}
360364
className="fa fa-minus-square clickable"
361365
aria-hidden="true"
362-
></i>
366+
/>
363367
)}
364368
</h4>
365-
{!this.state.collapseState["emails"] && (
369+
{!this.state.collapseState.emails && (
366370
<div>
367371
<div className="row">
368372
<div className="col-md-4">
@@ -432,6 +436,37 @@ class SummitDashboardPage extends React.Component {
432436
}
433437
}
434438

439+
SummitDashboardPage.propTypes = {
440+
currentSummit: PropTypes.shape({
441+
id: PropTypes.number,
442+
name: PropTypes.string,
443+
time_zone: PropTypes.shape({
444+
name: PropTypes.string
445+
}),
446+
start_date: PropTypes.number,
447+
end_date: PropTypes.number,
448+
registration_begin_date: PropTypes.number,
449+
registration_end_date: PropTypes.number,
450+
selection_plans: PropTypes.arrayOf(PropTypes.object),
451+
locations: PropTypes.arrayOf(PropTypes.object),
452+
speakers_count: PropTypes.number,
453+
presentations_submitted_count: PropTypes.number,
454+
published_events_count: PropTypes.number,
455+
presentation_voters_count: PropTypes.number,
456+
presentation_votes_count: PropTypes.number,
457+
speaker_announcement_email_accepted_count: PropTypes.number,
458+
speaker_announcement_email_rejected_count: PropTypes.number,
459+
speaker_announcement_email_alternate_count: PropTypes.number,
460+
speaker_announcement_email_accepted_alternate_count: PropTypes.number,
461+
speaker_announcement_email_accepted_rejected_count: PropTypes.number,
462+
speaker_announcement_email_alternate_rejected_count: PropTypes.number
463+
}).isRequired,
464+
member: PropTypes.object,
465+
match: PropTypes.shape({
466+
url: PropTypes.string
467+
}).isRequired
468+
};
469+
435470
const mapStateToProps = ({ currentSummitState, loggedUserState }) => ({
436471
currentSummit: currentSummitState.currentSummit,
437472
member: loggedUserState.member

0 commit comments

Comments
 (0)