Skip to content

Commit

Permalink
Switch to secure json fields
Browse files Browse the repository at this point in the history
  • Loading branch information
oshirohugo committed Sep 13, 2023
1 parent 45563af commit 296a0ab
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 12 deletions.
3 changes: 1 addition & 2 deletions examples/app-basic/provisioning/plugins/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ apps:
disabled: false
jsonData:
apiUrl: http://default-url.com
isApiKeySet: true
secureJsonData:
apiKey: secret-key
apiKey: secret-key
6 changes: 2 additions & 4 deletions examples/app-basic/src/components/AppConfig/AppConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { testIds } from '../testIds';

export type JsonData = {
apiUrl?: string;
isApiKeySet?: boolean;
};

type State = {
Expand All @@ -26,11 +25,11 @@ interface Props extends PluginConfigPageProps<AppPluginMeta<JsonData>> {}

export const AppConfig = ({ plugin }: Props) => {
const s = useStyles2(getStyles);
const { enabled, pinned, jsonData } = plugin.meta;
const { enabled, pinned, jsonData, secureJsonFields } = plugin.meta;
const [state, setState] = useState<State>({
apiUrl: jsonData?.apiUrl || '',
apiKey: '',
isApiKeySet: Boolean(jsonData?.isApiKeySet),
isApiKeySet: Boolean(secureJsonFields?.apiKey),
});

const onResetApiKey = () =>
Expand Down Expand Up @@ -137,7 +136,6 @@ export const AppConfig = ({ plugin }: Props) => {
pinned,
jsonData: {
apiUrl: state.apiUrl,
isApiKeySet: true,
},
// This cannot be queried later by the frontend.
// We don't want to override it in case it was set previously and left untouched now.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { testIds } from '../testIds';

export type JsonData = {
apiUrl?: string;
isApiKeySet?: boolean;
};

interface Props extends PluginConfigPageProps<AppPluginMeta<JsonData>> {}
Expand Down
1 change: 0 additions & 1 deletion examples/app-with-scenes/provisioning/plugins/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ apps:
disabled: false
jsonData:
apiUrl: http://default-url.com
isApiKeySet: true
secureJsonData:
apiKey: secret-key
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { testIds } from '../testIds';

export type JsonData = {
apiUrl?: string;
isApiKeySet?: boolean;
};

type State = {
Expand All @@ -25,11 +24,11 @@ interface Props extends PluginConfigPageProps<AppPluginMeta<JsonData>> {}

export const AppConfig = ({ plugin }: Props) => {
const s = useStyles2(getStyles);
const { enabled, pinned, jsonData } = plugin.meta;
const { enabled, pinned, jsonData, secureJsonFields } = plugin.meta;
const [state, setState] = useState<State>({
apiUrl: jsonData?.apiUrl || '',
apiKey: '',
isApiKeySet: Boolean(jsonData?.isApiKeySet),
isApiKeySet: Boolean(secureJsonFields?.apiKey),
});

const onResetApiKey = () =>
Expand Down Expand Up @@ -136,7 +135,6 @@ export const AppConfig = ({ plugin }: Props) => {
pinned,
jsonData: {
apiUrl: state.apiUrl,
isApiKeySet: true,
},
// This cannot be queried later by the frontend.
// We don't want to override it in case it was set previously and left untouched now.
Expand Down

0 comments on commit 296a0ab

Please sign in to comment.