Skip to content

Commit

Permalink
issue #150 - disable powerful actions tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
Manvel committed Mar 31, 2024
1 parent d04c670 commit bdd35e4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 76 deletions.
23 changes: 2 additions & 21 deletions src/js/ui/projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,16 +175,6 @@ async function populateActions(items)
onActionSelect();
}

function projectHasAction(id, types)
{
const project = projectsComp.getItem(id);
if (project.type !== "project" || !project.actions)
return false;

const filterTypes = (action) => types.indexOf(action.type) >= 0;
return project.actions.filter(filterTypes).length > 0;
}

async function initPlayButtonTooltip()
{
const text = warnings["powerFullActions"].text;
Expand All @@ -206,17 +196,8 @@ async function hideWarningMessage()

async function setPlayButtonTooltip()
{
const {id} = await projectsComp.getSelectedItem();
if (await prefs.get("hidePowerfulActionWarning") == true)
{
playButtonTooltip.disable();
}
else if (projectHasAction(id, ["bg-inject", "cs-inject"])) {
playButtonTooltip.enable();
}
else {
playButtonTooltip.disable();
}
// Disabling since MV3 as we no more have "Powerful" actions.
playButtonTooltip.disable();
}

async function onProjectSelect()
Expand Down
57 changes: 2 additions & 55 deletions tests/tests/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,8 @@ it("Selecting action populates input deselecting clears", async() =>
itemHasTypeAndInputs(await cbaTableGetItem(cbaTableQuery, 1), type, [input1, input2]);

equal(await getValue(inputEventQuery), type);
equal(await getValue(inputDataQuery), input1);
equal(await getValue(inputValueQuery), input2);
equal(await getValue(inputDataQuery), "");
equal(await getValue(inputValueQuery), "");
});

it("dragndropping from the functions table or self-organizing actions table should update actions accordingly", async() =>
Expand Down Expand Up @@ -603,59 +603,6 @@ it("click and bg-function actions doesn't stop project execution on error", asyn
equal(await getBadgeText(), "");
});

it("Selecting a project that has 'bg-inject' or 'cs-inject' shows powerful actions tooltip unless 'Hide message' is clicked", async() =>
{
const projects = [{
id: "group",
text: "group",
type: "group",
expanded: false,
subItems: [
{
id: "project",
text: "project",
type: "project",
actions: [{type: "cs-inject", inputs: ["alert('Hello from CBA!')", ""]}]
},
{
id: "project1",
text: "project1",
type: "project",
actions: [{type: "bg-inject", inputs: ["alert('Hello from CBA!')", ""]}]
},
{
id: "project2",
text: "project2",
type: "project",
actions: [{type: "inject", inputs: ["alert('Hello from CBA!')", ""]}]
}
]
}];
await setProjects(projects);

await cbaListItemExpand(cbaListQuery, "group");
await wait();

ok(await isDisabled(playButtonTooltipQuery));

await cbaListItemSelect(cbaListQuery, "project", "group");
notOk(await isDisabled(playButtonTooltipQuery));

await cbaListItemSelect(cbaListQuery, "project1", "group");
notOk(await isDisabled(playButtonTooltipQuery));
await cbaListItemSelect(cbaListQuery, "project2", "group");
ok(await isDisabled(playButtonTooltipQuery));

await cbaListItemSelect(cbaListQuery, "project", "group");
notOk(await isDisabled(playButtonTooltipQuery));
await hoverElement(playButtonTooltipQuery);
await cbaTooltipClickAction(playButtonTooltipQuery);
ok(await isDisabled(playButtonTooltipQuery));

await cbaListItemSelect(cbaListQuery, "project1", "group");
ok(await isDisabled(playButtonTooltipQuery));
});

it("Project with bg-inject render warning both in project table and actions table", async() =>
{
const projects = [{
Expand Down

0 comments on commit bdd35e4

Please sign in to comment.