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: updated permissions header to be consistent #29880

Merged
merged 5 commits into from
Jan 24, 2025
Merged
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
31 changes: 22 additions & 9 deletions ui/pages/permissions-connect/permissions-connect.component.js
NidhiKJha marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ export default class PermissionConnect extends Component {
this.props.permissionsRequest,
),
permissionsApproved: null,
origin: this.props.origin,
targetSubjectMetadata: this.props.targetSubjectMetadata || {},
snapsInstallPrivacyWarningShown: this.props.snapsInstallPrivacyWarningShown,
};

componentDidMount() {
Expand All @@ -153,7 +156,6 @@ export default class PermissionConnect extends Component {
history.replace(DEFAULT_ROUTE);
return;
}

if (history.location.pathname === connectPath && !isRequestingAccounts) {
switch (requestType) {
case 'wallet_installSnap':
Expand All @@ -175,8 +177,17 @@ export default class PermissionConnect extends Component {
}

componentDidUpdate(prevProps) {
const { permissionsRequest, lastConnectedInfo, origin } = this.props;
const { redirecting } = this.state;
const { permissionsRequest, lastConnectedInfo, targetSubjectMetadata } =
this.props;
const { redirecting, origin } = this.state;

// We cache the last known good targetSubjectMetadata since it may be null when the approval is cleared
if (
NidhiKJha marked this conversation as resolved.
Show resolved Hide resolved
targetSubjectMetadata?.origin &&
prevProps.targetSubjectMetadata?.origin !== targetSubjectMetadata?.origin
) {
this.setState({ targetSubjectMetadata });
}

if (!permissionsRequest && prevProps.permissionsRequest && !redirecting) {
const accountsLastApprovedTime =
Expand Down Expand Up @@ -262,7 +273,7 @@ export default class PermissionConnect extends Component {
}

renderTopBar(permissionsRequestId) {
const { targetSubjectMetadata } = this.props;
const { targetSubjectMetadata } = this.state;
const handleCancelFromHeader = () => {
this.cancelPermissionsRequest(permissionsRequestId);
};
Expand Down Expand Up @@ -319,12 +330,14 @@ export default class PermissionConnect extends Component {
rejectPendingApproval,
setSnapsInstallPrivacyWarningShownStatus,
approvePermissionsRequest,
snapsInstallPrivacyWarningShown,
origin,
history,
} = this.props;
const { selectedAccountAddresses, permissionsApproved, redirecting } =
this.state;
const {
selectedAccountAddresses,
permissionsApproved,
redirecting,
snapsInstallPrivacyWarningShown,
} = this.state;

const isRequestingSnap = isSnapId(permissionsRequest?.metadata?.origin);

Expand Down Expand Up @@ -366,7 +379,7 @@ export default class PermissionConnect extends Component {
rejectPermissionsRequest={(requestId) =>
this.cancelPermissionsRequest(requestId)
}
activeTabOrigin={origin}
activeTabOrigin={this.state.origin}
request={permissionsRequest}
permissionsRequestId={permissionsRequestId}
approveConnection={this.approveConnection}
Expand Down
Loading