8000 pre-pf5 cleanup by himdel · Pull Request #4863 · ansible/ansible-hub-ui · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

pre-pf5 cleanup #4863

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

Merged
merged 43 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
a867749
drop NAMESPACE_TERM
himdel Feb 13, 2024
a10e3af
drop DEPLOYMENT_MODE
himdel Feb 15, 2024
8e8d8cf
remove *WithNamespace path hack, use optional params
himdel Feb 13, 2024
b84cd28
EE manifest - inline query
himdel Feb 19, 2024
6209253
remove withContainerParamFix, replace with a containerName helper
himdel Feb 19, 2024
243ee99
containerNanme - typing fix
himdel Feb 19, 2024
a0417d3
always static contextType
himdel Feb 19, 2024
b411aa4
inline single-use constants
himdel Feb 13, 2024
61dda92
translateLockedRole - inline const
himdel Feb 13, 2024
ff7a2d5
clean up { foo: foo } -> { foo }
himdel Feb 19, 2024
9f6af57
translateTask - move to utilities
himdel Feb 13, 2024
6e7b7cd
various
himdel Feb 19, 2024
fc1a01c
prop={true} => prop
himdel Feb 19, 2024
f637100
prop type fix to allow falsy removal
himdel Feb 19, 2024
91404c4
replace React.Fragment with <> or Fragment
himdel Feb 19, 2024
771b0fc
remove prop={false}
himdel Feb 19, 2024
ee09de1
namespaceBreadcrumg.url unnecessary
himdel Feb 19, 2024
45814ee
eslintrc - remove unused
himdel Feb 19, 2024
26e86ef
task trans test
himdel Feb 19, 2024
b9b642f
convert react imports - Component
himdel Feb 19, 2024
8f1a147
ReactNode
himdel Feb 19, 2024
d0aa594
FC/FunctionComponent
himdel Feb 19, 2024
cfde3cf
StrictMode
himdel Feb 19, 2024
7376975
ReactElement
himdel Feb 19, 2024
7727bd2
ElementType
himdel Feb 19, 2024
1cd52ba
createContext; useContext; rename our useContext to useHubContext
himdel Feb 19, 2024
0faf49c
useRef
himdel Feb 19, 2024
eb53ea7
useEffect
himdel Feb 19, 2024
2a0a361
rest of React.foo
himdel Feb 19, 2024
24e9b33
Ref
himdel Feb 19, 2024
bc33f71
createRef
himdel Feb 19, 2024
c820265
FormEvent
himdel Feb 19, 2024
bac6534
MouseEvent
himdel Feb 19, 2024
8216179
useState
himdel Feb 19, 2024
6245ed5
RefObject
himdel Feb 19, 2024
941d431
ReactFragment
himdel Feb 19, 2024
c120fbc
HTMLProps
himdel Feb 19, 2024
c958be2
CSSProperties
himdel Feb 19, 2024
5c7fbd5
HTMLAttributes
himdel Feb 19, 2024
2aaa349
Children
himdel Feb 19, 2024
473d79b
fixup login-form
himdel Feb 19, 2024
d3d0b8a
dont pass context in props
himdel Feb 19, 2024
cc04bff
dont pass context in props2
himdel Feb 19, 2024
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
10 changes: 1 addition & 9 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@
"jsx": true,
},
},
globals: {
// overridden in test/.eslintrc
APPLICATION_NAME: "readonly",
NAMESPACE_TERM: "readonly",
UI_BASE_PATH: "readonly",
},
rules: {
"curly": ["error", "all"],
"eol-last": ["error", "always"],
Expand All @@ -48,8 +42,6 @@
"name": "@patternfly/react-core",
}],
}],

/// FIXME: Rules to add from previous config (see #860)
// array-bracket-spacing camelcase comma-dangle comma-spacing comma-style curly dot-notation eol-last eqeqeq func-names indent key-spacing keyword-spacing linebreak-style max-len new-cap no-bitwise no-caller no-mixed-spaces-and-tabs no-multiple-empty-lines no-trailing-spaces no-undef no-unused-vars no-use-before-define no-var no-with object-curly-spacing object-shorthand one-var padding-line-between-statements quote-props quotes react/jsx-curly-spacing semi space-before-blocks space-in-parens space-infix-ops space-unary-ops vars-on-top wrap-iife yoda
},
}
// set vim:ft=javascript
6 changes: 1 addition & 5 deletions config/community.dev.webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,9 @@ module.exports = webpackBase({
// Port that the UI is served over
UI_PORT: 8002,

// Determines if the app should be compiled to run on insights or on
// another platform. Options: insights, standalone
DEPLOYMENT_MODE: 'standalone',
// Determines if the app should be compiled to run as community galaxy
IS_COMMUNITY: true,

NAMESPACE_TERM: 'namespaces',

// Serve the UI over http or https. Options: true, false
UI_USE_HTTPS: false,

Expand Down
2 changes: 0 additions & 2 deletions config/community.prod.webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ module.exports = webpackBase({
API_BASE_PATH: '/api/',
API_HOST: '',
APPLICATION_NAME: 'Ansible Galaxy',
DEPLOYMENT_MODE: 'standalone',
IS_COMMUNITY: true,
NAMESPACE_TERM: 'namespaces',
UI_BASE_PATH: '/ui/',
UI_DEBUG: false,
UI_EXTERNAL_LOGIN_URI: '/login/github/',
Expand Down
7 changes: 1 addition & 6 deletions config/insights.dev.webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,9 @@ module.exports = webpackBase({
// Port that the UI is served over
UI_PORT: 8002,

// Determines if the app should be compiled to run on insights or on
// another platform. Options: insights, standalone
DEPLOYMENT_MODE: 'insights',
// Determines if the app should be compiled to run on insights
IS_INSIGHTS: true,

// Determines the title of the "namespaces" page
NAMESPACE_TERM: 'partners',

// Determines the title of the app
APPLICATION_NAME: 'Automation Hub',

Expand Down
2 changes: 0 additions & 2 deletions config/insights.prod.webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ module.exports = webpackBase({
cloudBeta === 'true'
? '/preview/ansible/automation-hub/'
: '/ansible/automation-hub/',
DEPLOYMENT_MODE: 'insights',
IS_INSIGHTS: true,
NAMESPACE_TERM: 'partners',
UI_USE_HTTPS: false,
UI_DEBUG: false,
APPLICATION_NAME: 'Automation Hub',
Expand Down
5 changes: 0 additions & 5 deletions config/standalone.dev.webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,9 @@ module.exports = webpackBase({
// Port that the UI is served over
UI_PORT: 8002,

// Determines if the app should be compiled to run on insights or on
// another platform. Options: insights, standalone
DEPLOYMENT_MODE: 'standalone',
// dev-mode only, support `IS_COMMUNITY=1 npm run start-standalone` in addition to `npm run start-community`
IS_COMMUNITY: !!process.env.IS_COMMUNITY,

NAMESPACE_TERM: 'namespaces',

// Serve the UI over http or https. Options: true, false
UI_USE_HTTPS: false,

Expand Down
2 changes: 0 additions & 2 deletions config/standalone.prod.webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ module.exports = webpackBase({
API_HOST: '',
API_BASE_PATH: '/api/galaxy/',
UI_BASE_PATH: '/ui/',
DEPLOYMENT_MODE: 'standalone',
NAMESPACE_TERM: 'namespaces',
UI_USE_HTTPS: false,
UI_DEBUG: false,
UI_EXTERNAL_LOGIN_URI: '/login',
Expand Down
9 changes: 4 additions & 5 deletions config/webpack.base.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,13 @@ const defaultConfigs = [
{ name: 'APPLICATION_NAME', default: 'Galaxy NG', scope: 'global' },
{ name: 'IS_COMMUNITY', default: false, scope: 'global' },
{ name: 'IS_INSIGHTS', default: false, scope: 'global' },
{ name: 'NAMESPACE_TERM', default: 'namespaces', scope: 'global' },
{ name: 'UI_BASE_PATH', default: '', scope: 'global' },
{ name: 'UI_COMMIT_HASH', default: gitCommit, scope: 'global' },
{ name: 'UI_DOCS_URL', default: docsURL, scope: 'global' },
{ name: 'UI_EXTERNAL_LOGIN_URI', default: '/login', scope: 'global' },

// Webpack scope: only available in customConfigs here, not exposed to the UI
{ name: 'API_PROXY_TARGET', default: undefined, scope: 'webpack' },
{ name: 'DEPLOYMENT_MODE', default: 'standalone', scope: 'webpack' },
{ name: 'UI_DEBUG', default: false, scope: 'webpack' },
{ name: 'UI_PORT', default: 8002, scope: 'webpack' },
{ name: 'UI_USE_HTTPS', default: false, scope: 'webpack' },
Expand Down Expand Up @@ -131,7 +129,8 @@ module.exports = (inputConfigs) => {
customConfigs.API_BASE_PATH + 'pulp/api/v3/',
);

const isStandalone = customConfigs.DEPLOYMENT_MODE !== 'insights';
// community is also considered standalone
const isStandalone = !customConfigs.IS_INSIGHTS;

const { config: webpackConfig, plugins } = config({
rootFolder: resolve(__dirname, '../'),
Expand Down Expand Up @@ -237,7 +236,7 @@ module.exports = (inputConfigs) => {
newWebpackConfig.output.publicPath = customConfigs.WEBPACK_PUBLIC_PATH;
}

if (customConfigs.DEPLOYMENT_MODE === 'standalone') {
if (isStandalone) {
console.log('Overriding configs for standalone mode.');

const newEntry = resolve(__dirname, '../src/entry-standalone.tsx');
Expand All @@ -258,7 +257,7 @@ module.exports = (inputConfigs) => {
);
}

if (customConfigs.DEPLOYMENT_MODE === 'insights') {
if (customConfigs.IS_INSIGHTS) {
/**
* Generates remote containers for chrome 2
*/
Expand Down
2 changes: 1 addition & 1 deletion src/actions/ansible-repository-collection-version-add.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ const AddCollectionVersionModal = ({
{t`Cancel`}
</Button>,
]}
isOpen={true}
isOpen
>
title={t`Select a collection`}
variant='large'
Expand Down
12 changes: 10 additions & 2 deletions src/actions/ansible-repository-delete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { msg, t } from '@lingui/macro';
import React from 'react';
import { AnsibleDistributionAPI, AnsibleRepositoryAPI } from 'src/api';
import { DeleteAnsibleRepositoryModal } from 'src/components';
import { Constants } from 'src/constants';
import { canDeleteAnsibleRepository } from 'src/permissions';
import {
handleHttpError,
Expand Down Expand Up @@ -41,7 +40,16 @@ export const ansibleRepositoryDeleteAction = Action({
},
}),
disabled: ({ name }) => {
if (Constants.PROTECTED_REPOSITORIES.includes(name)) {
if (
[
'rh-certified',
'validated',
'community',
'published',
'staging',
'rejected',
].includes(name)
) {
return t`Protected repositories cannot be deleted.`;
}

Expand Down
2 changes: 1 addition & 1 deletion src/actions/ansible-repository-sync.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const SyncModal = ({
{t`Close`}
</Button>,
]}
isOpen={true}
isOpen
>
title={t`Sync repository "${name}"`}
variant='medium'
Expand Down
2 changes: 1 addition & 1 deletion src/actions/ansible-repository-version-revert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const RevertModal = ({
{t`Cancel`}
</Button>,
]}
isOpen={true}
isOpen
>
title={t`Revert repository`}
titleIconVariant='warning'
Expand Down
4 changes: 1 addition & 3 deletions src/api/base.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import axios from 'axios';
import Cookies from 'js-cookie';
import { Constants } from 'src/constants';
import { ParamHelper } from 'src/utilities';

export class BaseAPI {
Expand Down Expand Up @@ -33,8 +32,7 @@ export class BaseAPI {
// The api uses offset/limit OR page/page_size for pagination
// the UI uses page/page size and maps to whatever the api expects

const pageSize =
parseInt(newParams['page_size'], 10) || Constants.DEFAULT_PAGE_SIZE;
const pageSize = parseInt(newParams['page_size'], 10) || 10;
const page = parseInt(newParams['page'], 10) || 1;

delete newParams['page'];
Expand Down
6 changes: 3 additions & 3 deletions src/api/container-tag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ class API extends PulpAPI {

tag(repositoryID: string, tag: string, digest: string) {
return this.http.post(this.apiPath + `${repositoryID}/tag/`, {
digest: digest,
tag: tag,
digest,
tag,
});
}

untag(repositoryID: string, tag: string) {
return this.http.post(this.apiPath + `${repositoryID}/untag/`, {
tag: tag,
tag,
});
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/components/about-modal/about-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ import {
TextListVariants,
} from '@patternfly/react-core';
import { detect } from 'detect-browser';
import React, { useEffect, useState } from 'react';
import React, { ReactNode, useEffect, useState } from 'react';
import { Link } from 'react-router-dom';
import Logo from 'src/../static/images/logo_large.svg';
import { ApplicationInfoAPI, UserType } from 'src/api';
import { ExternalLink, MaybeLink } from 'src/components';
import { Paths, formatPath } from 'src/paths';

const Label = ({ children }: { children: React.ReactNode }) => (
const Label = ({ children }: { children: ReactNode }) => (
<TextListItem component={TextListItemVariants.dt}>{children}</TextListItem>
);

const Value = ({ children }: { children: React.ReactNode }) => (
const Value = ({ children }: { children: ReactNode }) => (
<TextListItem component={TextListItemVariants.dd}>{children}</TextListItem>
);

Expand Down
8 changes: 4 additions & 4 deletions src/components/ansible-role/namespace-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import React from 'react';
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 { useHubContext } from 'src/loaders/app-context';
import { Paths, formatPath } from 'src/paths';
import './namespace-item.scss';

Expand All @@ -28,7 +28,7 @@ export function LegacyNamespaceListItem({
const {
featureFlags: { ai_deny_index },
user: { username, is_superuser },
} = useContext();
} = useHubContext();
const location = useLocation();
const navigate = useNavigate();
const { id, avatar_url, name, summary_fields } = namespace;
Expand All @@ -38,7 +38,7 @@ export function LegacyNamespaceListItem({
});

const cells = [
<DataListCell isFilled={false} alignRight={false} key='ns'>
<DataListCell isFilled={false} key='ns'>
<Logo
alt='logo'
fallbackToDefault
Expand Down Expand Up @@ -92,7 +92,7 @@ export function LegacyNamespaceListItem({

if (dropdownItems.length) {
cells.push(
<DataListCell key='menu' alignRight={true}>
<DataListCell key='menu' alignRight>
<div style={{ float: 'right' }}>
<StatefulDropdown items={dropdownItems} />
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/components/ansible-role/role-import-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
ExternalLink,
RoleNamespaceEditModal,
} from 'src/components';
import { useContext } from 'src/loaders/app-context';
import { useHubContext } from 'src/loaders/app-context';
import { Paths, formatPath } from 'src/paths';
import {
ErrorMessagesType,
Expand Down Expand Up @@ -174,7 +174,7 @@ const NamespaceCheck = ({
};

export const RoleImportForm = ({ addAlert }: IProps) => {
const { queueAlert, user } = useContext();
const { queueAlert, user } = useHubContext();
const navigate = useNavigate();
const location = useLocation();
const params = ParamHelper.parseParamString(location.search) as {
Expand Down
6 changes: 3 additions & 3 deletions src/components/ansible-role/role-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import './role-item.scss';

interface LegacyRoleProps {
role: LegacyRoleDetailType;
show_thumbnail: boolean;
show_thumbnail?: boolean;
}

export function LegacyRoleListItem({ role, show_thumbnail }: LegacyRoleProps) {
Expand All @@ -44,9 +44,9 @@ export function LegacyRoleListItem({ role, show_thumbnail }: LegacyRoleProps) {
const provider = getProviderInfo(role);
const cells = [];

if (show_thumbnail !== false) {
if (show_thumbnail) {
cells.push(
<DataListCell isFilled={false} alignRight={false} key='ns'>
<DataListCell isFilled={false} key='ns'>
<Logo
alt={t`${namespace.name} logo`}
image={namespace.avatar_url}
Expand Down
2 changes: 1 addition & 1 deletion src/components/ansible-role/role-namespace-edit-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const RoleNamespaceEditModal = ({
return (
<Modal
actions={actions}
isOpen={true}
isOpen
>
title={t`Change provider namespace`}
variant='large'
Expand Down
17 changes: 10 additions & 7 deletions src/components/approval/approval-row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,20 @@ import CheckCircleIcon from '@patternfly/react-icons/dist/esm/icons/check-circle
import DownloadIcon from '@patternfly/react-icons/dist/esm/icons/download-icon';
import ExclamationCircleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-circle-icon';
import ExclamationTriangleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-triangle-icon';
import React from 'react';
import React, { Fragment } from 'react';
import { Link } from 'react-router-dom';
import { CollectionAPI, CollectionVersionSearch } from 'src/api';
import {
CollectionAPI,
CollectionVersionSearch,
FeatureFlagsType,
} from 'src/api';
import { DateComponent, LabelGroup, ListItemActions } from 'src/components';
import { IAppContextType } from 'src/loaders/app-context';
import { Paths, formatPath } from 'src/paths';

interface IProps {
approve: (collectionVersion: CollectionVersionSearch) => void;
collectionVersion: CollectionVersionSearch;
context: IAppContextType;
featureFlags: FeatureFlagsType;
isVersionUpdating: (collectionVersion: CollectionVersionSearch) => boolean;
openUploadCertificateModal: (
collectionVersion: CollectionVersionSearch,
Expand All @@ -31,7 +34,7 @@ interface IProps {
export const ApprovalRow = ({
approve,
collectionVersion,
context: { featureFlags },
featureFlags,
isVersionUpdating,
openUploadCertificateModal,
reject,
Expand Down Expand Up @@ -109,11 +112,11 @@ export const ApprovalRow = ({

const approveButton = [
canUploadSignature && (
<React.Fragment key='upload'>
<Fragment key='upload'>
<Button => openUploadCertificateModal(collectionVersion)}>
{t`Upload signature`}
</Button>{' '}
</React.Fragment>
</Fragment>
),
<Button
key='approve-button'
Expand Down
Loading
0