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

feat: consolidated checkbox state to single checkbox #1011

Merged
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
28 changes: 5 additions & 23 deletions frontend/widgets/src/QueryApi.Launchpad.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ useEffect(() => {
setCheckboxEvents(initializeCheckboxState(eventsData, 'event_name'));
}, [methodsData, eventsData]);

const generateMethods = () => {
const generateProperties = () => {
const filterData = (data, checkboxState, keyName) => {
return data
.map(item => {
Expand Down Expand Up @@ -463,7 +463,7 @@ const handleFetchCheckboxData = async () => {
};

const toggleAllSelection = (action) => {
const isSelectAll = action === 'select_all';
const isSelectAll = !selectAllMethods;
const isMethodsTab = tab === 'methods_tab';
const isEventsTab = tab === 'events_tab';

Expand Down Expand Up @@ -632,20 +632,11 @@ return (
<Checkbox
type="checkbox"
id="select_all"
onChange={() => toggleAllSelection('select_all')}
onChange={() => toggleAllSelection(selectAllMethods)}
checked={selectAllMethods}
/>
Select All
</CheckboxLabel>
<CheckboxLabel>
<Checkbox
type="checkbox"
id="unselect_all"
onChange={() => toggleAllSelection('unselect_all')}
checked={!selectAllMethods}
/>
Unselect All
</CheckboxLabel>
</CheckboxContainer>

{methodsData.map((item, index) => (
Expand Down Expand Up @@ -686,20 +677,11 @@ return (
<Checkbox
type="checkbox"
id="select_all_events"
onChange={() => toggleAllSelection('select_all')}
onChange={() => toggleAllSelection(selectAllEvents)}
checked={selectAllEvents}
/>
Select All Events
</CheckboxLabel>
<CheckboxLabel>
<Checkbox
type="checkbox"
id="unselect_all_events"
onChange={() => toggleAllSelection('unselect_all')}
checked={!selectAllEvents}
/>
Unselect All Events
</CheckboxLabel>
</CheckboxContainer>

{eventsData.map((item, index) => (
Expand Down Expand Up @@ -737,7 +719,7 @@ return (
</ScrollableDiv>
</SubContainerContent>
)}
<GenerateButton onClick={generateMethods} disabled={(!checkboxMethods || !hasSelectedValues(checkboxMethods)) && (!checkboxEvents || !hasSelectedValues(checkboxEvents))}>Generate</GenerateButton>
<GenerateButton onClick={generateProperties} disabled={(!checkboxMethods || !hasSelectedValues(checkboxMethods)) && (!checkboxEvents || !hasSelectedValues(checkboxEvents))}>Generate</GenerateButton>
</SubContainerContent>
</SubContainer>
</WidgetContainer>
Expand Down
Loading