Skip to content

Commit

Permalink
adapt UI and fix service
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Jul 11, 2023
1 parent 21c64d6 commit f889ae2
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 19 deletions.
2 changes: 1 addition & 1 deletion service/lib/agama/dbus/clients/questions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

require "agama/dbus/clients/base"
require "agama/dbus/clients/question"
require "agama/luks_activation_question"
require "agama/dbus/clients/question_with_password"

module Agama
module DBus
Expand Down
2 changes: 1 addition & 1 deletion service/lib/agama/storage/callbacks/activate_luks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# To contact SUSE LLC about this file by physical or electronic mail, you may
# find current contact information at www.suse.com.

require "agama/luks_activation_question"
require "agama/question_with_password"
require "y2storage/disk_size"

module Agama
Expand Down
19 changes: 9 additions & 10 deletions web/src/client/questions.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ const DBUS_CONFIG = {
question: {
ifaces: {
generic: "org.opensuse.Agama.Questions1.Generic",
luksActivation: "org.opensuse.Agama.Questions1.LuksActivation"
withPassword: "org.opensuse.Agama.Questions1.WithPassword"
}
}
};

const QUESTION_TYPES = {
generic: "generic",
luksActivation: "luksActivation"
withPassword: "withPassword"
};

/**
Expand Down Expand Up @@ -75,8 +75,6 @@ const fetchValue = (ifaceProperties, key) => {
};

/**
* Builds a question from the given D-Bus question
*
* @param {Object} dbusQuestion
* @return {Object}
*/
Expand All @@ -93,15 +91,16 @@ function buildQuestion(dbusQuestion) {
question.options = fetchValue(dbusProperties, "Options");
question.defaultOption = fetchValue(dbusProperties, "DefaultOption");
question.text = fetchValue(dbusProperties, "Text");
question.class = fetchValue(dbusProperties, "Class");
question.data = fetchValue(dbusProperties, "Data");
question.answer = fetchValue(dbusProperties, "Answer");
}

if (ifaces.includes(DBUS_CONFIG.question.ifaces.luksActivation)) {
const dbusProperties = ifacesAndProperties[DBUS_CONFIG.question.ifaces.luksActivation];
if (ifaces.includes(DBUS_CONFIG.question.ifaces.withPassword)) {
const dbusProperties = ifacesAndProperties[DBUS_CONFIG.question.ifaces.withPassword];

question.type = QUESTION_TYPES.luksActivation;
question.type = QUESTION_TYPES.withPassword;
question.password = fetchValue(dbusProperties, "Password");
question.attempt = fetchValue(dbusProperties, "Attempt");
}

return question;
Expand Down Expand Up @@ -145,8 +144,8 @@ class QuestionsClient {
async answer(question) {
const path = DBUS_CONFIG.questions.path + "/" + question.id;

if (question.type === QUESTION_TYPES.luksActivation) {
const proxy = await this.client.proxy(DBUS_CONFIG.question.ifaces.luksActivation, path);
if (question.type === QUESTION_TYPES.withPassword) {
const proxy = await this.client.proxy(DBUS_CONFIG.question.ifaces.withPassword, path);
proxy.Password = question.password;
}

Expand Down
2 changes: 1 addition & 1 deletion web/src/components/questions/LuksActivationQuestion.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default function LuksActivationQuestion({ question, answerCallback }) {
aria-label="Question"
titleIconVariant={() => <Icon name="lock" size="24" />}
>
{ renderAlert(question.attempt) }
{ renderAlert(question.data.attempt) }
<Text>
{ question.text }
</Text>
Expand Down
12 changes: 6 additions & 6 deletions web/src/components/questions/Questions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ import { useCancellablePromise } from "~/utils";

import { GenericQuestion, LuksActivationQuestion } from "~/components/questions";

const QUESTION_TYPES = {
generic: GenericQuestion,
luksActivation: LuksActivationQuestion
};

export default function Questions() {
const client = useInstallerClient();
const { cancellablePromise } = useCancellablePromise();
Expand Down Expand Up @@ -67,6 +62,11 @@ export default function Questions() {

// Renders the first pending question
const [currentQuestion] = pendingQuestions;
const QuestionComponent = QUESTION_TYPES[currentQuestion.type];
let QuestionComponent = GenericQuestion;
// show specialized popup for luks activation question
// more can follow as it will be needed
if (currentQuestion.class === "storage.luks_activation") {
QuestionComponent = LuksActivationQuestion;
}
return <QuestionComponent question={currentQuestion} answerCallback={answerQuestion} />;
}

0 comments on commit f889ae2

Please sign in to comment.