Skip to content

Commit

Permalink
added i18next eslint plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Ducica committed Dec 1, 2023
1 parent 76a45f1 commit 788cec5
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 3 deletions.
69 changes: 67 additions & 2 deletions oarepo_ui/theme/assets/semantic-ui/js/oarepo_ui/api/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ export class OARepoDepositApiClient extends DepositApiClient {
*/
readDraft = async (draftLinks) => {
return this._createResponse(() => {
const response = this.axiosWithConfig.get(relativeUrl(draftLinks.self))
return this.recordSerializer.deserialize(response)
const response = this.axiosWithConfig.get(relativeUrl(draftLinks.self));
return this.recordSerializer.deserialize(response);
});
};

Expand Down Expand Up @@ -176,3 +176,68 @@ export class OARepoDepositApiClient extends DepositApiClient {
);
};
}

export class DepositFileApiClient {
constructor(additionalApiConfig) {
if (this.constructor === DepositFileApiClient) {
throw new Error("Abstract");
}
const additionalHeaders = _get(additionalApiConfig, "headers", {});
this.apiHeaders = Object.assign({}, BASE_HEADERS, additionalHeaders);

const apiConfig = {
withCredentials: true,
xsrfCookieName: "csrftoken",
xsrfHeaderName: "X-CSRFToken",
headers: this.apiHeaders.json,
};
this.axiosWithConfig = axios.create(apiConfig);
}

isCancelled(error) {
return axios.isCancel(error);
}

initializeFileUpload(initializeUploadUrl, filename) {
throw new Error("Not implemented.");
}

uploadFile(uploadUrl, file, onUploadProgress, cancel) {
throw new Error("Not implemented.");
}

finalizeFileUpload(finalizeUploadUrl) {
throw new Error("Not implemented.");
}

deleteFile(fileLinks) {
throw new Error("Not implemented.");
}
}

/**
* Default File API Client for deposits.
*/
export class OARepoDepositFileApiClient extends DepositFileApiClient {
_createResponse = async (axiosRequest) => {
let response;
try {
response = await axiosRequest();
const data = response.data || {};
return data;
} catch (error) {
return Promise.reject(error);
}
};

getDraftFiles = async (draft) => {
return this._createResponse(() => {
const response = this.axiosWithConfig.get(relativeUrl(draft.links.files));
return response;
});
};

deleteFile = (fileLinks) => {
return this.axiosWithConfig.delete(fileLinks.self);
};
}
4 changes: 3 additions & 1 deletion oarepo_ui/theme/webpack.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@
"lodash": "^4.17.0",
"react-text-truncate": "^0.19.0",
},
devDependencies={},
devDependencies={
"eslint-plugin-i18next":"^6.0.3"
},
aliases={
"@translations/oarepo_ui": "translations/oarepo_ui",
"../../theme.config$": "less/theme.config",
Expand Down

0 comments on commit 788cec5

Please sign in to comment.