mirror of
https://codeberg.org/gitnex/GitNex.git
synced 2023-12-13 20:50:18 +01:00
8cfd4b6a31
closes #919 TODO - [X] repo and file actions (create release, label...) - [X] allow for repo admins - [x] label actions (edit, delete) - [x] allow for repo admins - [X] issue/pr action that are available for creators (close...) - [X] allow for creator - [X] allow for repo admins - [x] pr actions that are allowed when having push access to pr source (there was a bug in Gitea that makes that this was not working and these features were not accessible -> https://github.com/go-gitea/gitea/issues/17181) - [x] allow deleting of head branch/updates only if you can do this - [x] issue/pr action that are available for repo admins (merge) - [x] allow for repo admins - [x] milestone actions (close/reopen) - [x] allow for repo admins - [x] comment actions (delete, edit...) - [X] allow for creators - [x] allow for repo admins - [x] org actions (create label, team, repo; req gitea 1.16.0) - [x] actions when creating/editing issues - [x] delete head when merging - [x] All actions available to instance admins? (handled through API) Maybe as extras: - [x] Allow close/reopen also for PRs - [x] Improve handling of these (multiple btns for the same action) Co-authored-by: qwerty287 <ndev@web.de> Co-authored-by: M M Arif <mmarif@noreply.codeberg.org> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/977 Reviewed-by: M M Arif <mmarif@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
93 lines
2.7 KiB
Java
93 lines
2.7 KiB
Java
package org.mian.gitnex.fragments;
|
|
|
|
import android.content.Context;
|
|
import android.os.Bundle;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
|
import org.gitnex.tea4j.models.OrgPermissions;
|
|
import org.mian.gitnex.clients.RetrofitClient;
|
|
import org.mian.gitnex.databinding.BottomSheetOrganizationBinding;
|
|
import org.mian.gitnex.structs.BottomSheetListener;
|
|
import org.mian.gitnex.helpers.Authorization;
|
|
import org.mian.gitnex.helpers.TinyDB;
|
|
import org.mian.gitnex.helpers.Version;
|
|
import java.util.List;
|
|
import retrofit2.Call;
|
|
import retrofit2.Callback;
|
|
import retrofit2.Response;
|
|
|
|
/**
|
|
* Author M M Arif
|
|
*/
|
|
|
|
public class BottomSheetOrganizationFragment extends BottomSheetDialogFragment {
|
|
|
|
private BottomSheetListener bmListener;
|
|
private final OrgPermissions permissions;
|
|
|
|
public BottomSheetOrganizationFragment(OrgPermissions org) {
|
|
permissions = org;
|
|
}
|
|
|
|
@Nullable
|
|
@Override
|
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
|
|
|
BottomSheetOrganizationBinding bottomSheetOrganizationBinding = BottomSheetOrganizationBinding.inflate(inflater, container, false);
|
|
|
|
if(permissions != null) {
|
|
if(!permissions.canCreateRepositories()) {
|
|
bottomSheetOrganizationBinding.createRepository.setVisibility(View.GONE);
|
|
}
|
|
if(!permissions.isOwner()) {
|
|
bottomSheetOrganizationBinding.createLabel.setVisibility(View.GONE);
|
|
bottomSheetOrganizationBinding.createTeam.setVisibility(View.GONE);
|
|
}
|
|
}
|
|
|
|
bottomSheetOrganizationBinding.createTeam.setOnClickListener(v1 -> {
|
|
|
|
bmListener.onButtonClicked("team");
|
|
dismiss();
|
|
});
|
|
|
|
bottomSheetOrganizationBinding.createLabel.setOnClickListener(v1 -> {
|
|
|
|
bmListener.onButtonClicked("label");
|
|
dismiss();
|
|
});
|
|
|
|
bottomSheetOrganizationBinding.createRepository.setOnClickListener(v12 -> {
|
|
|
|
bmListener.onButtonClicked("repository");
|
|
dismiss();
|
|
});
|
|
|
|
bottomSheetOrganizationBinding.copyOrgUrl.setOnClickListener(v1 -> {
|
|
|
|
bmListener.onButtonClicked("copyOrgUrl");
|
|
dismiss();
|
|
});
|
|
|
|
return bottomSheetOrganizationBinding.getRoot();
|
|
}
|
|
|
|
@Override
|
|
public void onAttach(@NonNull Context context) {
|
|
|
|
super.onAttach(context);
|
|
|
|
try {
|
|
bmListener = (BottomSheetListener) context;
|
|
}
|
|
catch (ClassCastException e) {
|
|
throw new ClassCastException(context.toString() + " must implement BottomSheetListener");
|
|
}
|
|
}
|
|
|
|
}
|