Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewind the rules table UI prototype #3079

Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
80c31e6
Proof of concept implementation of rewind-the-rules-table UI
michellemounde Dec 11, 2023
b3ba896
Lint fix for recurring max-len error
michellemounde Dec 11, 2023
3613542
WIP: Implement horrible hardcoded way to use diff mode
michellemounde Dec 13, 2023
1af3ea9
Don't use DiffRule directly in ListRules
michellemounde Dec 13, 2023
eb41ec2
Add horrible hack to implement diff checkbox
michellemounde Dec 13, 2023
1f151c7
Lint fixes
michellemounde Dec 14, 2023
6b7a1fc
Fix button disabling
michellemounde Dec 14, 2023
4a6a0c2
Center and space rule list options
michellemounde Dec 14, 2023
c133aa0
Fix search field cutting off first rule card in rewind mode
michellemounde Dec 14, 2023
138fb99
Rename disableActions to isRewound
michellemounde Dec 14, 2023
0f4525b
Fix bug where rules wouldn't rewind when productChannelFilter is all
michellemounde Dec 15, 2023
053abc2
Remove diff mode
michellemounde Dec 15, 2023
26b150e
Add timestamp query to url and datetime string to banner
michellemounde Dec 15, 2023
86c4d50
Lint fixes
michellemounde Dec 15, 2023
af42a0c
Enable return to current mode from rewind mode
michellemounde Dec 15, 2023
93ef2dd
Stop fetching rules twice on page load
michellemounde Dec 18, 2023
0c49803
Remove read-only mode comment
michellemounde Dec 18, 2023
b1fbc94
Align rewind date picker with other options
michellemounde Dec 18, 2023
507f4de
Disable scheduled changes filter in rewind mode
michellemounde Dec 18, 2023
67e663f
Completely remove diff mode
michellemounde Dec 18, 2023
d02609c
Add comment on search field ref
michellemounde Dec 18, 2023
2ba28f6
Disable rule creation in rewind mode
michellemounde Dec 18, 2023
17927a3
Readability improvements
michellemounde Dec 18, 2023
7e65792
Implement rewind date clearing in the primary UI
michellemounde Dec 19, 2023
e01d38c
Sort rules in rewind mode
michellemounde Dec 19, 2023
deb059f
Show info when there are no rules matching rewind date or product/cha…
michellemounde Dec 21, 2023
0343cf6
Combine use cases for disabling actions on rule cards
michellemounde Dec 21, 2023
76a9345
Fix error where info doesn't show when product channel filter is all
michellemounde Dec 21, 2023
a8d36f1
Show info when no rules with scheduled changes & reset scheduled chan…
michellemounde Dec 21, 2023
165651e
Move filtered rules info to a utility function
michellemounde Dec 21, 2023
e1bdb41
Modify links in dashboard to add query string while on target url
michellemounde Dec 21, 2023
919940f
Remove add rule button in rewind mode to fix tooltip error
michellemounde Dec 21, 2023
5c7a3b1
Fix cutting off of rule card when link with anchor is loaded
michellemounde Dec 22, 2023
5400364
Remove clear button in rewind date picker when rules are not rewound
michellemounde Dec 22, 2023
b27623b
Fix disable updates banner not showing consistently in rewind mode
michellemounde Dec 22, 2023
4d37246
Fix updates are disabled dialog disappearing on rewind date change
michellemounde Jan 8, 2024
a00bbf4
Test getFilteredRulesInfo
michellemounde Jan 8, 2024
368a3d7
Lint fixes
michellemounde Jan 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion ui/src/components/Dashboard/SettingsMenu.jsx
Expand Up @@ -59,7 +59,13 @@ function SettingsMenu({ user, disabled }) {
onClose={handleMenuClose}>
{menuItems.settings.map(navItem => (
<MenuItem dense key={navItem.value} title={navItem.value}>
<Link className={classes.link} to={navItem.path}>
<Link
className={classes.link}
to={
window.location.pathname === navItem.path
? `${window.location.pathname}${window.location.search}`
: navItem.path
}>
{navItem.value.toUpperCase()}
</Link>
</MenuItem>
Expand Down
6 changes: 5 additions & 1 deletion ui/src/components/Dashboard/index.jsx
Expand Up @@ -71,7 +71,11 @@ export default function Dashboard(props) {
key={menuItem.value}
className={disabled ? classes.disabledLink : classes.link}
nav
to={menuItem.path}>
to={
window.location.pathname === menuItem.path
? `${window.location.pathname}${window.location.search}`
: menuItem.path
}>
<Button color="inherit">{menuItem.value}</Button>
</Link>
))}
Expand Down
30 changes: 17 additions & 13 deletions ui/src/components/RuleCard/index.jsx
Expand Up @@ -161,6 +161,7 @@ function RuleCard({
user,
readOnly,
actionLoading,
disableActions,
// We don't actually use these, but we need to avoid passing them onto
// `Card` like the rest of the props.
onAuthorize: _,
Expand Down Expand Up @@ -860,7 +861,11 @@ function RuleCard({
</CardContent>
{!readOnly && (
<CardActions className={classes.cardActions}>
{user ? (
{disableActions ? (
<Button color="secondary" disabled={disableActions}>
Duplicate
</Button>
) : (
<Link
className={classes.link}
to={{
Expand All @@ -873,12 +878,12 @@ function RuleCard({
}}>
<Button color="secondary">Duplicate</Button>
</Link>
) : (
<Button color="secondary" disabled>
Duplicate
</Button>
)}
{user ? (
{disableActions ? (
<Button color="secondary" disabled={disableActions}>
Update
</Button>
) : (
<Link
className={classes.link}
to={{
Expand All @@ -891,29 +896,25 @@ function RuleCard({
}}>
<Button color="secondary">Update</Button>
</Link>
) : (
<Button color="secondary" disabled>
Update
</Button>
)}
<Button
color="secondary"
disabled={!user || actionLoading}
disabled={disableActions || actionLoading}
onClick={() => onRuleDelete(rule)}>
Delete
</Button>
{requiresSignoff &&
(user && user.email in rule.scheduledChange.signoffs ? (
<Button
color="secondary"
disabled={!user || actionLoading}
disabled={disableActions || actionLoading}
onClick={onRevoke}>
Revoke Signoff
</Button>
) : (
<Button
color="secondary"
disabled={!user || actionLoading || !canSignoff}
disabled={disableActions || actionLoading || !canSignoff}
onClick={onSignoff}>
Signoff
</Button>
Expand All @@ -935,12 +936,15 @@ RuleCard.propTypes = {
// If true, card buttons that trigger a request
// navigating to a different view will be disabled
actionLoading: bool,
// If true, the card will disable all buttons
disableActions: bool,
};

RuleCard.defaultProps = {
onRuleDelete: Function.prototype,
readOnly: false,
actionLoading: false,
disableActions: false,
};

export default withUser(RuleCard);
10 changes: 8 additions & 2 deletions ui/src/components/VariableSizeList/index.jsx
Expand Up @@ -9,13 +9,19 @@ import { AutoSizer, WindowScroller, List } from 'react-virtualized';
import { APP_BAR_HEIGHT } from '../../utils/constants';

const VariableSizeList = forwardRef((props, ref) => {
const { scrollToRow, ...rest } = props;
const { scrollToRow, pathname, ...rest } = props;
michellemounde marked this conversation as resolved.
Show resolved Hide resolved
const listRef = useRef(null);

useEffect(() => {
const rowOffset = listRef.current.getOffsetForRow({ index: scrollToRow });

listRef.current.scrollToPosition(rowOffset - APP_BAR_HEIGHT);
if (pathname === '/rules') {
listRef.current.scrollToPosition(
rowOffset - APP_BAR_HEIGHT - rest.searchFieldHeight
);
} else {
listRef.current.scrollToPosition(rowOffset - APP_BAR_HEIGHT);
}
}, [scrollToRow]);

useImperativeHandle(ref, () => ({
Expand Down
3 changes: 2 additions & 1 deletion ui/src/services/rules.js
@@ -1,7 +1,8 @@
import { stringify } from 'qs';
import axios from 'axios';

const getRules = () => axios.get('/rules');
const getRules = (timestamp = null) =>
timestamp ? axios.get(`/rules?timestamp=${timestamp}`) : axios.get('/rules');
const getRule = id => axios.get(`/rules/${id}`);
const getChannels = () => axios.get('/rules/columns/channel');
const getProducts = () => axios.get('/rules/columns/product');
Expand Down
33 changes: 33 additions & 0 deletions ui/src/utils/getFilteredRulesInfo.js
@@ -0,0 +1,33 @@
// This utility builds the string shown in the
// info alert when no rules match the selected filters
export default (productChannelQueries, rewindDate, onlyScheduledChanges) => {
let info = 'No rules found ';
michellemounde marked this conversation as resolved.
Show resolved Hide resolved
const rewindDateStr = `on ${rewindDate}.`;
const scheduledChangesStr = 'with scheduled changes.';

if (!productChannelQueries) {
if (rewindDate) {
info += rewindDateStr;
} else if (onlyScheduledChanges) {
info += scheduledChangesStr;
}
} else if (productChannelQueries[1]) {
info += `for the ${productChannelQueries[0]} ${productChannelQueries[1]} channel `;

if (rewindDate) {
info += rewindDateStr;
} else if (onlyScheduledChanges) {
info += scheduledChangesStr;
}
} else {
info += `for the ${productChannelQueries[0]} channel `;

if (rewindDate) {
info += rewindDateStr;
} else if (onlyScheduledChanges) {
info += scheduledChangesStr;
}
}

return info;
};