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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"moment-duration-format": "^2.3.2",
"moment-timezone": "^0.5.33",
"mui-color-input": "^9.0.0",
"openstack-uicore-foundation": "5.0.44",
"openstack-uicore-foundation": "5.0.49-beta.2",
"p-limit": "^6.1.0",
"path-browserify": "^1.0.1",
"postcss-loader": "^6.2.1",
Expand Down
4 changes: 3 additions & 1 deletion src/actions/sponsor-forms-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ export const getSponsorForms =
expand: "sponsorship_types"
};

filter.push(`is_archived==${showArchived ? 1 : 0}`);
if (!showArchived) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@santipalenque this changes the meaning of the "Show archived" checkbox for this one list only. On master all 13 showArchived thunks push is_archived==${showArchived ? 1 : 0} (checked = archived only). After this change getSponsorForms returns active + archived when checked, while the other 12 — including getSponsorFormItems, the sponsor Forms tab and the rest of this same file (lines 326, 575, 774, 857, 1162), plus form-template-actions.js:99, form-template-item-actions.js:101, inventory-item-actions.js:117, page-template-actions.js:79, show-pages-actions.js:78, sponsor-pages-actions.js:145/361 — keep the old semantics. The global forms list and the sponsor Forms tab now render the identical GridToolbar checkbox with the same "Show archived" label and behave in opposite ways.

Ticket 86bb7tvh1 is scoped to column-width/responsive layout and does not ask for a filter change, so unless product requested this, please revert this hunk to filter.push(is_archived==${showArchived ? 1 : 0}) so the archived filter stays consistent across lists. If "include archived" is the intended new behavior, it needs to be applied to all 13 sites (and covered by a showArchived=true case in src/actions/__tests__/sponsor-forms-actions.test.js) in one change, not to a single list.

filter.push("is_archived==0");
}

if (sponsorshipTypesId?.length > 0) {
const formattedSponsorships = sponsorshipTypesId.join("&&");
Expand Down
2 changes: 1 addition & 1 deletion src/components/CustomTheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const theme = createTheme(CustomThemeBase, {
...(ownerState.size === "medium" && {
fontSize: "14px",
lineHeight: "20px",
padding: "10px 20px"
padding: "8px 12px"
}),
...(ownerState.size === "large" && {
fontSize: "16px",
Expand Down
4 changes: 2 additions & 2 deletions src/components/image-preview-cell.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ export const ImagePreviewCell = React.memo(
return (
<>
<IconButton
size="small"
size="medium"
aria-label={T.translate("preview_modal.title")}
onClick={() => setOpen(true)}
>
<ImageIcon fontSize="small" />
<ImageIcon fontSize="large" />
</IconButton>

{open && (
Expand Down
125 changes: 125 additions & 0 deletions src/components/mui/grid-toolbar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
import React from "react";
import PropTypes from "prop-types";
import { Checkbox, FormControlLabel, FormGroup, Grid2 } from "@mui/material";
import SearchInput from "openstack-uicore-foundation/lib/components/mui/search-input";

const GridToolbar = ({ searchProps, checkboxProps, children, splitAt }) => {
const hasSearch = !!searchProps;
const hasCheckbox = !!checkboxProps;

let searchSize;
let checkboxSize;
let actionsSize;

if (hasSearch && hasCheckbox) {
searchSize = { xs: 12, sm: 6, md: 4 };
checkboxSize = { xs: 12, sm: 6, md: 2 };
actionsSize = { xs: 12, md: 6 };
} else if (hasSearch) {
// has search but no checkbox
searchSize = { xs: 12, [splitAt]: 4 };
actionsSize = { xs: 12, [splitAt]: 8 };
} else if (hasCheckbox) {
// has checkbox but no search
checkboxSize = { xs: 12, [splitAt]: 4 };
actionsSize = { xs: 12, [splitAt]: 8 };
Comment thread
smarcet marked this conversation as resolved.
} else {
actionsSize = { xs: 12 };
}

// must match the breakpoint where actionsSize itself leaves its xs:12
// (own full-width row) value — that's the point flexWrap needs to switch
// to nowrap, so children don't get squeezed once actionsSize starts
// sharing a row with a sibling
const actionsWidthBreakpoint =
hasSearch && hasCheckbox ? "md" : hasSearch || hasCheckbox ? splitAt : "xs";

// children go natural (auto) width starting at actionsWidthBreakpoint,
// never earlier than sm; between sm and that point (only a real window
// when actionsWidthBreakpoint is md) they fill the row evenly instead
const actionsAutoBreakpoint =
actionsWidthBreakpoint === "xs" ? "sm" : actionsWidthBreakpoint;
const hasFillTier = actionsAutoBreakpoint !== "sm";

return (
<Grid2 container spacing={2} sx={{ mb: 3 }}>
{hasSearch && (
<Grid2 size={searchSize}>
<SearchInput {...searchProps} />
</Grid2>
)}
{hasCheckbox && (
<Grid2 size={checkboxSize}>
<FormGroup sx={{ flexShrink: 0 }}>
<FormControlLabel
control={
<Checkbox
checked={checkboxProps.checked}
onChange={checkboxProps.onChange}
inputProps={{
"aria-label": checkboxProps.ariaLabel ?? checkboxProps.label
}}
Comment thread
smarcet marked this conversation as resolved.
/>
}
label={checkboxProps.label}
sx={{ whiteSpace: "nowrap" }}
/>
</FormGroup>
</Grid2>
)}
<Grid2
size={actionsSize}
sx={{
display: "flex",
justifyContent: "flex-end",
flexWrap: { xs: "wrap", [actionsWidthBreakpoint]: "nowrap" },
gap: 2
}}
>
{/* xs: stacked full width. sm through actionsAutoBreakpoint (only a
real window when that's md): fill the row evenly via flexGrow.
From actionsAutoBreakpoint on: natural/auto width. */}
{React.Children.map(children, (child) =>
child
? React.cloneElement(child, {
sx: {
width: { xs: "100%", [actionsAutoBreakpoint]: "auto" },
...(hasFillTier && {
flexGrow: { sm: 1, [actionsAutoBreakpoint]: 0 },
flexBasis: { sm: 0, [actionsAutoBreakpoint]: "auto" }
}),
...child.props.sx
}
})
: child
)}
</Grid2>
</Grid2>
);
};

GridToolbar.propTypes = {
searchProps: PropTypes.shape({
term: PropTypes.string,
onSearch: PropTypes.func.isRequired,
placeholder: PropTypes.string,
debounced: PropTypes.bool
}),
checkboxProps: PropTypes.shape({
checked: PropTypes.bool,
onChange: PropTypes.func,
label: PropTypes.node,
ariaLabel: PropTypes.string
}),
// breakpoint where search/checkbox split from the actions row into their
// compact ratio — raise it (e.g. "lg") when actions holds a lot of children
splitAt: PropTypes.oneOf(["xs", "sm", "md", "lg", "xl"])
};

GridToolbar.defaultProps = {
searchProps: null,
checkboxProps: null,
splitAt: "sm"
};

export default GridToolbar;
14 changes: 5 additions & 9 deletions src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -858,8 +858,6 @@
},
"tag_list": {
"tag_list": "Tag List",
"item": "item",
"items": "items",
"tags": "Tags",
"add_tag": "Add Tag",
"delete_tag_warning": "Are you sure you want to delete tag",
Expand Down Expand Up @@ -2765,14 +2763,12 @@
"sponsor_forms": {
"forms": "Forms",
"alert_info": "To add an order form, select Add Form to start the process. To edit an existing form, click on the form name. To edit the line items within the form click manage items on the form line you wish to edit.",
"show_archived": "Show archived Forms",
"show_archived": "Show archived",
"using_global": "Using Global Template",
"add_form": "New Form Template",
"code_column_label": "Code",
"name_column_label": "Name",
"items_column_label": "Items",
"item_label_singular": "Item",
"item_label_plural": "Items",
"tiers_column_label": "Tiers",
"manage_items_button": "Manage Items",
"form_delete_success": "Form successfully deleted.",
Expand Down Expand Up @@ -2924,8 +2920,8 @@
"sponsor_users": {
"users": "Users",
"access_request": "access request",
"import_user": "import existing user",
"add_user": "add user",
"import_user": "import",
"add_user": "add",
"name": "Name",
"email": "Email",
"sponsor": "Sponsor",
Expand Down Expand Up @@ -3488,7 +3484,7 @@
"media_uploads": "Media Upload Types",
"media_upload": "Media Upload Type",
"media_upload_list": "Media Upload Type List",
"add": "Add Media Upload Type",
"add": "Add Type",
"no_results": "No items found for this search criteria.",
"id": "Id",
"name": "Name",
Expand All @@ -3504,7 +3500,7 @@
"public_storage_type": "Public Storage Type",
"private_storage_type": "Private Storage Type",
"presentation_types": "Presentation Types",
"copy_media_uploads": "Copy Media Uploads",
"copy_media_uploads": "Copy Types",
"media_uploads_copied": "Media Upload Types copied successfully.",
"delete_warning": "Are you sure you want to delete media media type ",
"saved": "Media Upload Type saved successfully.",
Expand Down
57 changes: 17 additions & 40 deletions src/pages/admin_access/admin-access-list-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ import { connect } from "react-redux";
import T from "i18n-react/dist/i18n-react";
import Box from "@mui/material/Box";
import Button from "@mui/material/Button";
import Grid2 from "@mui/material/Grid2";
import AddIcon from "@mui/icons-material/Add";
import MuiTable from "openstack-uicore-foundation/lib/components/mui/table";
import MuiSearchInput from "openstack-uicore-foundation/lib/components/mui/search-input";
import GridToolbar from "../../components/mui/grid-toolbar";
import {
getAdminAccesses,
deleteAdminAccess,
Expand Down Expand Up @@ -109,46 +108,24 @@ const AdminAccessListPage = ({
return (
<Box className="container">
<h3>{T.translate("admin_access.admin_access_list")}</h3>
<Grid2
container
spacing={2}
sx={{ justifyContent: "center", alignItems: "center", mb: 2 }}
<GridToolbar
searchProps={{
term,
onSearch: handleSearch,
placeholder: T.translate("admin_access.placeholders.search")
}}
>
<Grid2 size={2}>
<Box component="span">
{totalAdminAccesses} {T.translate("general.items")}
</Box>
</Grid2>
<Grid2
container
size={10}
spacing={1}
gap={1}
sx={{ justifyContent: "flex-end", alignItems: "center" }}
<Button
variant="contained"
startIcon={<AddIcon />}
onClick={handleNewAdminAccess}
>
<Grid2 size={3}>
<MuiSearchInput
term={term}
onSearch={handleSearch}
placeholder={T.translate("admin_access.placeholders.search")}
/>
</Grid2>
<Button
variant="contained"
startIcon={<AddIcon />}
onClick={handleNewAdminAccess}
sx={{
height: "36px",
padding: "6px 16px",
fontSize: "1.4rem",
lineHeight: "2.4rem",
letterSpacing: "0.4px"
}}
>
{T.translate("admin_access.add")}
</Button>
</Grid2>
</Grid2>
{T.translate("admin_access.add")}
</Button>
</GridToolbar>
<Box sx={{ mb: 2 }}>
{totalAdminAccesses} {T.translate("general.items")}
</Box>

{admin_accesses.length === 0 && (
<div>{T.translate("admin_access.no_results")}</div>
Expand Down
64 changes: 17 additions & 47 deletions src/pages/companies/company-list-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
import React, { useEffect, useState } from "react";
import { connect } from "react-redux";
import T from "i18n-react/dist/i18n-react";
import { Box, Button, Grid2 } from "@mui/material";
import { Box, Button } from "@mui/material";
import AddIcon from "@mui/icons-material/Add";
import MuiTable from "openstack-uicore-foundation/lib/components/mui/table";
import SearchInput from "openstack-uicore-foundation/lib/components/mui/search-input";
import GridToolbar from "../../components/mui/grid-toolbar";
import {
getCompanies,
getCompany,
Expand Down Expand Up @@ -125,54 +125,24 @@ const CompanyListPage = ({
return (
<div className="container">
<h3> {T.translate("company_list.company_list")}</h3>
<Grid2
container
spacing={1}
sx={{
justifyContent: "space-between",
alignItems: "center",
mb: 2
<GridToolbar
searchProps={{
term,
onSearch: handleSearch,
placeholder: T.translate("company_list.placeholders.search_companies")
}}
>
<Grid2 size={2}>
<Box component="span">
{totalCompanies} {T.translate("company_list.companies")}
</Box>
</Grid2>
<Grid2
container
size={10}
gap={1}
sx={{
justifyContent: "flex-end",
alignItems: "center"
}}
<Button
variant="contained"
onClick={handleNewCompany}
startIcon={<AddIcon />}
>
<Grid2 size={4}>
<SearchInput
term={term}
onSearch={handleSearch}
placeholder={T.translate(
"company_list.placeholders.search_companies"
)}
/>
</Grid2>
<Button
variant="contained"
onClick={handleNewCompany}
startIcon={<AddIcon />}
sx={{
height: "36px",
padding: "6px 16px",
fontSize: "1.4rem",
lineHeight: "2.4rem",
letterSpacing: "0.4px"
}}
>
{T.translate("company_list.add_company")}
</Button>
</Grid2>
</Grid2>
{T.translate("company_list.add_company")}
</Button>
</GridToolbar>
<Box sx={{ mb: 2 }}>
{totalCompanies} {T.translate("company_list.companies")}
</Box>

{companies.length > 0 && (
<MuiTable
Expand Down
Loading
Loading