Skip to content

Commit

Permalink
hide forbidden actions from Add menu in schedule (#4708)
Browse files Browse the repository at this point in the history
# What this PR does

hide forbidden actions from Add menu in schedule

<!--
*Note*: If you want the issue to be auto-closed once the PR is merged,
change "Related to" to "Closes" in the line above.
If you have more than one GitHub issue that this PR closes, be sure to
preface
each issue link with a [closing
keyword](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests#linking-a-pull-request-to-an-issue).
This ensures that the issue(s) are auto-closed once the PR has been
merged.
-->

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.
  • Loading branch information
brojd authored Jul 22, 2024
1 parent 1c88107 commit 4438443
Showing 1 changed file with 57 additions and 32 deletions.
89 changes: 57 additions & 32 deletions grafana-plugin/src/pages/schedule/Schedule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { RouteComponentProps, withRouter } from 'react-router-dom';

import { PageErrorHandlingWrapper } from 'components/PageErrorHandlingWrapper/PageErrorHandlingWrapper';
import { PluginLink } from 'components/PluginLink/PluginLink';
import { RenderConditionally } from 'components/RenderConditionally/RenderConditionally';
import { ScheduleFilters } from 'components/ScheduleFilters/ScheduleFilters';
import { ScheduleFiltersType } from 'components/ScheduleFilters/ScheduleFilters.types';
import { ScheduleQuality } from 'components/ScheduleQuality/ScheduleQuality';
Expand Down Expand Up @@ -232,40 +233,64 @@ class _SchedulePage extends React.Component<SchedulePageProps, SchedulePageState
<Dropdown
overlay={
<Menu>
{layers?.map((layer, index) => (
<Menu.Item
key={index}
label={`L${layer.priority} rotation`}
onClick={() => {
scrollToElement(document.getElementById(HTML_ID.SCHEDULE_ROTATIONS));

this.handleShowRotationForm('new', layer.priority);
}}
/>
))}
<Menu.Item
label="New layer with rotation"
onClick={() => {
scrollToElement(document.getElementById(HTML_ID.SCHEDULE_ROTATIONS));

this.handleShowRotationForm('new', nextPriority);
}}
<RenderConditionally
shouldRender={!disabledRotationForm}
render={() =>
layers?.map((layer, index) => (
<Menu.Item
key={index}
label={`L${layer.priority} rotation`}
onClick={() => {
scrollToElement(document.getElementById(HTML_ID.SCHEDULE_ROTATIONS));

this.handleShowRotationForm('new', layer.priority);
}}
/>
))
}
/>
<Menu.Item
label="Shift swap request"
onClick={() => {
scrollToElement(document.getElementById(HTML_ID.SCHEDULE_OVERRIDES_AND_SWAPS));

this.handleShowShiftSwapForm('new');
}}
<RenderConditionally
shouldRender={!disabledRotationForm}
render={() => (
<Menu.Item
label="New layer with rotation"
onClick={() => {
scrollToElement(document.getElementById(HTML_ID.SCHEDULE_ROTATIONS));

this.handleShowRotationForm('new', nextPriority);
}}
/>
)}
/>
<Menu.Item
label="Override"
onClick={() => {
scrollToElement(document.getElementById(HTML_ID.SCHEDULE_OVERRIDES_AND_SWAPS));

this.handleShowOverridesForm('new');
}}
<RenderConditionally
shouldRender={!disabledShiftSwaps}
render={() => (
<Menu.Item
label="Shift swap request"
onClick={() => {
scrollToElement(
document.getElementById(HTML_ID.SCHEDULE_OVERRIDES_AND_SWAPS)
);

this.handleShowShiftSwapForm('new');
}}
/>
)}
/>
<RenderConditionally
shouldRender={!disabledOverrideForm}
render={() => (
<Menu.Item
label="Override"
onClick={() => {
scrollToElement(
document.getElementById(HTML_ID.SCHEDULE_OVERRIDES_AND_SWAPS)
);

this.handleShowOverridesForm('new');
}}
/>
)}
/>
</Menu>
}
Expand Down

0 comments on commit 4438443

Please sign in to comment.