Skip to content

Commit

Permalink
Merge branch 'main' into andrea/early-access
Browse files Browse the repository at this point in the history
  • Loading branch information
andre-code authored Jan 8, 2025
2 parents 703e441 + a75f163 commit 6d588f8
Show file tree
Hide file tree
Showing 14 changed files with 278 additions and 171 deletions.
4 changes: 2 additions & 2 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "renku-ui",
"version": "3.44.1",
"version": "3.45.0",
"private": true,
"scripts": {
"start": "vite --port 3000",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,14 @@ import {
useGetOauth2ProvidersQuery,
} from "../../../connectedServices/api/connectedServices.api";
import { INTERNAL_GITLAB_PROVIDER_ID } from "../../../connectedServices/connectedServices.constants";
import PermissionsGuard from "../../../permissionsV2/PermissionsGuard";
import { Project } from "../../../projectsV2/api/projectV2.api";
import { usePatchProjectsByProjectIdMutation } from "../../../projectsV2/api/projectV2.enhanced-api";
import repositoriesApi, {
useGetRepositoryMetadataQuery,
useGetRepositoryProbeQuery,
} from "../../../repositories/repositories.api";
import useProjectPermissions from "../../utils/useProjectPermissions.hook";

interface EditCodeRepositoryModalProps {
project: Project;
Expand Down Expand Up @@ -293,6 +295,8 @@ function CodeRepositoryActions({
url: string;
project: Project;
}) {
const permissions = useProjectPermissions({ projectId: project.id });

const [isDeleteOpen, setIsDeleteOpen] = useState(false);
const toggleDelete = useCallback(() => {
setIsDeleteOpen((open) => !open);
Expand All @@ -317,31 +321,41 @@ function CodeRepositoryActions({
);

return (
<>
<ButtonWithMenuV2
color="outline-primary"
default={defaultAction}
preventPropagation
size="sm"
>
<DropdownItem data-cy="code-repository-delete" onClick={toggleDelete}>
<Trash className={cx("bi", "me-1")} />
Remove
</DropdownItem>
</ButtonWithMenuV2>
<CodeRepositoryDeleteModal
repositoryUrl={url}
isOpen={isDeleteOpen}
toggleModal={toggleDelete}
project={project}
/>
<EditCodeRepositoryModal
toggleModal={toggleEdit}
isOpen={isEditOpen}
project={project}
repositoryUrl={url}
/>
</>
<PermissionsGuard
disabled={null}
enabled={
<>
<ButtonWithMenuV2
color="outline-primary"
default={defaultAction}
preventPropagation
size="sm"
>
<DropdownItem
data-cy="code-repository-delete"
onClick={toggleDelete}
>
<Trash className={cx("bi", "me-1")} />
Remove
</DropdownItem>
</ButtonWithMenuV2>
<CodeRepositoryDeleteModal
repositoryUrl={url}
isOpen={isDeleteOpen}
toggleModal={toggleDelete}
project={project}
/>
<EditCodeRepositoryModal
toggleModal={toggleEdit}
isOpen={isEditOpen}
project={project}
repositoryUrl={url}
/>
</>
}
requestedPermission="write"
userPermissions={permissions}
/>
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* limitations under the License.
*/

import { skipToken } from "@reduxjs/toolkit/query";
import { useEffect } from "react";

import { DEFAULT_PERMISSIONS } from "../../permissionsV2/permissions.constants";
Expand All @@ -30,14 +31,14 @@ export default function useProjectPermissions({
projectId,
}: UseProjectPermissionsArgs): Permissions {
const { currentData, isLoading, isError, isUninitialized } =
projectV2Api.endpoints.getProjectsByProjectIdPermissions.useQueryState({
projectId,
});
projectV2Api.endpoints.getProjectsByProjectIdPermissions.useQueryState(
projectId ? { projectId } : skipToken
);
const [fetchPermissions] =
projectV2Api.endpoints.getProjectsByProjectIdPermissions.useLazyQuery();

useEffect(() => {
if (isUninitialized) {
if (projectId && isUninitialized) {
fetchPermissions({ projectId });
}
}, [fetchPermissions, isUninitialized, projectId]);
Expand Down
Loading

0 comments on commit 6d588f8

Please sign in to comment.