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

fix: Remove Auto-attach button #68

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 2 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,10 @@ function openRegisterDialog() {
password: '',
activation_keys: '',
org: '',
insights: true,
insights: subscriptionsClient.insightsAvailable,
insights_available: subscriptionsClient.insightsAvailable,
insights_detected: false,
register_method: 'account',
auto_attach: true
register_method: 'account'
});

Insights.detect().then(installed => {
Expand Down Expand Up @@ -135,7 +134,6 @@ function initStore(rootElement) {
syspurpose: subscriptionsClient.syspurposeStatus.info,
syspurpose_status: subscriptionsClient.syspurposeStatus.status,
insights_available: subscriptionsClient.insightsAvailable,
autoAttach: subscriptionsClient.autoAttach,
org: subscriptionsClient.org,
dismissError: dismissStatusError,
register: openRegisterDialog,
Expand Down
18 changes: 2 additions & 16 deletions src/subscriptions-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ function createProxy(name) {
// creates multiple services otherwise only readies one proxy at a time
const configService = createProxy('Config');
const registerServer = createProxy('RegisterServer');
const attachService = createProxy('Attach');
const entitlementService = createProxy('Entitlement');
const unregisterService = createProxy('Unregister');
const productsService = createProxy('Products');
Expand Down Expand Up @@ -355,7 +354,7 @@ client.registerSystem = (subscriptionDetails, update_progress) => new Promise((r
else {
console.debug('registering using username and password');
const registration_options = {
"enable_content": dbus_bool(subscriptionDetails.auto_attach)
"enable_content": dbus_bool(true)
};
console.log('registration_options:', registration_options);
if (update_progress)
Expand Down Expand Up @@ -426,7 +425,7 @@ client.registerSystem = (subscriptionDetails, update_progress) => new Promise((r
}
})
.catch(error => {
console.error('error during auto-attach', error);
console.error('error during enabling content', error);
isRegistering = false;
reject(parseErrorMessage(error));
})
Expand Down Expand Up @@ -463,19 +462,6 @@ client.unregisterSystem = () => {
});
};

client.autoAttach = () => {
console.debug('auto-attaching ...');
return attachService.AutoAttach('', {}, userLang)
.then(() => needRender())
.catch(error => {
console.error('error during auto-attach', error);
client.subscriptionStatus.error = {
'severity': parseErrorSeverity(error),
'msg': parseErrorMessage(error)
};
});
};

function statusUpdateFailed(reason) {
console.warn("Subscription status update failed:", reason);
client.subscriptionStatus.status = (reason && reason.problem) || "not-found";
Expand Down
22 changes: 6 additions & 16 deletions src/subscriptions-register.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,12 @@ class SubscriptionRegisterDialog extends React.Component {
);
}
let insights;
let insights_checkbox_disabled = true;
if (this.props.insights_available === true) {
insights_checkbox_disabled = false;
} else {
if (this.props.auto_attach === true) {
insights_checkbox_disabled = false;
}
let insights_checkbox_disabled = false;
// Disable registration of insights-client only in the corner case, when
// insights-client is not installed, and it is not possible to install it,
// because PackageKit is not available
if (this.props.insights_available === false) {
insights_checkbox_disabled = true;
}
insights = [
<FormGroup key="0" fieldId="subscription-insights" label={_("Insights")} hasNoPaddingTop>
Expand Down Expand Up @@ -176,15 +175,6 @@ class SubscriptionRegisterDialog extends React.Component {
</Flex>
{ credentials }
</FormGroup>
<FormGroup className="control-label" label={_("Subscriptions")} hasNoPaddingTop>
<Checkbox id="subscription-auto-attach-use" isChecked={this.props.auto_attach}
label={_("Attach automatically")}
onChange={value => {
this.props.onChange('auto_attach', value);
this.props.insights && !value && this.props.onChange('insights', value);
}}
/>
</FormGroup>
{ insights }
</Form>
);
Expand Down
36 changes: 0 additions & 36 deletions src/subscriptions-view.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,30 +37,6 @@ let _ = cockpit.gettext;
class InstalledProducts extends React.Component {
constructor(props) {
super(props);
this.state = {
attaching_in_progress: false,
attach_button_text: _("Auto-attach")
};
this.handleAutoAttach = this.handleAutoAttach.bind(this);
}

handleAutoAttach(event) {
// only consider primary mouse button
if (!event || event.button !== 0)
return;
if (this.props.autoAttach) {
this.setState({
attaching_in_progress: true,
attach_button_text: _("Auto-attaching ...")
});
this.props.autoAttach()
.finally(() =>
this.setState({
attaching_in_progress: false,
attach_button_text: _("Auto-attach")
})
);
}
}

render() {
Expand All @@ -78,18 +54,6 @@ class InstalledProducts extends React.Component {
}

let card_actions;
if (sca_mode === false) {
card_actions = (
<CardActions>
<Button
isDisabled={this.state.attaching_in_progress || this.props.status === 'unknown'}
onClick={this.handleAutoAttach}>
{ this.state.attach_button_text }
</Button>
</CardActions>
)
}

let entries = this.props.products.map(function (itm) {
let status_color;
let status_text;
Expand Down
45 changes: 7 additions & 38 deletions test/check-subscriptions
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ password=foobar

class TestSubscriptions(SubscriptionsCase):
def testRegister(self):
m = self.machine
b = self.browser

self.login_and_go("/subscriptions")
Expand All @@ -228,7 +229,8 @@ class TestSubscriptions(SubscriptionsCase):
b.set_input_text("#subscription-register-password", "wrongpass")

# Do not try to connect to insights
b.set_checked("#subscription-insights", False)
if m.image.startswith("rhel-"):
b.set_checked("#subscription-insights", False)
Comment on lines +232 to +233
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should not be a problem to do regardless of the OS, so simply avoid the check altogether


# try to register
dialog_register_button_sel = "footer .pf-m-primary"
Expand Down Expand Up @@ -272,6 +274,7 @@ class TestSubscriptions(SubscriptionsCase):
b.wait_visible(register_button_sel)

def testRegisterWithKey(self):
m = self.machine
b = self.browser

self.login_and_go("/subscriptions")
Expand All @@ -287,7 +290,8 @@ class TestSubscriptions(SubscriptionsCase):
b.set_input_text("#subscription-register-url-custom", CANDLEPIN_URL)

# Do not try to connect to insights
b.set_checked("#subscription-insights", False)
if m.image.startswith("rhel-"):
b.set_checked("#subscription-insights", False)
Comment on lines +293 to +294
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto


# select registration method "activation key"
activation_key_checkbox = "#subscription-register-activation-key-method"
Expand Down Expand Up @@ -320,42 +324,6 @@ class TestSubscriptions(SubscriptionsCase):
# find another one that isn't subscribed too
self.wait_subscription(PRODUCT_SHARED, False)

def testRegisterWithoutAutoAttach(self):
b = self.browser

self.login_and_go("/subscriptions")

# wait until we can open the registration dialog
register_button_sel = "button:contains('Register')"
b.click(register_button_sel)

b.wait_visible("#subscription-register-url")

# enter server and correct login data
b.set_val("#subscription-register-url", "custom")
b.set_input_text("#subscription-register-url-custom", CANDLEPIN_URL)
b.set_input_text("#subscription-register-username", "doc")
b.set_input_text("#subscription-register-password", "password")
b.set_input_text("#subscription-register-org", "snowwhite")

b.click("#subscription-auto-attach-use")

dialog_register_button_sel = "footer .pf-m-primary"
b.click(dialog_register_button_sel)

# dialog should disappear
with b.wait_timeout(60):
b.wait_not_present(dialog_register_button_sel)

# this product should not be subscribed ATM, because auto-attach was skipped
self.wait_subscription(PRODUCT_SHARED, False)

b.click("button:contains('Auto-attach')")

# find another one that is subscribed
with b.wait_timeout(60):
self.wait_subscription(PRODUCT_SHARED, True)

def testUnpriv(self):
self.machine.execute("useradd junior; echo junior:foobar | chpasswd")
self.login_and_go("/subscriptions", user="junior")
Expand Down Expand Up @@ -476,6 +444,7 @@ class TestSubscriptions(SubscriptionsCase):


class TestSubscriptionsPackages(SubscriptionsCase, PackageCase):
@skipUnlessDistroFamily("rhel", "Insights support is specific to RHEL")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no need to disable this test on non-RHEL OSes: the test itself creates a fake insights-client package which is added to the local repositories of the system (so PackageKit can install it)

def testMissingPackages(self):
m = self.machine
b = self.browser
Expand Down
Loading