Exemplo n.º 1
0
    rejection => {
      if (rejection.status !== 400) {
        // rollback all
        previousState.forEach(item => {
          store.dispatch(post.patch(item, item))
        })
        return snackbar.apiError(rejection)
      }

      let errors = []
      let rollback = []

      rejection.forEach(item => {
        if (item.detail) {
          errors.push(item)
          rollback.push(item.id)
        } else {
          store.dispatch(post.patch(item, item))
        }

        previousState.forEach(item => {
          if (rollback.indexOf(item) !== -1) {
            store.dispatch(post.patch(item, item))
          }
        })
      })

      let posts = {}
      selection.forEach(item => {
        posts[item.id] = item
      })

      modal.show(<ErrorsList errors={errors} posts={posts} />)
    }
Exemplo n.º 2
0
  handleError = rejection => {
    store.dispatch(thread.release())

    if (rejection.status === 400) {
      if (rejection.best_answers || rejection.polls) {
        modal.show(
          <MergeConflict
            api={this.props.thread.api.merge}
            bestAnswers={rejection.best_answers}
            data={{ other_thread: this.state.url }}
            polls={rejection.polls}
            onError={this.handleError}
            onSuccess={this.handleSuccessUnmounted}
          />
        )
      } else if (rejection.best_answer) {
        snackbar.error(rejection.best_answer[0])
      } else if (rejection.poll) {
        snackbar.error(rejection.poll[0])
      } else {
        snackbar.error(rejection.detail)
      }
    } else {
      snackbar.apiError(rejection)
    }
  }
Exemplo n.º 3
0
 onClick = () => {
   modal.show(
     <LikesModal
       post={this.props.post}
     />
   );
 };
Exemplo n.º 4
0
 move = () => {
   modal.show(
     <MoveModal
       posts={this.props.posts}
       thread={this.props.thread}
     />
   );
 };
Exemplo n.º 5
0
 move = () => {
   modal.show(
     <MoveThreads callApi={this.callApi}
                  categories={this.props.categories}
                  categoriesMap={this.props.categoriesMap}
                  route={this.props.route}
                  user={this.props.user} />
   );
 };
Exemplo n.º 6
0
 handleError(rejection) {
   if (rejection.status === 400) {
     this.setState({
       'errors': Object.assign({}, this.state.errors, rejection)
     });
     snackbar.error(gettext("Form contains errors."));
   } else if (rejection.status === 403 && Array.isArray(rejection)) {
     modal.show(<ErrorsModal errors={rejection} />);
   } else {
     snackbar.apiError(rejection);
   }
 }
Exemplo n.º 7
0
    const countdown = new Countdown(() => {
      this.props.threads.forEach((thread) => {
        this.props.freezeThread(thread.id);
      });

      if (errors.length) {
        modal.show(<ErrorsModal errors={errors} />);
      } else {
        snackbar.success(successMessage);
        if (onSuccess) {
          onSuccess();
        }
      }
    }, this.props.threads.length);
Exemplo n.º 8
0
  merge = () => {
    const errors = [];
    this.props.threads.forEach((thread) => {
      if (!thread.acl.can_merge) {
        errors.append({
          'id': thread.id,
          'title': thread.title,
          'errors': [
            gettext("You don't have permission to merge this thread with others.")
          ]
        });
      }
    });

    if (this.props.threads.length < 2) {
      snackbar.info(
        gettext("You have to select at least two threads to merge."));
    } else if (errors.length) {
      modal.show(<ErrorsModal errors={errors} />);
      return;
    } else {
      modal.show(<MergeThreads {...this.props} />);
    }
  };
Exemplo n.º 9
0
 handleError = (rejection) => {
   if (rejection.status === 400) {
     if (rejection.polls) {
       modal.show(
         <MergePolls
           api={misago.get('MERGE_THREADS_API')}
           data={this.getFormdata()}
           polls={rejection.polls}
           onError={this.handleError}
           onSuccess={this.handleSuccess}
         />
       );
     } else {
       this.setState({
         'errors': Object.assign({}, this.state.errors, rejection)
       });
       snackbar.error(gettext("Form contains errors."));
     }
   } else if (rejection.status === 403 && Array.isArray(rejection)) {
     modal.show(<ErrorsModal errors={rejection} />);
   } else {
     snackbar.apiError(rejection);
   }
 };
Exemplo n.º 10
0
    const countdown = new Countdown(() => {
      if (errors.length) {
        modal.show(<ErrorsModal errors={errors} />);
      } else {
        snackbar.success(gettext("Selected threads were deleted."));
      }

      // unfreeze non-deleted threads
      this.props.threads.forEach((thread) => {
        this.props.freezeThread(thread.id);
      });

      // reduce selection to non-deleted threads
      store.dispatch(select.all(this.props.threads.map(function(item) {
        return item.id;
      })));
    }, this.props.threads.length);
 onClick = () => {
   modal.show(
     <AddParticipantModal thread={this.props.thread} />
   );
 }
Exemplo n.º 12
0
 changeAvatar() {
   modal.show(connect(select)(ChangeAvatarModal));
 }
Exemplo n.º 13
0
 onClick = () => {
   modal.show(
     <PostChangelog post={this.props.post} />
   )
 };
Exemplo n.º 14
0
 onClick = () => {
   modal.show(
     <MoveModal {...this.props} />
   );
 };
Exemplo n.º 15
0
 showSignInModal() {
   modal.show(SignInModal);
 }
Exemplo n.º 16
0
 merge = () => {
   modal.show(
     <MergeModal thread={this.props.thread} />
   );
 };
Exemplo n.º 17
0
 onClick = () => {
   modal.show(
     <SplitModal {...this.props} />
   );
 };