Skip to content

Commit

Permalink
Merge branch 'kb_migration' into kb_migration_development
Browse files Browse the repository at this point in the history
  • Loading branch information
kmycode committed Sep 12, 2023
2 parents e34966f + 2c19439 commit 35fe4e7
Show file tree
Hide file tree
Showing 26 changed files with 406 additions and 443 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/bundler-audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:

steps:
- name: Clone repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install native Ruby dependencies
run: sudo apt-get install -y libicu-dev libidn11-dev
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check-i18n.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install system dependencies
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint-css.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:

steps:
- name: Clone repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint-haml.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Clone repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install native Ruby dependencies
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:

steps:
- name: Clone repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint-json.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:

steps:
- name: Clone repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint-md.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:

steps:
- name: Clone repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint-ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:

steps:
- name: Clone repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install native Ruby dependencies
run: sudo apt-get install -y libicu-dev libidn11-dev
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint-yml.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:

steps:
- name: Clone repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:

steps:
- name: Clone repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-migrations-one-step.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
BUNDLE_RETRY: 3

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install native Ruby dependencies
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-migrations-two-step.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
BUNDLE_RETRY: 3

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install native Ruby dependencies
run: |
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/test-ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
SECRET_KEY_BASE: precompile_placeholder

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v3
Expand Down Expand Up @@ -128,7 +128,7 @@ jobs:
- 3
- 4
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/download-artifact@v3
with:
Expand Down Expand Up @@ -204,7 +204,7 @@ jobs:
- '.ruby-version'

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/download-artifact@v3
with:
Expand Down Expand Up @@ -285,7 +285,7 @@ jobs:
- 6379:6379

elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.17.9
image: docker.elastic.co/elasticsearch/elasticsearch:7.17.13
env:
discovery.type: single-node
xpack.security.enabled: false
Expand Down Expand Up @@ -317,7 +317,7 @@ jobs:
- '.ruby-version'

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/download-artifact@v3
with:
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ GEM
activerecord
kaminari-core (= 1.2.2)
kaminari-core (1.2.2)
kt-paperclip (7.2.0)
kt-paperclip (7.2.1)
activemodel (>= 4.2.0)
activesupport (>= 4.2.0)
marcel (~> 1.0.1)
Expand Down Expand Up @@ -642,7 +642,7 @@ GEM
sidekiq (>= 5, < 8)
rspec-support (3.12.1)
rspec_chunked (0.6)
rubocop (1.56.2)
rubocop (1.56.3)
base64 (~> 0.1.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
Expand Down
37 changes: 0 additions & 37 deletions app/javascript/mastodon/actions/account_notes.js

This file was deleted.

18 changes: 18 additions & 0 deletions app/javascript/mastodon/actions/account_notes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { createAppAsyncThunk } from 'mastodon/store/typed_functions';

import api from '../api';

export const submitAccountNote = createAppAsyncThunk(
'account_note/submit',
async (args: { id: string; value: string }, { getState }) => {
// TODO: replace `unknown` with `ApiRelationshipJSON` when it is merged
const response = await api(getState).post<unknown>(
`/api/v1/accounts/${args.id}/note`,
{
comment: args.value,
},
);

return { relationship: response.data };
},
);
76 changes: 0 additions & 76 deletions app/javascript/mastodon/api.js

This file was deleted.

63 changes: 63 additions & 0 deletions app/javascript/mastodon/api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import type { AxiosResponse, RawAxiosRequestHeaders } from 'axios';
import axios from 'axios';
import LinkHeader from 'http-link-header';

import ready from './ready';
import type { GetState } from './store';

export const getLinks = (response: AxiosResponse) => {
const value = response.headers.link as string | undefined;

if (!value) {
return new LinkHeader();
}

return LinkHeader.parse(value);
};

const csrfHeader: RawAxiosRequestHeaders = {};

const setCSRFHeader = () => {
const csrfToken = document.querySelector<HTMLMetaElement>(
'meta[name=csrf-token]',
);

if (csrfToken) {
csrfHeader['X-CSRF-Token'] = csrfToken.content;
}
};

void ready(setCSRFHeader);

const authorizationHeaderFromState = (getState?: GetState) => {
const accessToken =
getState && (getState().meta.get('access_token', '') as string);

if (!accessToken) {
return {};
}

return {
Authorization: `Bearer ${accessToken}`,
} as RawAxiosRequestHeaders;
};

// eslint-disable-next-line import/no-default-export
export default function api(getState: GetState) {
return axios.create({
headers: {
...csrfHeader,
...authorizationHeaderFromState(getState),
},

transformResponse: [
function (data: unknown) {
try {
return JSON.parse(data as string) as unknown;
} catch {
return data;
}
},
],
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const mapStateToProps = (state, { account }) => ({
const mapDispatchToProps = (dispatch, { account }) => ({

onSave (value) {
dispatch(submitAccountNote(account.get('id'), value));
dispatch(submitAccountNote({ id: account.get('id'), value}));
},

});
Expand Down
Loading

0 comments on commit 35fe4e7

Please sign in to comment.