From 7a455d08d717df4a6b903945d38231cf29072893 Mon Sep 17 00:00:00 2001 From: mabashian Date: Fri, 11 Jun 2021 11:31:54 -0400 Subject: [PATCH] Change Options to Enabled Options in various details views --- .../PromptInventorySourceDetail.jsx | 42 +++++++--- .../PromptInventorySourceDetail.test.jsx | 12 +-- .../PromptDetail/PromptJobTemplateDetail.jsx | 44 +++++++--- .../PromptJobTemplateDetail.test.jsx | 11 +-- .../PromptDetail/PromptProjectDetail.jsx | 41 +++++++--- .../PromptDetail/PromptProjectDetail.test.jsx | 15 ++-- .../PromptWFJobTemplateDetail.jsx | 28 +++++-- .../PromptWFJobTemplateDetail.test.jsx | 6 +- .../CredentialDetail/CredentialDetail.jsx | 37 ++++++--- .../CredentialDetail.test.jsx | 2 +- .../InventorySourceDetail.jsx | 80 +++++-------------- .../InventorySourceDetail.test.jsx | 6 +- .../Project/ProjectDetail/ProjectDetail.jsx | 41 +++++++--- .../ProjectDetail/ProjectDetail.test.jsx | 15 ++-- .../JobTemplateDetail/JobTemplateDetail.jsx | 25 ++++-- .../WorkflowJobTemplateDetail.jsx | 10 +-- 16 files changed, 249 insertions(+), 166 deletions(-) diff --git a/awx/ui_next/src/components/PromptDetail/PromptInventorySourceDetail.jsx b/awx/ui_next/src/components/PromptDetail/PromptInventorySourceDetail.jsx index 0dd41a5066..3780de727a 100644 --- a/awx/ui_next/src/components/PromptDetail/PromptInventorySourceDetail.jsx +++ b/awx/ui_next/src/components/PromptDetail/PromptInventorySourceDetail.jsx @@ -1,9 +1,13 @@ import React from 'react'; - import { t } from '@lingui/macro'; import { Link } from 'react-router-dom'; - -import { Chip, List, ListItem } from '@patternfly/react-core'; +import { + Chip, + TextList, + TextListItem, + TextListVariants, + TextListItemVariants, +} from '@patternfly/react-core'; import { Detail, DeletedDetail } from '../DetailList'; import { VariablesDetail } from '../CodeEditor'; import CredentialChip from '../CredentialChip'; @@ -44,14 +48,28 @@ function PromptInventorySourceDetail({ resource }) { update_on_project_update ) { optionsList = ( - - {overwrite && {t`Overwrite`}} - {overwrite_vars && {t`Overwrite Variables`}} - {update_on_launch && {t`Update on Launch`}} - {update_on_project_update && ( - {t`Update on Project Update`} + + {overwrite && ( + + {t`Overwrite local groups and hosts from remote inventory source`} + )} - + {overwrite_vars && ( + + {t`Overwrite local variables from remote inventory source`} + + )} + {update_on_launch && ( + + {t`Update on launch`} + + )} + {update_on_project_update && ( + + {t`Update on project update`} + + )} + ); } @@ -162,7 +180,9 @@ function PromptInventorySourceDetail({ resource }) { } /> )} - {optionsList && } + {optionsList && ( + + )} {source_vars && ( { ); expect( wrapper - .find('Detail[label="Options"]') + .find('Detail[label="Enabled Options"]') .containsAllMatchingElements([ -
  • Overwrite
  • , -
  • Overwrite Variables
  • , -
  • Update on Launch
  • , -
  • Update on Project Update
  • , +
  • + Overwrite local groups and hosts from remote inventory source +
  • , +
  • Overwrite local variables from remote inventory source
  • , +
  • Update on launch
  • , +
  • Update on project update
  • , ]) ).toEqual(true); }); diff --git a/awx/ui_next/src/components/PromptDetail/PromptJobTemplateDetail.jsx b/awx/ui_next/src/components/PromptDetail/PromptJobTemplateDetail.jsx index 73fdb3a48c..00b2cf93c9 100644 --- a/awx/ui_next/src/components/PromptDetail/PromptJobTemplateDetail.jsx +++ b/awx/ui_next/src/components/PromptDetail/PromptJobTemplateDetail.jsx @@ -1,9 +1,13 @@ import React from 'react'; - import { t } from '@lingui/macro'; import { Link } from 'react-router-dom'; - -import { Chip, List, ListItem } from '@patternfly/react-core'; +import { + Chip, + TextList, + TextListItem, + TextListVariants, + TextListItemVariants, +} from '@patternfly/react-core'; import CredentialChip from '../CredentialChip'; import ChipGroup from '../ChipGroup'; import Sparkline from '../Sparkline'; @@ -51,19 +55,37 @@ function PromptJobTemplateDetail({ resource }) { become_enabled || host_config_key || allow_simultaneous || - use_fact_cache + use_fact_cache || + webhook_service ) { optionsList = ( - + {become_enabled && ( - {t`Enable Privilege Escalation`} + + {t`Privilege Escalation`} + )} {host_config_key && ( - {t`Allow Provisioning Callbacks`} + + {t`Provisioning Callbacks`} + )} - {allow_simultaneous && {t`Enable Concurrent Jobs`}} - {use_fact_cache && {t`Use Fact Storage`}} - + {allow_simultaneous && ( + + {t`Concurrent Jobs`} + + )} + {use_fact_cache && ( + + {t`Fact Storage`} + + )} + {webhook_service && ( + + {t`Webhooks`} + + )} + ); } @@ -164,7 +186,7 @@ function PromptJobTemplateDetail({ resource }) { } /> )} - {optionsList && } + {optionsList && } {summary_fields?.credentials?.length > 0 && ( { ).toEqual(true); expect( wrapper - .find('Detail[label="Options"]') + .find('Detail[label="Enabled Options"]') .containsAllMatchingElements([ -
  • Enable Privilege Escalation
  • , -
  • Allow Provisioning Callbacks
  • , -
  • Enable Concurrent Jobs
  • , -
  • Use Fact Storage
  • , +
  • Privilege Escalation
  • , +
  • Provisioning Callbacks
  • , +
  • Concurrent Jobs
  • , +
  • Fact Storage
  • , +
  • Webhooks
  • , ]) ).toEqual(true); expect(wrapper.find('VariablesDetail').prop('value')).toEqual( diff --git a/awx/ui_next/src/components/PromptDetail/PromptProjectDetail.jsx b/awx/ui_next/src/components/PromptDetail/PromptProjectDetail.jsx index dd2fe8b5a9..a779e026dc 100644 --- a/awx/ui_next/src/components/PromptDetail/PromptProjectDetail.jsx +++ b/awx/ui_next/src/components/PromptDetail/PromptProjectDetail.jsx @@ -1,10 +1,13 @@ import React from 'react'; - import { t } from '@lingui/macro'; -import { List, ListItem } from '@patternfly/react-core'; +import { + TextList, + TextListItem, + TextListVariants, + TextListItemVariants, +} from '@patternfly/react-core'; import { Link } from 'react-router-dom'; import { Config } from '../../contexts/Config'; - import { Detail, DeletedDetail } from '../DetailList'; import CredentialChip from '../CredentialChip'; import { toTitleCase } from '../../util/strings'; @@ -36,17 +39,33 @@ function PromptProjectDetail({ resource }) { allow_override ) { optionsList = ( - - {scm_clean && {t`Clean`}} - {scm_delete_on_update && {t`Delete on Update`}} + + {scm_clean && ( + {t`Discard local changes before syncing`} + )} + {scm_delete_on_update && ( + {t`Delete the project before syncing`} + )} {scm_track_submodules && ( - {t`Track submodules latest commit on branch`} + {t`Track submodules latest commit on branch`} )} {scm_update_on_launch && ( - {t`Update Revision on Launch`} + {t`Update revision on job launch`} )} - {allow_override && {t`Allow Branch Override`}} - + {allow_override && ( + {t`Allow branch override`} + )} + ); } @@ -90,7 +109,7 @@ function PromptProjectDetail({ resource }) { } /> )} - {optionsList && } + {optionsList && } { beforeAll(() => { wrapper = mountWithContexts( - , + , { context: { config }, } @@ -54,12 +56,13 @@ describe('PromptProjectDetail', () => { ); expect( wrapper - .find('Detail[label="Options"]') + .find('Detail[label="Enabled Options"]') .containsAllMatchingElements([ -
  • Clean
  • , -
  • Delete on Update
  • , -
  • Update Revision on Launch
  • , -
  • Allow Branch Override
  • , +
  • Discard local changes before syncing
  • , +
  • Delete the project before syncing
  • , +
  • Track submodules latest commit on branch
  • , +
  • Update revision on job launch
  • , +
  • Allow branch override
  • , ]) ).toEqual(true); }); diff --git a/awx/ui_next/src/components/PromptDetail/PromptWFJobTemplateDetail.jsx b/awx/ui_next/src/components/PromptDetail/PromptWFJobTemplateDetail.jsx index 935c187864..4a54fb31d8 100644 --- a/awx/ui_next/src/components/PromptDetail/PromptWFJobTemplateDetail.jsx +++ b/awx/ui_next/src/components/PromptDetail/PromptWFJobTemplateDetail.jsx @@ -1,9 +1,13 @@ import React from 'react'; - import { t } from '@lingui/macro'; import { Link } from 'react-router-dom'; - -import { Chip, List, ListItem } from '@patternfly/react-core'; +import { + Chip, + TextList, + TextListItem, + TextListVariants, + TextListItemVariants, +} from '@patternfly/react-core'; import CredentialChip from '../CredentialChip'; import ChipGroup from '../ChipGroup'; import { Detail } from '../DetailList'; @@ -26,10 +30,18 @@ function PromptWFJobTemplateDetail({ resource }) { let optionsList = ''; if (allow_simultaneous || webhook_service) { optionsList = ( - - {allow_simultaneous && {t`Enable Concurrent Jobs`}} - {webhook_service && {t`Enable Webhooks`}} - + + {allow_simultaneous && ( + + {t`Concurrent Jobs`} + + )} + {webhook_service && ( + + {t`Webhooks`} + + )} + ); } @@ -82,7 +94,7 @@ function PromptWFJobTemplateDetail({ resource }) { value={`${window.location.origin}${related.webhook_receiver}`} /> )} - {optionsList && } + {optionsList && } {summary_fields?.webhook_credential && ( { ); expect( wrapper - .find('Detail[label="Options"]') + .find('Detail[label="Enabled Options"]') .containsAllMatchingElements([ -
  • Enable Concurrent Jobs
  • , -
  • Enable Webhooks
  • , +
  • Concurrent Jobs
  • , +
  • Webhooks
  • , ]) ).toEqual(true); expect( diff --git a/awx/ui_next/src/screens/Credential/CredentialDetail/CredentialDetail.jsx b/awx/ui_next/src/screens/Credential/CredentialDetail/CredentialDetail.jsx index 9ca1c1ed0d..0d32e6ec44 100644 --- a/awx/ui_next/src/screens/Credential/CredentialDetail/CredentialDetail.jsx +++ b/awx/ui_next/src/screens/Credential/CredentialDetail/CredentialDetail.jsx @@ -1,9 +1,14 @@ import React, { Fragment, useEffect, useCallback } from 'react'; import { Link, useHistory } from 'react-router-dom'; - import { t } from '@lingui/macro'; import styled from 'styled-components'; -import { Button, List, ListItem } from '@patternfly/react-core'; +import { + Button, + TextList, + TextListItem, + TextListVariants, + TextListItemVariants, +} from '@patternfly/react-core'; import AlertModal from '../../../components/AlertModal'; import { CardBody, CardActionsRow } from '../../../components/Card'; import ContentError from '../../../components/ContentError'; @@ -134,15 +139,7 @@ function CredentialDetail({ credential }) { } if (type === 'boolean') { - return ( - {inputs[id] && {label}}} - /> - ); + return null; } if (inputs[id] === '$encrypted$') { @@ -189,6 +186,10 @@ function CredentialDetail({ credential }) { credential ); + const enabledBooleanFields = fields.filter( + ({ id, type }) => type === 'boolean' && inputs[id] + ); + if (hasContentLoading) { return ; } @@ -255,6 +256,20 @@ function CredentialDetail({ credential }) { date={modified} user={modified_by} /> + {enabledBooleanFields.length > 0 && ( + + {enabledBooleanFields.map(({ id, label }) => ( + + {label} + + ))} + + } + /> + )} {Object.keys(inputSources).length > 0 && ( diff --git a/awx/ui_next/src/screens/Credential/CredentialDetail/CredentialDetail.test.jsx b/awx/ui_next/src/screens/Credential/CredentialDetail/CredentialDetail.test.jsx index 25147bb148..14e48a3569 100644 --- a/awx/ui_next/src/screens/Credential/CredentialDetail/CredentialDetail.test.jsx +++ b/awx/ui_next/src/screens/Credential/CredentialDetail/CredentialDetail.test.jsx @@ -111,7 +111,7 @@ describe('', () => { 'Privilege Escalation Password', 'Prompt on launch' ); - expect(wrapper.find(`Detail[label="Options"] ListItem`).text()).toEqual( + expect(wrapper.find(`Detail[label="Enabled Options"] li`).text()).toEqual( 'Authorize' ); }); diff --git a/awx/ui_next/src/screens/Inventory/InventorySourceDetail/InventorySourceDetail.jsx b/awx/ui_next/src/screens/Inventory/InventorySourceDetail/InventorySourceDetail.jsx index 5f9213328b..bc617d7a68 100644 --- a/awx/ui_next/src/screens/Inventory/InventorySourceDetail/InventorySourceDetail.jsx +++ b/awx/ui_next/src/screens/Inventory/InventorySourceDetail/InventorySourceDetail.jsx @@ -1,9 +1,13 @@ import React, { useCallback, useEffect, useState } from 'react'; import { Link, useHistory } from 'react-router-dom'; - import { t } from '@lingui/macro'; - -import { Button, List, ListItem } from '@patternfly/react-core'; +import { + Button, + TextList, + TextListItem, + TextListVariants, + TextListItemVariants, +} from '@patternfly/react-core'; import AlertModal from '../../../components/AlertModal'; import { CardBody, CardActionsRow } from '../../../components/Card'; import { VariablesDetail } from '../../../components/CodeEditor'; @@ -19,7 +23,6 @@ import { UserDateDetail, } from '../../../components/DetailList'; import ErrorDetail from '../../../components/ErrorDetail'; -import Popover from '../../../components/Popover'; import useRequest from '../../../util/useRequest'; import { InventorySourcesAPI } from '../../../api'; import { relatedResourceDeleteRequests } from '../../../util/getRelatedResourceDeleteDetails'; @@ -112,71 +115,28 @@ function InventorySourceDetail({ inventorySource }) { update_on_project_update ) { optionsList = ( - + {overwrite && ( - - {t`Overwrite`} - - {t`If checked, any hosts and groups that were - previously present on the external source but are now removed - will be removed from the inventory. Hosts and groups - that were not managed by the inventory source will be promoted - to the next manually created group or if there is no manually - created group to promote them into, they will be left in the "all" - default group for the inventory.`} -
    -
    - {t`When not checked, local child - hosts and groups not found on the external source will remain - untouched by the inventory update process.`} - - } - /> -
    + + {t`Overwrite local groups and hosts from remote inventory source`} + )} {overwrite_vars && ( - - {t`Overwrite variables`} - - {t`If checked, all variables for child groups - and hosts will be removed and replaced by those found - on the external source.`} -
    -
    - {t`When not checked, a merge will be performed, - combining local variables with those found on the - external source.`} - - } - /> -
    + + {t`Overwrite local variables from remote inventory source`} + )} {update_on_launch && ( - + {t`Update on launch`} - - + )} {update_on_project_update && ( - + {t`Update on project update`} - - + )} -
    + ); } @@ -242,7 +202,7 @@ function InventorySourceDetail({ inventorySource }) { /> )} {optionsList && ( - + )} {source_vars && ( { expect(wrapper.find('VariablesDetail').prop('value')).toEqual( '---\nfoo: bar' ); - wrapper.find('Detail[label="Options"] li').forEach(option => { + wrapper.find('Detail[label="Enabled Options"] li').forEach(option => { expect([ - 'Overwrite', - 'Overwrite variables', + 'Overwrite local groups and hosts from remote inventory source', + 'Overwrite local variables from remote inventory source', 'Update on launch', 'Update on project update', ]).toContain(option.text()); diff --git a/awx/ui_next/src/screens/Project/ProjectDetail/ProjectDetail.jsx b/awx/ui_next/src/screens/Project/ProjectDetail/ProjectDetail.jsx index 6e1bad5b24..0882456b5f 100644 --- a/awx/ui_next/src/screens/Project/ProjectDetail/ProjectDetail.jsx +++ b/awx/ui_next/src/screens/Project/ProjectDetail/ProjectDetail.jsx @@ -5,8 +5,10 @@ import styled from 'styled-components'; import { Button, ClipboardCopy, - List, - ListItem, + TextList, + TextListItem, + TextListVariants, + TextListItemVariants, Tooltip, } from '@patternfly/react-core'; import { Project } from '../../../types'; @@ -78,17 +80,33 @@ function ProjectDetail({ project }) { allow_override ) { optionsList = ( - - {scm_clean && {t`Clean`}} - {scm_delete_on_update && {t`Delete on Update`}} + + {scm_clean && ( + {t`Discard local changes before syncing`} + )} + {scm_delete_on_update && ( + {t`Delete the project before syncing`} + )} {scm_track_submodules && ( - {t`Track submodules latest commit on branch`} + {t`Track submodules latest commit on branch`} )} {scm_update_on_launch && ( - {t`Update Revision on Launch`} + {t`Update revision on job launch`} )} - {allow_override && {t`Allow Branch Override`}} - + {allow_override && ( + {t`Allow branch override`} + )} + ); } @@ -196,7 +214,6 @@ function ProjectDetail({ project }) { } /> )} - {optionsList && } - + {optionsList && ( + + )} {summary_fields.user_capabilities?.edit && ( diff --git a/awx/ui_next/src/screens/Project/ProjectDetail/ProjectDetail.test.jsx b/awx/ui_next/src/screens/Project/ProjectDetail/ProjectDetail.test.jsx index 34ef0d6beb..fa627ff09f 100644 --- a/awx/ui_next/src/screens/Project/ProjectDetail/ProjectDetail.test.jsx +++ b/awx/ui_next/src/screens/Project/ProjectDetail/ProjectDetail.test.jsx @@ -70,7 +70,7 @@ describe('', () => { scm_refspec: 'refs/remotes/*', scm_clean: true, scm_delete_on_update: true, - scm_track_submodules: false, + scm_track_submodules: true, credential: 100, status: 'successful', organization: 10, @@ -127,12 +127,13 @@ describe('', () => { ); expect( wrapper - .find('Detail[label="Options"]') + .find('Detail[label="Enabled Options"]') .containsAllMatchingElements([ -
  • Clean
  • , -
  • Delete on Update
  • , -
  • Update Revision on Launch
  • , -
  • Allow Branch Override
  • , +
  • Discard local changes before syncing
  • , +
  • Delete the project before syncing
  • , +
  • Track submodules latest commit on branch
  • , +
  • Update revision on job launch
  • , +
  • Allow branch override
  • , ]) ).toEqual(true); }); @@ -151,7 +152,7 @@ describe('', () => { const wrapper = mountWithContexts( ); - expect(wrapper.find('Detail[label="Options"]').length).toBe(0); + expect(wrapper.find('Detail[label="Enabled Options"]').length).toBe(0); }); test('should have proper number of delete detail requests', () => { diff --git a/awx/ui_next/src/screens/Template/JobTemplateDetail/JobTemplateDetail.jsx b/awx/ui_next/src/screens/Template/JobTemplateDetail/JobTemplateDetail.jsx index 914441a9d3..1e2df548c8 100644 --- a/awx/ui_next/src/screens/Template/JobTemplateDetail/JobTemplateDetail.jsx +++ b/awx/ui_next/src/screens/Template/JobTemplateDetail/JobTemplateDetail.jsx @@ -115,28 +115,37 @@ function JobTemplateDetail({ template }) { ); const generateCallBackUrl = `${window.location.origin + url}callback/`; const renderOptionsField = - become_enabled || host_config_key || allow_simultaneous || use_fact_cache; + become_enabled || + host_config_key || + allow_simultaneous || + use_fact_cache || + webhook_service; const renderOptions = ( {become_enabled && ( - {t`Enable Privilege Escalation`} + {t`Privilege Escalation`} )} {host_config_key && ( - {t`Allow Provisioning Callbacks`} + {t`Provisioning Callbacks`} )} {allow_simultaneous && ( - {t`Enable Concurrent Jobs`} + {t`Concurrent Jobs`} )} {use_fact_cache && ( - {t`Use Fact Storage`} + {t`Fact Storage`} + + )} + {webhook_service && ( + + {t`Webhooks`} )} @@ -258,9 +267,6 @@ function JobTemplateDetail({ template }) { } /> )} - {renderOptionsField && ( - - )} + {renderOptionsField && ( + + )} {summary_fields.credentials && summary_fields.credentials.length > 0 && ( {template.allow_simultaneous && ( - {t`- Enable Concurrent Jobs`} + {t`Concurrent Jobs`} )} {template.webhook_service && ( - {t`- Enable Webhooks`} + {t`Webhooks`} )} @@ -186,9 +186,6 @@ function WorkflowJobTemplateDetail({ template }) { } /> )} - {renderOptionsField && ( - - )} + {renderOptionsField && ( + + )} {summary_fields.labels?.results?.length > 0 && (