Skip to content

Commit

Permalink
Merge branch 'alpha' into beta
Browse files Browse the repository at this point in the history
  • Loading branch information
Ninerian committed Oct 14, 2024
2 parents ea62b36 + 63ff6bd commit a2df8e3
Show file tree
Hide file tree
Showing 14 changed files with 135 additions and 7 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,18 @@ jobs:
needs: test
runs-on: ubuntu-20.04
steps:
- name: Obtain App Token
uses: actions/create-github-app-token@v1.10.3
id: get_token
with:
app-id: ${{ vars.STAFFBASE_ACTIONS_APP_ID }}
private-key: ${{ secrets.STAFFBASE_ACTIONS_PRIVATE_KEY }}

- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
token: ${{ steps.get_token.outputs.token }}

- uses: actions/setup-node@v4
with:
Expand All @@ -58,6 +66,7 @@ jobs:
run: yarn semantic-release
env:
GITHUB_NPM_CONFIG_REGISTRY: https://npm.pkg.github.com/
GITHUB_NPM_TOKEN: ${{ secrets.STAFFBOT_GITHUB_TOKEN }}
GITHUB_NPM_TOKEN: ${{ secrets.STAFFBOT_NPM_WRITE }}
GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}
PUBLIC_NPM_CONFIG_REGISTRY: https://registry.npmjs.org
PUBLIC_NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
41 changes: 41 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,44 @@
# [3.0.0-alpha.2](https://github.com/Staffbase/plugins-client-sdk/compare/3.0.0-alpha.1...3.0.0-alpha.2) (2024-10-14)


### chore

* **deps-dev:** bump rollup from 3.29.4 to 4.21.0 ([4edc9cf](https://github.com/Staffbase/plugins-client-sdk/commit/4edc9cf8e1bf3682f10690e65986c7e5875535b2))
* **deps-dev:** bump rollup from 3.29.4 to 4.21.0 ([05b19b6](https://github.com/Staffbase/plugins-client-sdk/commit/05b19b6454492697a03532b0d6a68d5dabbf86ac))
* **deps:** bump braces from 3.0.2 to 3.0.3 ([d816fcb](https://github.com/Staffbase/plugins-client-sdk/commit/d816fcbbb27b44ae5de70eaf953c800812bdb59d))
* **deps:** bump Staffbase/gha-workflows from 4.0.2 to 5.2.0 ([8c0adf6](https://github.com/Staffbase/plugins-client-sdk/commit/8c0adf62e806a8c06661d3bcec92d95b8504d2e3))
* **deps:** bump Staffbase/gha-workflows from 5.2.0 to 5.5.0 ([9627af1](https://github.com/Staffbase/plugins-client-sdk/commit/9627af16e0c889e1066fab2bcca98b346fc3af67))
* **deps:** bump Staffbase/gha-workflows from 5.5.0 to 6.0.0 ([3d83de6](https://github.com/Staffbase/plugins-client-sdk/commit/3d83de65789a729fcb586d8f4b050187336b7124))
* **deps:** bump tar from 6.1.11 to 6.2.1 ([579df8e](https://github.com/Staffbase/plugins-client-sdk/commit/579df8e105a005cfba5f7f6e32df30e12dc6f404))
* **deps:** bump the npm-updates group across 1 directory with 20 updates ([356913b](https://github.com/Staffbase/plugins-client-sdk/commit/356913b4081a68eee520d128df9cef3014ebeb02))
* **deps:** bump the npm-updates group across 1 directory with 20 updates ([75578e2](https://github.com/Staffbase/plugins-client-sdk/commit/75578e218b056ef2adf42eec434cce9fadbfc493))
* **deps:** bump ws from 8.12.0 to 8.17.1 ([8fa5d6a](https://github.com/Staffbase/plugins-client-sdk/commit/8fa5d6a568a34e397216d4209460bb1cde61cb77))
* finish implementation ([c7cd832](https://github.com/Staffbase/plugins-client-sdk/commit/c7cd832d425c8413a459c55d13fb2851e4d1c09e))
* fix ([36b97e5](https://github.com/Staffbase/plugins-client-sdk/commit/36b97e58f57c037933e5430d0c80a01069204d55))
* fix typo ([0fc5f16](https://github.com/Staffbase/plugins-client-sdk/commit/0fc5f1691380dc6daf1ec6dee112027d9d84766a))
* fix typo ([816e564](https://github.com/Staffbase/plugins-client-sdk/commit/816e564bf872951032c1f6eca13566eeea22fc60))
* fix typo ([5e44be1](https://github.com/Staffbase/plugins-client-sdk/commit/5e44be143c6289c56dfbe67e02751abff7b76206))
* try release workflow with the sb actions token ([c701170](https://github.com/Staffbase/plugins-client-sdk/commit/c701170776a2ac5f58b37d69341b34654a7222e4))
* try release workflow with the sb actions token ([faf9f39](https://github.com/Staffbase/plugins-client-sdk/commit/faf9f3953fa93ee7a8546bd4e8a5661a84b81bbd))
* update index.html ([53583c9](https://github.com/Staffbase/plugins-client-sdk/commit/53583c9dda113fc9b5781b5076347113613f23dc))
* update semver ([800a05a](https://github.com/Staffbase/plugins-client-sdk/commit/800a05ad1fafce75aeed4b1d1ade5cab341dbea7))
* updated api.md ([1812b09](https://github.com/Staffbase/plugins-client-sdk/commit/1812b09f937ba2845801ba31cdd1199a14bc4760))
* updated docs ([377268d](https://github.com/Staffbase/plugins-client-sdk/commit/377268dff57096d9982c86a9ff426348b51af344))
* updated docs ([bb1b8da](https://github.com/Staffbase/plugins-client-sdk/commit/bb1b8dadd17d61694d435d43e5ded8701f6f6dec))
* updated method naming ([d649474](https://github.com/Staffbase/plugins-client-sdk/commit/d6494745a8524f9e32523fd1ee4066ef8fcb4679))
* updated snapshot ([8ee0427](https://github.com/Staffbase/plugins-client-sdk/commit/8ee0427739c9f17ff884327a460cda69fc59a158))
* updated test & readme ([9a3ddd7](https://github.com/Staffbase/plugins-client-sdk/commit/9a3ddd7f8c1210bf389da6bd957091d6e67059a1))


### feat

* add getusercontentlanguage to client sdk ([f1ad989](https://github.com/Staffbase/plugins-client-sdk/commit/f1ad98920e0f8ad1b1216d504b5a6853a3c16a87))


### refactor

* remove from error from doc ([8de8250](https://github.com/Staffbase/plugins-client-sdk/commit/8de82502520c176e6c2d322ec8f156039e988e20))

# [3.0.0-alpha.1](https://github.com/Staffbase/plugins-client-sdk/compare/2.0.1...3.0.0-alpha.1) (2024-03-12)


Expand Down
6 changes: 3 additions & 3 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ To run the tests a simple `# yarn jest` command in the root directory will suffi

## License

Copyright 2018 Staffbase GmbH.
Copyright 2024 Staffbase GmbH.

Licensed under the Apache License, Version 2.0: <http://www.apache.org/licenses/LICENSE-2.0>

Expand All @@ -54,8 +54,8 @@ Licensed under the Apache License, Version 2.0: <http://www.apache.org/licenses/
</td>
<td>
<b>Staffbase GmbH</b>
<br />Staffbase is an internal communications platform built to revolutionize the way you work and unite your company. Staffbase is hiring: <a href="https://jobs.staffbase.com" target="_blank" rel="noreferrer">jobs.staffbase.com</a>
<br /><a href="https://github.com/Staffbase" target="_blank" rel="noreferrer">GitHub</a> | <a href="https://staffbase.com/" target="_blank" rel="noreferrer">Website</a> | <a href="https://jobs.staffbase.com" target="_blank" rel="noreferrer">Jobs</a>
<br />Staffbase is an internal communications platform built to revolutionize the way you work and unite your company. Staffbase is hiring: <a href="https://staffbase.com/jobs/" target="_blank" rel="noreferrer">jobs.staffbase.com</a>
<br /><a href="https://github.com/Staffbase" target="_blank" rel="noreferrer">GitHub</a> | <a href="https://staffbase.com/" target="_blank" rel="noreferrer">Website</a> | <a href="https://staffbase.com/jobs/" target="_blank" rel="noreferrer">Jobs</a>
</td>
</tr>
</table>
9 changes: 9 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ should be used.</p>
<dt><a href="#getPreferredContentLocale">getPreferredContentLocale(content)</a> ⇒ <code>Promise.&lt;string&gt;</code></dt>
<dd><p>Gets the chosen language from a given content object</p>
</dd>
<dt><a href="#getUserContentLocale">getUserContentLocale()</a> ⇒ <code>Promise.&lt;any&gt;</code></dt>
<dd><p>Get the current user&#39;s content locale, fallback to branch default locale</p>
</dd>
</dl>

<a name="openNativeShareDialog"></a>
Expand Down Expand Up @@ -179,3 +182,9 @@ Gets the chosen language from a given content object
getPreferredContentLocale(['de_DE', 'en_EN']) // => 'de_DE'
getPreferredContentLocale({'de_DE': {1,'eins'}, 'en_EN': {1: 'one'}}) // => 'de_DE'
```
<a name="getUserContentLocale"></a>

## getUserContentLocale() ⇒ <code>Promise.&lt;any&gt;</code>
Get the current user's content locale, fallback to branch default locale

**Kind**: global function
11 changes: 11 additions & 0 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,17 @@ As a developer you can request various informations from the Staffbase app.
}
```

1. `getUserContentLocale` -> string

the content locale which is set for current user. Fallback is the branch default locale

```js
// example for user with german content locale in an english app
getUserContentLocale().then(function (locale) {
console.log(locale); // 'de_DE'
})
```

### Invoking native methods

With the SDK you can invoke methods, which are in the scope of the native app.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@staffbase/plugins-client-sdk",
"version": "3.0.0-alpha.1",
"version": "3.0.0-alpha.2",
"description": "Staffbase plugins client SDK for JavaScript",
"main": "dist/plugins-client-sdk.js",
"module": "dist/plugins-client-sdk.esm.js",
Expand Down
18 changes: 18 additions & 0 deletions resources/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,11 @@ <h5>
>
<pre id="isBranchDefaultLang"></pre>
<br />
<strong
>getUserContentLocale() - User Content Locale:</strong
>
<pre id="isUserContentLocale"></pre>
<br />
<strong>getContentLanguages() - Content Languages:</strong>
<pre id="isContentLangs"></pre>
<br />
Expand Down Expand Up @@ -799,6 +804,19 @@ <h5>Native Share Dialog</h5>
error
);
});
PluginSDK.getUserContentLocale()
.then(function (isUserContentLocale) {
console.log("User Content Language: ", isUserContentLocale);
document.getElementById(
"isUserContentLocale"
).textContent = JSON.stringify(isUserContentLocale, undefined, 2);
})
.catch(function (error) {
console.warn(
"Something went wrong with getUserContentLocale(): ",
error
);
});
PluginSDK.getContentLanguages()
.then(function (isContentLangs) {
console.log("Content Languages: ", isContentLangs);
Expand Down
10 changes: 10 additions & 0 deletions src/lib/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,13 @@ export const getPreferredContentLocale = async (content) => {
log.debug('app/getPreferredContentLocale');
return sendMessage(cmd.prefContentLang, content);
};

/**
* Get the default content language configured for the branch.
*
* @return {Promise<Object>}
*/
export const getUserContentLocale = async () => {
log.debug('app/getUserContentLocale');
return sendMessage(cmd.langInfos).then((res) => res.userContentLocale);
};
3 changes: 2 additions & 1 deletion src/lib/connection/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ export const commands = {
nativeShare: 'nativeShareDialog',
langInfos: 'getLanguageInfos',
branchDefaultLang: 'getBranchDefaultLanguage',
prefContentLang: 'getPreferredContentLocale'
prefContentLang: 'getPreferredContentLocale',
userContentLocale: 'getUserContentLocale'
};

/**
Expand Down
12 changes: 12 additions & 0 deletions src/lib/connection/connector/fallback-handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,15 @@ export const getPreferredContentLocale = (content) => {
return keys[index] || keys[0];
}
};

/**
* Get the current user's content locale, fallback to branch default locale
*
* @return {String} the user's content locale
*/
export const getUserContentLocale = () => {
log.debug('fallback/getUserContentLocale');
const locale = getBranchDefaultLanguage().locale;

return locale;
};
2 changes: 2 additions & 0 deletions src/lib/connection/connector/fallback.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ export const sendMessage = async (cmd, ...payload) => {
return fallbacks.getBranchDefaultLanguage();
case action.prefContentLang:
return fallbacks.getPreferredContentLocale.apply(null, payload);
case action.userContentLocale:
return fallbacks.getUserContentLocale();
case action.nativeUpload:
case action.nativeShare:
return fallbacks.unSupported(cmd);
Expand Down
7 changes: 7 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@ export const getContentLanguages = async () => app.getContentLanguages();
*/
export const getPreferredContentLocale = async (content) => app.getPreferredContentLocale(content);

/**
* Get the current user's content locale, fallback to branch default locale
* @function
* @return {Promise<any>}
*/
export const getUserContentLocale = async () => app.getUserContentLocale();

/**
* Open a share dialog on native devices
*
Expand Down
8 changes: 7 additions & 1 deletion test/lib/app.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ const langInfos = {
branchLanguages: branchLanguages,
branchDefaultLanguage: branchLanguages.de,
deviceLanguage: branchLanguages.en,
contentLanguages: branchLanguages
contentLanguages: branchLanguages,
userContentLocale: branchLanguages.en.locale
};

const mockVersion = '3.6-dev';
Expand Down Expand Up @@ -80,6 +81,11 @@ describe('app', () => {
expect(await App.getPreferredContentLocale(['de_DE', 'EN_US'])).toEqual('de_DE');
});

it('should get the current user content locale', async () => {
messageStub.changeMsg(langInfoMsg);
expect(await App.getUserContentLocale()).toEqual(langInfos.userContentLocale);
});

it('should open links', async () => {
messageStub.changeMsg(['SUCCESS', 0, true]);
expect(await App.openLink('https://test.de')).toEqual(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -902,4 +902,6 @@ exports[`connector/fallback connect send function accepts all comands command.op

exports[`connector/fallback connect send function accepts all comands command.prefContentLang 1`] = `"en_US"`;

exports[`connector/fallback connect send function accepts all comands command.userContentLocale 1`] = `"en_US"`;

exports[`connector/fallback connect send function accepts all comands command.version 1`] = `"3.4"`;

0 comments on commit a2df8e3

Please sign in to comment.