Browse Source

Merge pull request #4706 from weseek/feat/77525-81006-disable-delete-button

Feat/77525 81006 disable delete button
Yuki Takei 4 years ago
parent
commit
16bf7c0ad5

+ 1 - 0
packages/app/src/components/SearchPage.jsx

@@ -251,6 +251,7 @@ class SearchPage extends React.Component {
     return (
     return (
       <SearchControl
       <SearchControl
         searchingKeyword={this.state.searchingKeyword}
         searchingKeyword={this.state.searchingKeyword}
+        searchResultCount={this.state.searchResultCount || 0}
         appContainer={this.props.appContainer}
         appContainer={this.props.appContainer}
         onSearchInvoked={this.searchHandler}
         onSearchInvoked={this.searchHandler}
         onExcludeUsersHome={this.onExcludeUsersHome}
         onExcludeUsersHome={this.onExcludeUsersHome}

+ 3 - 2
packages/app/src/components/SearchPage/DeleteSelectedPageGroup.tsx

@@ -3,6 +3,7 @@ import { useTranslation } from 'react-i18next';
 import { CheckboxType } from '../../interfaces/search';
 import { CheckboxType } from '../../interfaces/search';
 
 
 type Props = {
 type Props = {
+  isSelectAllCheckboxDisabled: boolean,
   selectAllCheckboxType: CheckboxType,
   selectAllCheckboxType: CheckboxType,
   onClickDeleteButton?: () => void,
   onClickDeleteButton?: () => void,
   onClickSelectAllCheckbox?: (nextSelectAllCheckboxType: CheckboxType) => void,
   onClickSelectAllCheckbox?: (nextSelectAllCheckboxType: CheckboxType) => void,
@@ -30,12 +31,14 @@ const DeleteSelectedPageGroup:FC<Props> = (props:Props) => {
         type="checkbox"
         type="checkbox"
         name="check-all-pages"
         name="check-all-pages"
         className="custom-control custom-checkbox ml-1 align-self-center"
         className="custom-control custom-checkbox ml-1 align-self-center"
+        disabled={props.isSelectAllCheckboxDisabled}
         onClick={onClickCheckbox}
         onClick={onClickCheckbox}
         checked={selectAllCheckboxType !== CheckboxType.NONE_CHECKED}
         checked={selectAllCheckboxType !== CheckboxType.NONE_CHECKED}
       />
       />
       <button
       <button
         type="button"
         type="button"
         className="btn text-danger font-weight-light p-0 ml-3"
         className="btn text-danger font-weight-light p-0 ml-3"
+        disabled={selectAllCheckboxType === CheckboxType.NONE_CHECKED}
         onClick={() => {
         onClick={() => {
           if (onClickDeleteButton != null) {
           if (onClickDeleteButton != null) {
             onClickDeleteButton();
             onClickDeleteButton();
@@ -50,6 +53,4 @@ const DeleteSelectedPageGroup:FC<Props> = (props:Props) => {
 
 
 };
 };
 
 
-DeleteSelectedPageGroup.propTypes = {
-};
 export default DeleteSelectedPageGroup;
 export default DeleteSelectedPageGroup;

+ 3 - 0
packages/app/src/components/SearchPage/SearchControl.tsx

@@ -8,6 +8,7 @@ import { CheckboxType } from '../../interfaces/search';
 type Props = {
 type Props = {
   searchingKeyword: string,
   searchingKeyword: string,
   appContainer: AppContainer,
   appContainer: AppContainer,
+  searchResultCount: number,
   selectAllCheckboxType: CheckboxType,
   selectAllCheckboxType: CheckboxType,
   onSearchInvoked: (data : any[]) => boolean,
   onSearchInvoked: (data : any[]) => boolean,
   onExcludeUsersHome?: () => void,
   onExcludeUsersHome?: () => void,
@@ -20,6 +21,7 @@ const SearchControl: FC <Props> = (props: Props) => {
   // later needs to be fixed: SearchControl to typescript componet
   // later needs to be fixed: SearchControl to typescript componet
   const SearchPageFormTypeAny : any = SearchPageForm;
   const SearchPageFormTypeAny : any = SearchPageForm;
   const { t } = useTranslation('');
   const { t } = useTranslation('');
+  const { searchResultCount } = props;
 
 
   const onExcludeUsersHome = () => {
   const onExcludeUsersHome = () => {
     if (props.onExcludeUsersHome != null) {
     if (props.onExcludeUsersHome != null) {
@@ -52,6 +54,7 @@ const SearchControl: FC <Props> = (props: Props) => {
       <div className="d-flex my-4">
       <div className="d-flex my-4">
         {/* Todo: design will be fixed in #80324. Function will be implemented in #77525 */}
         {/* Todo: design will be fixed in #80324. Function will be implemented in #77525 */}
         <DeleteSelectedPageGroup
         <DeleteSelectedPageGroup
+          isSelectAllCheckboxDisabled={searchResultCount === 0}
           selectAllCheckboxType={props.selectAllCheckboxType}
           selectAllCheckboxType={props.selectAllCheckboxType}
           onClickDeleteButton={onDeleteSelectedPageHandler}
           onClickDeleteButton={onDeleteSelectedPageHandler}
           onClickSelectAllCheckbox={props.onClickSelectAllCheckbox}
           onClickSelectAllCheckbox={props.onClickSelectAllCheckbox}