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

Role import #4508

Merged
merged 24 commits into from
Dec 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
c082aa5
Prototype role import logs.
jctanner Nov 7, 2023
a7b1565
Finish import log for imported roles
himdel Nov 11, 2023
770aece
Import role - only for logged in users
himdel Dec 17, 2023
693319d
taskAlert - handle unknown task
himdel Dec 17, 2023
08cf9f5
Role namespace create - superadmin
himdel Dec 17, 2023
e232d8f
Namespace - add role namespaces tab
himdel Dec 17, 2023
77fddbb
naming step
himdel Dec 17, 2023
42b5763
role namespaces - cope with provider filter
himdel Dec 17, 2023
23245a0
sync role for !IS_COMMUNITY && is_superadmin
himdel Dec 17, 2023
c85efbd
taskAlert - dont split empty task
himdel Dec 17, 2023
02f1daa
import/data-form - handle helpertext with direct components
himdel Dec 17, 2023
9ef0101
import - handle user/repo, github/user/repo; sync - handle user.role
himdel Dec 17, 2023
fa606c7
import namespace check - allow creating a role namespace
himdel Dec 17, 2023
c03bbc8
import namespace check - handle assigning a provider namespace
himdel Dec 17, 2023
8904af9
fix namespace description header link
himdel Dec 17, 2023
42ed5c8
linter fix
himdel Dec 17, 2023
79d0f3d
fixup TODO
himdel Dec 17, 2023
f54fbda
Role detail - load namespace, add Import new version
himdel Dec 17, 2023
f509fbf
role namespace detail,list - import role
himdel Dec 17, 2023
c9b6e25
add Role imports (except for the actual screen)
himdel Dec 17, 2023
7bd963e
my-imports: more cleanup
himdel Dec 17, 2023
505cfeb
RoleImports - empty
himdel Dec 17, 2023
5a2b3ff
l10n update
himdel Dec 17, 2023
dfb3624
update l10n test
himdel Dec 17, 2023
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
2 changes: 1 addition & 1 deletion locale/en.js

Large diffs are not rendered by default.

153 changes: 129 additions & 24 deletions locale/en.po

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion locale/es.js

Large diffs are not rendered by default.

153 changes: 129 additions & 24 deletions locale/es.po

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion locale/fr.js

Large diffs are not rendered by default.

153 changes: 129 additions & 24 deletions locale/fr.po

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion locale/ja.js

Large diffs are not rendered by default.

153 changes: 129 additions & 24 deletions locale/ja.po

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion locale/ko.js

Large diffs are not rendered by default.

153 changes: 129 additions & 24 deletions locale/ko.po

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion locale/nl.js

Large diffs are not rendered by default.

153 changes: 129 additions & 24 deletions locale/nl.po

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion locale/zh.js

Large diffs are not rendered by default.

153 changes: 129 additions & 24 deletions locale/zh.po

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export { ImportAPI } from './import';
export { LegacyImportAPI } from './legacy-import';
export { LegacyNamespaceAPI } from './legacy-namespace';
export { LegacyRoleAPI } from './legacy-role';
export { LegacySyncAPI } from './legacy-sync';
export { MyDistributionAPI } from './my-distribution';
export { MyNamespaceAPI } from './my-namespace';
export { MySyncListAPI } from './my-synclist';
Expand Down Expand Up @@ -53,6 +54,7 @@ export {
} from './response-types/execution-environment';
export { FeatureFlagsType } from './response-types/feature-flags';
export { ImportDetailType, ImportListType } from './response-types/import';
export { LegacyRoleImportDetailType } from './response-types/legacy-import';
export {
LegacyNamespaceDetailType,
LegacyNamespaceListType,
Expand Down
1 change: 1 addition & 0 deletions src/api/legacy-namespace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export class API extends LegacyAPI {
apiPath = 'v1/namespaces/';
sortParam = 'sort';

// create(data)
// get(id)
// list(params?)

Expand Down
11 changes: 11 additions & 0 deletions src/api/legacy-sync.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { LegacyAPI } from './legacy';

export class API extends LegacyAPI {
apiPath = 'v1/sync/';

sync(data) {
return this.http.post(this.apiPath, data);
}
}

export const LegacySyncAPI = new API();
24 changes: 24 additions & 0 deletions src/api/response-types/legacy-import.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
export class LegacyRoleImportDetailType {
id: number;
pulp_id: string;
role_id: number;
state: string;
error: {
code: string;
description: string;
traceback: string;
};
summary_fields: {
request_username: string;
github_user: string;
github_repo: string;
github_reference: string;
alternate_role_name: string;
task_messages: {
id: string;
state: string;
message_type: string;
message_text: string;
}[];
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import {
DropdownItem,
} from '@patternfly/react-core';
import React from 'react';
import { Link } from 'react-router-dom';
import { Link, useLocation, useNavigate } from 'react-router-dom';
import { LegacyNamespaceDetailType } from 'src/api';
import { Logo, StatefulDropdown } from 'src/components';
import { useContext } from 'src/loaders/app-context';
import { Paths, formatPath } from 'src/paths';
import './legacy-namespace-item.scss';
import './namespace-item.scss';

interface LegacyNamespaceProps {
namespace: LegacyNamespaceDetailType;
Expand All @@ -29,15 +29,15 @@ export function LegacyNamespaceListItem({
featureFlags: { ai_deny_index },
user: { username, is_superuser },
} = useContext();
const location = useLocation();
const navigate = useNavigate();
const { id, avatar_url, name, summary_fields } = namespace;

const namespace_url = formatPath(Paths.standaloneNamespace, {
namespaceid: id,
});

const cells = [];

cells.push(
const cells = [
<DataListCell isFilled={false} alignRight={false} key='ns'>
<Logo
alt='logo'
Expand All @@ -48,20 +48,18 @@ export function LegacyNamespaceListItem({
width='97px'
/>
</DataListCell>,
);

cells.push(
<DataListCell key='content' size={10}>
<div>
<Link to={namespace_url}>{name}</Link>
</div>
</DataListCell>,
);
];

const userOwnsLegacyNamespace = !!summary_fields.owners.find(
(n) => n.username == username,
);
const showWisdom = ai_deny_index && (is_superuser || userOwnsLegacyNamespace);
const canImport = is_superuser || userOwnsLegacyNamespace;

const dropdownItems = [
showWisdom && openWisdomModal && (
Expand All @@ -74,6 +72,22 @@ export function LegacyNamespaceListItem({
onClick={() => openEditModal(namespace)}
>{t`Change provider namespace`}</DropdownItem>
),
canImport && (
<DropdownItem
onClick={() =>
navigate(
formatPath(
Paths.standaloneRoleImport,
{},
{
github_user: namespace.name,
back: location.pathname,
},
),
)
}
>{t`Import role`}</DropdownItem>
),
].filter(Boolean);

if (dropdownItems.length) {
Expand Down
Loading
Loading