Skip to content

Commit

Permalink
Revert "feat(dashboard): gh #660 Added terminate session feature (#60)…
Browse files Browse the repository at this point in the history
…" (#63)

This reverts commit 4bfa1ed.
  • Loading branch information
whorka authored Apr 20, 2022
1 parent d51a57a commit aa8f4c9
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ describe('Sid Dashboard - Homepage', () => {
const activeLaunchers = cy.sid.launchers.filter(l => Cypress.env('active_launchers').includes(l.id))
Cypress.config('baseUrl', baseUrl);

const cancelSession = sessionId => {
const deleteSession = sessionId => {
cy.log(`Deleting session: ${sessionId}`)
cy.get(`div#sessions-container > div#${sessionId}`).should('be.visible')
cy.get(`div#sessions-container > div#${sessionId}`).find('div a.btn-terminate').click()
cy.get('div.modal-dialog div.modal-body').should('contain.text', 'Are you sure')
cy.get(`div#sessions-container > div#${sessionId}`).find('div a.btn-delete').click()
cy.get('div.modal-dialog div.modal-body').should('have.text', 'Are you sure?')
cy.get('div.modal-dialog button.commit').click()
//PARTIAL TEXT CHECK => BETTER RESILIENCE
cy.get('div.alert-success').should('contain.text', 'Session was successfully')
cy.get('div.alert-success').should('contain.text', 'Session was successfully deleted')
}

const cleanupSessions = () => {
Expand All @@ -24,9 +23,9 @@ describe('Sid Dashboard - Homepage', () => {
return
}

cy.log(`sessions to cancel: ${numberOfSessions}`)
cy.log(`sessions to delete: ${numberOfSessions}`)
const sessionId = $sessionsContainer.children().first().attr('id')
cancelSession(sessionId)
deleteSession(sessionId)

cleanupSessions()
})
Expand Down Expand Up @@ -78,7 +77,7 @@ describe('Sid Dashboard - Homepage', () => {
})

//CLEANUP
cancelSession(session.sessionId)
deleteSession(session.sessionId)
})
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ describe('Sid Dashboard - Interactive Apps', () => {
const interactiveApps = Cypress.env('dashboard_applications')
Cypress.config('baseUrl', baseUrl);

const cancelSession = sessionId => {
const deleteSession = sessionId => {
cy.log(`Deleting session: ${sessionId}`)
cy.get(`div[data-toggle="poll"].sessions > div#${sessionId}`).should('be.visible')
cy.get(`div[data-toggle="poll"].sessions > div#${sessionId}`).find('div a.btn-terminate').click()
cy.get('div.modal-dialog div.modal-body').should('contain.text', 'Are you sure')
cy.get(`div[data-toggle="poll"].sessions > div#${sessionId}`).find('div a.btn-delete').click()
cy.get('div.modal-dialog div.modal-body').should('have.text', 'Are you sure?')
cy.get('div.modal-dialog button.commit').click()
cy.get('div.alert-success').should('contain.text', 'Session was successfully')
cy.get('div.alert-success').should('contain.text', 'Session was successfully deleted')
}

const cleanupSessions = () => {
Expand All @@ -24,7 +24,7 @@ describe('Sid Dashboard - Interactive Apps', () => {
}
const completedSession = $item.find('div.pull-right:contains("Completed")').length != 0
if(!completedSession) {
cancelSession($item.attr('id'))
deleteSession($item.attr('id'))
}
})
}
Expand Down Expand Up @@ -74,9 +74,9 @@ describe('Sid Dashboard - Interactive Apps', () => {
expect(titlesArray).to.contain('basic parameters:')
expect(titlesArray).to.contain('problems with this session?')
})
//CANCEL SESSION
//DELETE SESSION
cy.get('div[data-toggle="poll"].sessions > div').first().then(sessionElement => {
cancelSession(sessionElement.attr('id'))
deleteSession(sessionElement.attr('id'))
})
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,36 +23,11 @@
}

.btn-sid-delete {
color: #90100C;
}

.btn-sid-delete:hover {
color: #fff;
background-color: #90100C;
border-color: #90100C;
}

.btn-sid-terminate {
color: #dd6561;
}

.btn-sid-terminate:hover {
.btn-sid-delete:hover {
color: #fff;
background-color: #dd6561;
border-color: #dd6561;
}

/* OVERRIDE CONFIRM BUTTON FOR MODAL DIALOG */
.modal-dialog {
.btn.commit.btn-danger {
color: #fff;
background-color: #337ab7;
border-color: #2e6da4;
}

.btn.commit.btn-danger:hover {
color: #fff;
background-color: #286090;
border-color: #204d74;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,15 @@ def destroy
set_session

redirect = get_redirect || batch_connect_sessions_url
message_key = delete_session_panel? ? 'delete' : 'terminate'

if @session.destroy(delete_session_panel?)
if @session.destroy
respond_to do |format|
format.html { redirect_to redirect, notice: t("dashboard.batch_connect_sessions_status_blurb_#{message_key}_success") }
format.html { redirect_to redirect, notice: t('dashboard.batch_connect_sessions_status_blurb_delete_success') }
format.json { head :no_content }
end
else
respond_to do |format|
format.html { redirect_to redirect, alert: t("dashboard.batch_connect_sessions_status_blurb_#{message_key}_failure") }
format.html { redirect_to redirect, alert: t('dashboard.batch_connect_sessions_status_blurb_delete_failure') }
format.json { render json: @session.errors, status: :unprocessable_entity }
end
end
Expand All @@ -63,8 +62,4 @@ def set_app_groups
def get_redirect
params[:r] ? params[:r] : nil
end

def delete_session_panel?
params[:delete] ? params[:delete] == 'true' : true
end
end
31 changes: 10 additions & 21 deletions dashboard/application/app/helpers/batch_connect/sessions_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def session_view(session)
capture do
concat(
content_tag(:div) do
concat content_tag(:div, delete_terminate_buttons(session))
concat content_tag(:div, delete(session))
concat host(session)
concat created(session)
concat requested_parameters(session)
Expand Down Expand Up @@ -222,26 +222,15 @@ def status_context(session)
end
end

def delete_terminate_buttons(session)
if session.completed?
link_to(
icon("fas", "trash-alt", t('dashboard.batch_connect_sessions_delete_title'), class: "fa-fw"),
batch_connect_session_path(session, r: session.redirect),
method: :delete,
class: "btn btn-sid-delete pull-right btn-delete",
title: t('dashboard.batch_connect_sessions_delete_hover'),
data: { confirm: t('dashboard.batch_connect_sessions_delete_confirm'), cancel: 'Close', toggle: "tooltip", placement: "bottom"}
)
else
link_to(
icon("fas", "times-circle", t('dashboard.batch_connect_sessions_terminate_title'), class: "fa-fw"),
batch_connect_session_path(session, r: session.redirect, delete: 'false'),
method: :delete,
class: "btn btn-sid-terminate pull-right btn-terminate",
title: t('dashboard.batch_connect_sessions_terminate_hover'),
data: { confirm: t('dashboard.batch_connect_sessions_terminate_confirm'), cancel: 'Close', toggle: "tooltip", placement: "bottom"}
)
end
def delete(session)
link_to(
icon("fas", "trash-alt", t('dashboard.batch_connect_sessions_delete_title'), class: "fa-fw"),
batch_connect_session_path(session, r: session.redirect),
method: :delete,
class: "btn btn-sid-delete pull-right btn-delete",
title: t('dashboard.batch_connect_sessions_delete_hover'),
data: { confirm: t('dashboard.batch_connect_sessions_delete_confirm'), toggle: "tooltip", placement: "bottom"}
)
end

def novnc_link(connect, view_only: false)
Expand Down
4 changes: 2 additions & 2 deletions dashboard/application/app/models/batch_connect/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,9 @@ def script_options(opts = {})

# Delete this session's job and database record
# @return [Boolean] whether successfully deleted
def destroy(delete_data = true)
def destroy
adapter.delete(job_id) unless completed?
db_file.delete if delete_data
db_file.delete
true
rescue ClusterNotFound, AdapterNotAllowed, OodCore::JobAdapterError => e
errors.add(:delete, e.message)
Expand Down
7 changes: 1 addition & 6 deletions dashboard/application/config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,9 @@ en:
If this job failed to submit because of an invalid job name
please ask your administrator to configure OnDemand to set the
environment variable OOD_JOB_NAME_ILLEGAL_CHARS.
batch_connect_sessions_delete_confirm: "Are you sure you want to delete the session?<br />Deleting is permanent, and will delete all session details."
batch_connect_sessions_delete_confirm: "Are you sure?"
batch_connect_sessions_delete_hover: "Delete Session"
batch_connect_sessions_delete_title: "Delete"
batch_connect_sessions_terminate_confirm: "Are you sure you want to end the session?<br />Session details are saved for reference and reuse until you delete them.<br /> Any unsaved work in this session will be lost."
batch_connect_sessions_terminate_hover: "Cancel Session"
batch_connect_sessions_terminate_title: "Cancel"
batch_connect_sessions_errors_staging: "Failed to stage the template with the following error:"
batch_connect_sessions_errors_submission: "Failed to submit session with the following error:"
batch_connect_sessions_novnc_launch: "Launch %{app_title}"
Expand All @@ -107,8 +104,6 @@ en:
batch_connect_sessions_status_blurb_create_success: "Session was successfully created."
batch_connect_sessions_status_blurb_delete_failure: "Failed to delete session."
batch_connect_sessions_status_blurb_delete_success: "Session was successfully deleted."
batch_connect_sessions_status_blurb_terminate_failure: "Failed to cancel session."
batch_connect_sessions_status_blurb_terminate_success: "Session was successfully cancelled."
batch_connect_sessions_status_starting: |
Your session is currently starting... Please be patient as this process can
take a few minutes.
Expand Down

0 comments on commit aa8f4c9

Please sign in to comment.