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

chore: dimmed as default disable method #1502

Merged
merged 13 commits into from
Dec 6, 2024
2 changes: 1 addition & 1 deletion ui/src/components/ConfigurationFormView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function ConfigurationFormView({ serviceName }) {
appearance="primary"
label={isSubmitting ? <WaitSpinner /> : _('Save')}
onClick={handleSubmit}
disabled={isSubmitting}
disabled={isSubmitting && 'dimmed'}
/>
</ButtonWrapper>
</>
Expand Down
4 changes: 2 additions & 2 deletions ui/src/components/DeleteModal/DeleteModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,13 @@ class DeleteModal extends Component<DeleteModalProps, DeleteModalState> {
appearance="secondary"
onClick={this.handleRequestClose}
label={_('Cancel')}
disabled={this.state.isDeleting}
disabled={this.state.isDeleting && 'dimmed'}
/>
<StyledButton
appearance="primary"
label={this.state.isDeleting ? <WaitSpinner /> : _('Delete')}
onClick={this.handleDelete}
disabled={this.state.isDeleting}
disabled={this.state.isDeleting && 'dimmed'}
soleksy-splunk marked this conversation as resolved.
Show resolved Hide resolved
/>
</Modal.Footer>
</ModalWrapper>
Expand Down
21 changes: 14 additions & 7 deletions ui/src/components/EntityModal/EntityModal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ describe('Oauth field disabled on edit - diableonEdit property', () => {
renderModalWithProps(props);
const oauthTextBox = getDisabledOauthField();
expect(oauthTextBox).toBeInTheDocument();
expect(oauthTextBox).not.toHaveAttribute('disabled');
expect(oauthTextBox).not.toHaveAttribute('readonly');
expect(oauthTextBox?.getAttribute('aria-disabled')).toBe('false');
soleksy-splunk marked this conversation as resolved.
Show resolved Hide resolved
});

it('Oauth Oauth - disableonEdit = true, oauth field disabled on edit', async () => {
Expand All @@ -82,7 +83,8 @@ describe('Oauth field disabled on edit - diableonEdit property', () => {

const oauthTextBox = getDisabledOauthField();
expect(oauthTextBox).toBeInTheDocument();
expect(oauthTextBox).toHaveAttribute('disabled');
expect(oauthTextBox).toHaveAttribute('readonly');
expect(oauthTextBox?.getAttribute('aria-disabled')).toBe('true');
});

it('Oauth Basic - Enable field equal false, so field disabled', async () => {
Expand All @@ -102,7 +104,8 @@ describe('Oauth field disabled on edit - diableonEdit property', () => {

const oauthTextBox = getDisabledBasicField();
expect(oauthTextBox).toBeInTheDocument();
expect(oauthTextBox).toHaveAttribute('disabled');
expect(oauthTextBox).toHaveAttribute('readonly');
expect(oauthTextBox?.getAttribute('aria-disabled')).toBe('true');
});

it('if oauth field not disabled with create after disableonEdit true', async () => {
Expand All @@ -120,7 +123,8 @@ describe('Oauth field disabled on edit - diableonEdit property', () => {
renderModalWithProps(props);
const oauthTextBox = getDisabledBasicField();
expect(oauthTextBox).toBeInTheDocument();
expect(oauthTextBox).not.toHaveAttribute('disabled');
expect(oauthTextBox).not.toHaveAttribute('readonly');
expect(oauthTextBox?.getAttribute('aria-disabled')).toBe('false');
});
});

Expand Down Expand Up @@ -163,7 +167,8 @@ describe('Options - Enable field property', () => {
renderModalWithProps(props);
const oauthTextBox = getDisabledOauthField();
expect(oauthTextBox).toBeInTheDocument();
expect(oauthTextBox).toHaveAttribute('disabled');
expect(oauthTextBox).toHaveAttribute('readonly');
expect(oauthTextBox?.getAttribute('aria-disabled')).toBe('true');
});

it('Oauth Basic - Enable field equal false, so field disabled', async () => {
Expand All @@ -181,7 +186,8 @@ describe('Options - Enable field property', () => {
renderModalWithProps(props);
const oauthTextBox = getDisabledOauthField();
expect(oauthTextBox).toBeInTheDocument();
expect(oauthTextBox).toHaveAttribute('disabled');
expect(oauthTextBox).toHaveAttribute('readonly');
expect(oauthTextBox?.getAttribute('aria-disabled')).toBe('true');
});

it('Oauth Basic - Fully enabled field, enabled: true, disableonEdit: false', async () => {
Expand All @@ -199,7 +205,8 @@ describe('Options - Enable field property', () => {
renderModalWithProps(props);
const oauthTextBox = getDisabledOauthField();
expect(oauthTextBox).toBeInTheDocument();
expect(oauthTextBox).not.toHaveAttribute('disabled');
expect(oauthTextBox).not.toHaveAttribute('readonly');
expect(oauthTextBox?.getAttribute('aria-disabled')).toBe('false');
});
});

Expand Down
4 changes: 2 additions & 2 deletions ui/src/components/EntityModal/EntityModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,14 @@ class EntityModal extends Component<EntityModalProps, EntityModalState> {
appearance="secondary"
onClick={this.handleRequestClose}
label={_('Cancel')}
disabled={this.state.isSubmititng}
disabled={this.state.isSubmititng && 'dimmed'}
/>
<StyledButton
className="saveBtn"
appearance="primary"
label={this.state.isSubmititng ? <WaitSpinner /> : this.buttonText}
onClick={this.handleSubmit}
disabled={this.state.isSubmititng}
disabled={this.state.isSubmititng && 'dimmed'}
/>
</Modal.Footer>
</ModalWrapper>
Expand Down
4 changes: 2 additions & 2 deletions ui/src/components/EntityPage/EntityPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,15 @@ function EntityPage({
appearance="secondary"
onClick={handleRequestClose}
label={_('Cancel')}
disabled={isSubmitting}
disabled={isSubmitting && 'dimmed'}
style={{ width: '80px' }}
/>
<StyledButton
type="Submit"
appearance="primary"
label={isSubmitting ? <WaitSpinner /> : buttonText}
onClick={handleSubmit}
disabled={isSubmitting}
disabled={isSubmitting && 'dimmed'}
style={{ width: '80px' }}
/>
</ButtonRow>
Expand Down
12 changes: 8 additions & 4 deletions ui/src/components/FormModifications/FormModifications.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,18 +127,22 @@ it('verify modification after text components change', async () => {
expect(parentElement).toHaveTextContent(mods.label);
};

expect(componentInput).toBeDisabled();
expect(componentInput).toHaveAttribute('readonly');
expect(componentInput.getAttribute('aria-disabled')).toBe('true');
verifyAllProps(componentParentElement, componentInput, mods1Field1);

expect(component2Input).toBeDisabled();
expect(component2Input).toHaveAttribute('readonly');
expect(component2Input.getAttribute('aria-disabled')).toBe('true');
verifyAllProps(component2ParentElement, component2Input, mods1Field2);

await userEvent.type(componentMakingModsTextBox1, secondValueToInput);

expect(componentInput).toBeEnabled();
expect(componentInput).not.toHaveAttribute('readonly');
expect(componentInput.getAttribute('aria-disabled')).toBe('false');
verifyAllProps(componentParentElement, componentInput, mods2Field1);

expect(component2Input).toBeEnabled();
expect(component2Input).not.toHaveAttribute('readonly');
expect(component2Input.getAttribute('aria-disabled')).toBe('false');
verifyAllProps(component2ParentElement, component2Input, mods2Field2);
});

Expand Down
4 changes: 2 additions & 2 deletions ui/src/components/InteractAllStatusButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export function InteractAllStatusButtons(props: DisableAllStatusButtonProps) {
setIsDisabling(false);
}}
role="button"
disabled={props.dataRows.length < 1}
disabled={props.dataRows.length < 1 && 'dimmed'}
>
Activate all
</InteractAllActionButton>
Expand All @@ -68,7 +68,7 @@ export function InteractAllStatusButtons(props: DisableAllStatusButtonProps) {
setIsDisabling(true);
}}
role="button"
disabled={props.dataRows.length < 1}
disabled={props.dataRows.length < 1 && 'dimmed'}
>
Deactivate all
</InteractAllActionButton>
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/TextComponent/TextComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class TextComponent extends Component<TextComponentProps> {
inline
error={this.props.error}
className={this.props.field}
disabled={this.props.disabled}
disabled={this.props.disabled && 'dimmed'}
value={
this.props.value === null || typeof this.props.value === 'undefined'
? ''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,14 @@ export const Base: Story = {
disabled: false,
},
};

export const AllPropsTrue: Story = {
args: {
handleChange: fn(),
value: 'default value',
field: 'field',
error: true,
encrypted: true,
disabled: true,
},
};
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading