Skip to content

Commit

Permalink
feat: simpler button label
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaucau committed Nov 17, 2023
1 parent 34ecb5d commit 1bdd0f7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 25 deletions.
13 changes: 6 additions & 7 deletions src/editor/components/GenerateAltButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,18 @@ export default ({
const { createSuccessNotice, createErrorNotice } = useDispatch(noticesStore);

const handleClick = async () => {
let confirmed = true;

if (attributes.alt.length) {
confirmed = confirm(
if (
attributes.alt.length &&
!confirm(
__(
"Are you sure you want to overwrite the existing alt text?",
"gpt-vision-img-alt-generator",
),
);
)
) {
return;
}

if (!confirmed) return;

try {
setIsGenerating(true);

Expand Down
7 changes: 1 addition & 6 deletions src/media/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ wp.media.view.Attachment.Details = wp.media.view.Attachment.Details.extend({
render: function () {
wp.media.view.Attachment.prototype.render.apply(this, arguments);

console.log(this.model);

if (this.model.get("type") !== "image") {
return this;
}
Expand All @@ -30,10 +28,7 @@ wp.media.view.Attachment.Details = wp.media.view.Attachment.Details.extend({

const button = createElement("button", {
class: "button",
text: __(
"Generate Alt Text using GPT Vision",
"gpt-vision-img-alt-generator",
),
text: __("Generate Alt Text", "gpt-vision-img-alt-generator"),
onclick: async (e) => {
const currentAlt = this.model.get("alt");
if (currentAlt?.length) {
Expand Down
24 changes: 12 additions & 12 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"compilerOptions": {
"target": "ES6",
"jsx": "react-jsx",
"esModuleInterop": true,
"resolveJsonModule": true,
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"strict": true,
"typeRoots": ["node_modules/@types", "src/types"]
},
"include": ["src"],
"exclude": ["build", "node_modules", "vendor"]
"compilerOptions": {
"jsx": "react-jsx",
"esModuleInterop": true,
"resolveJsonModule": true,
"module": "ESNext",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true,
"strict": true,
"typeRoots": ["node_modules/@types", "src/types"]
},
"include": ["src"],
"exclude": ["build", "node_modules", "vendor"]
}

0 comments on commit 1bdd0f7

Please sign in to comment.